Closed ryandash closed 2 years ago
What are the effects from this change?
What are the effects from this change?
chooseElevator is called only when the elevatorSubsystem pulls from the scheduler. Since the elevatorSubsystem alternates between sending and receiving, the elevator monitor will be updated between each pull of an event from the scheduler. This should select appropriate elevators instead of the old implementation which probably was probably adding all requests to the first elevator.
Getting some errors in Scheduler test -
Exception in thread "Scheduler" java.lang.NullPointerException: Cannot invoke "java.net.DatagramSocket.receive(java.net.DatagramPacket)" because "this.socket" is null
at client_server_host.MessageTransfer.receiveMessage(MessageTransfer.java:69)
at client_server_host.IntermediateHost.receivePacket(IntermediateHost.java:37)
at scheduler.Scheduler.receiveAndProcessPacket(Scheduler.java:67)
at scheduler.Scheduler.run(Scheduler.java:188)
at java.base/java.lang.Thread.run(Thread.java:833)
Exception in thread "Scheduler" java.lang.NullPointerException: Cannot invoke "java.net.DatagramSocket.receive(java.net.DatagramPacket)" because "this.socket" is null
at client_server_host.MessageTransfer.receiveMessage(MessageTransfer.java:69)
at client_server_host.IntermediateHost.receivePacket(IntermediateHost.java:37)
at scheduler.Scheduler.receiveAndProcessPacket(Scheduler.java:67)
at scheduler.Scheduler.run(Scheduler.java:188)
at java.base/java.lang.Thread.run(Thread.java:833)
Getting some errors in Scheduler test -
Exception in thread "Scheduler" java.lang.NullPointerException: Cannot invoke "java.net.DatagramSocket.receive(java.net.DatagramPacket)" because "this.socket" is null at client_server_host.MessageTransfer.receiveMessage(MessageTransfer.java:69) at client_server_host.IntermediateHost.receivePacket(IntermediateHost.java:37) at scheduler.Scheduler.receiveAndProcessPacket(Scheduler.java:67) at scheduler.Scheduler.run(Scheduler.java:188) at java.base/java.lang.Thread.run(Thread.java:833) Exception in thread "Scheduler" java.lang.NullPointerException: Cannot invoke "java.net.DatagramSocket.receive(java.net.DatagramPacket)" because "this.socket" is null at client_server_host.MessageTransfer.receiveMessage(MessageTransfer.java:69) at client_server_host.IntermediateHost.receivePacket(IntermediateHost.java:37) at scheduler.Scheduler.receiveAndProcessPacket(Scheduler.java:67) at scheduler.Scheduler.run(Scheduler.java:188) at java.base/java.lang.Thread.run(Thread.java:833)
The scheduler test is broken. It needs a rework to work with UDP or we simply need to give up on it.
Perhaps breaking up the receiveAndProcess method into smaller methods would make it easier to test
change the implementation of intermediate host and Scheduler method to make the elevator selection happen when the requester pulls off of the queue instead of when the sender adds to the queue
move message queue into Intermediate host