/** * Updates a {@link Robot} with information about a waveletUpdate event. * * @param robot The robot to process the update for. * @param wavelet the wavelet on which the update is occuring. * @param deltas the deltas the have been applied to the given wavelet. */ private void updateRobot(Robot robot, ReadableWaveletData wavelet, DeltaSequence deltas) { try { robot.waveletUpdate(wavelet, deltas); ensureScheduled(robot); } catch (OperationException e) { LOG.warning("Unable to update robot(" + robot.getRobotName() + ")", e); } }
public void testRunNotRequeingIfNoWork() { robot.run(); verify(gateway).doneRunning(robot); verify(gateway, never()).ensureScheduled(robot); }
public void testRunNotRequeingIfNoWork() { robot.run(); verify(gateway).doneRunning(robot); verify(gateway, never()).ensureScheduled(robot); }
public void testRunRequeuesRobotIfDoneWork() throws Exception { enqueueEmptyWavelet(); robot.run(); verify(gateway).doneRunning(robot); verify(gateway).ensureScheduled(robot); }
public void testRunRequeuesRobotIfDoneWork() throws Exception { enqueueEmptyWavelet(); robot.run(); verify(gateway).doneRunning(robot); verify(gateway).ensureScheduled(robot); }
public void testEnsureRunnableCallsRobot() throws Exception { Robot robot = mock(Robot.class); when(robot.getRobotName()).thenReturn(RobotName.fromAddress("robot@example.com")); gateway.ensureScheduled(robot); executor.runAllCommands(); verify(robot).run(); }
public void testEnsureRunnableCallsRobot() throws Exception { Robot robot = mock(Robot.class); when(robot.getRobotName()).thenReturn(RobotName.fromAddress("robot@example.com")); gateway.ensureScheduled(robot); executor.runAllCommands(); verify(robot).run(); }
/** * Runs this {@link Robot} by checking its queue for a new wavelet and then * processing this wavelet. In the end the {@link Robot} will check whether it * needs to requeue itself in the RobotGateway or that no further actions need * to be taken. */ @Override public void run() { try { LOG.fine(robotName + " called for processing"); WaveletAndDeltas wavelet = dequeueWavelet(); if (wavelet == null) { gateway.doneRunning(this); return; } process(wavelet); } catch (RuntimeException e) { LOG.severe("Unexpected error occurred when robot " + robotName + " was called", e); } // Requeue since we either had an exception or we processed a wavelet. gateway.doneRunning(this); gateway.ensureScheduled(this); }