org.apache.reef.wake.time.event.StopTime Java Examples

The following examples show how to use org.apache.reef.wake.time.event.StopTime. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RuntimeClock.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * Wait for all client alarms to finish executing and gracefully shutdown the clock.
 */
@Override
public void close() {

  LOG.entering(CLASS_NAME, "close");

  synchronized (this.schedule) {

    if (this.isClosed) {
      LOG.exiting(CLASS_NAME, "close", "Clock has already been closed");
      return;
    }

    this.isClosed = true;

    final Time stopEvent = new StopTime(Math.max(this.timer.getCurrent(), this.lastClientAlarm + 1));
    LOG.log(Level.FINE,
        "Graceful shutdown scheduled: {0} Outstanding client alarms: {1}",
        new Object[] {stopEvent, this.numClientAlarms});

    this.schedule.add(stopEvent);
    this.schedule.notify();
  }

  LOG.exiting(CLASS_NAME, "close");
}
 
Example #2
Source File: RuntimeClock.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private RuntimeClock(
    final Timer timer,
    @Parameter(Clock.StartHandler.class)
        final InjectionFuture<Set<EventHandler<StartTime>>> startHandler,
    @Parameter(Clock.StopHandler.class)
        final InjectionFuture<Set<EventHandler<StopTime>>> stopHandler,
    @Parameter(Clock.RuntimeStartHandler.class)
        final InjectionFuture<Set<EventHandler<RuntimeStart>>> runtimeStartHandler,
    @Parameter(Clock.RuntimeStopHandler.class)
        final InjectionFuture<Set<EventHandler<RuntimeStop>>> runtimeStopHandler,
    @Parameter(Clock.IdleHandler.class)
        final InjectionFuture<Set<EventHandler<IdleClock>>> idleHandler) {

  this.timer = timer;
  this.startHandler = startHandler;
  this.stopHandler = stopHandler;
  this.runtimeStartHandler = runtimeStartHandler;
  this.runtimeStopHandler = runtimeStopHandler;
  this.idleHandler = idleHandler;

  LOG.log(Level.FINE, "RuntimeClock instantiated.");
}
 
Example #3
Source File: GRPCDriverClientService.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public void driverRestartCompletedHandler(
    final DriverRestartCompletedInfo request,
    final StreamObserver<Void> responseObserver) {
  try (ObserverCleanup cleanup = ObserverCleanup.of(responseObserver)) {
    this.clientDriverDispatcher.get().dispatchRestart(new DriverRestartCompleted() {
      @Override
      public Time getCompletedTime() {
        return new StopTime(request.getCompletionTime().getStopTime());
      }

      @Override
      public boolean isTimedOut() {
        return request.getIsTimedOut();
      }
    });
  }
}
 
Example #4
Source File: GRPCDriverClientService.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public void stopHandler(final StopTimeInfo request, final StreamObserver<ExceptionInfo> responseObserver) {
  try {
    LOG.log(Level.INFO, "StopHandler at time {0}", request.getStopTime());
    final StopTime stopTime = new StopTime(request.getStopTime());
    final Throwable error = this.clientDriverDispatcher.get().dispatch(stopTime);
    if (error != null) {
      responseObserver.onNext(GRPCUtils.createExceptionInfo(this.exceptionCodec, error));
    } else {
      responseObserver.onNext(ExceptionInfo.newBuilder().setNoError(true).build());
    }
  } finally {
    responseObserver.onCompleted();
    this.server.shutdown();
  }
}
 
Example #5
Source File: HttpShellJobDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime time) {
  synchronized (HttpShellJobDriver.this) {
    LOG.log(Level.INFO, "{0} StopTime: {1}", new Object[]{state, time});
    for (final ActiveContext context : contexts.values()) {
      context.close();
    }
  }
}
 
Example #6
Source File: JobDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime time) {
  LOG.log(Level.INFO, " StopTime: {0}", new Object[]{time});
  try (LoggingScope ls = loggingScopeFactory.driverStop(time.getTimestamp())) {
    for (final ActiveContext context : contexts.values()) {
      context.close();
    }
  }
}
 
Example #7
Source File: MockDriverRestartContext.java    From reef with Apache License 2.0 5 votes vote down vote up
public DriverRestartCompleted getDriverRestartCompleted(final boolean isTimeout, final long restartDuration) {
  return new DriverRestartCompleted() {
    @Override
    public Time getCompletedTime() {
      return new StopTime(startTime.getTimestamp() + restartDuration);
    }

    @Override
    public boolean isTimedOut() {
      return isTimeout;
    }
  };
}
 
Example #8
Source File: TestHttpConfiguration.java    From reef with Apache License 2.0 5 votes vote down vote up
@Test
public void stopStateHandlerTest() throws InjectionException {

  final ReefEventStateManager.StopStateHandler h =
      this.injector.getInstance(ReefEventStateManager.StopStateHandler.class);
  Assert.assertNotNull(h);

  final StopTime st = new StopTime(new Date().getTime());
  h.onNext(st);

  final ReefEventStateManager reefEventStateManager =
      this.injector.getInstance(ReefEventStateManager.class);

  Assert.assertEquals(reefEventStateManager.getStopTime(), convertTime(st.getTimestamp()));
}
 
Example #9
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * We must implement this synchronously in order to catch exceptions and
 * forward them back via the bridge before the server shuts down, after
 * this method returns.
 * @param stopTime stop time
 */
@SuppressWarnings("checkstyle:illegalCatch")
public Throwable dispatch(final StopTime stopTime) {
  try {
    for (final EventHandler<StopTime> handler : stopHandlers) {
      handler.onNext(stopTime);
    }
    return null;
  } catch (Throwable t) {
    return t;
  }
}
 
Example #10
Source File: ProfilingStopHandler.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  try (PrintWriter out = new PrintWriter("profile-" + launchID + ".json", "UTF-8")) {
    out.print(profiler.objectGraphToString());
  } catch (final FileNotFoundException | UnsupportedEncodingException e) {
    LOG.log(Level.WARNING, "Unable to write the profile", e);
  }
}
 
Example #11
Source File: TaskCountingDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  synchronized (expectedRunningTaskIds) {
    if (!expectedRunningTaskIds.isEmpty()) {
      throw new DriverSideFailure("Still expecting RunningTasks");
    }
  }
}
 
Example #12
Source File: EvaluatorCompleteTestDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  synchronized (completedEvaluatorReceived) {
    if (completedEvaluatorReceived.get() && completedTaskReceived.get()) {
      LOG.log(Level.FINE, "Received an expected CompletedEvaluator and CompletedTask before exit. All good.");
    } else {
      throw new DriverSideFailure("Did not receive expected completion events.");
    }
  }
}
 
Example #13
Source File: EvaluatorCloseDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  if (!changedToClosing.get()) {
    throw new DriverSideFailure("Evaluator's state was not changed to closing.");
  } else if (!taskRepresenter.evaluatorIsClosed()){
    throw new DriverSideFailure("Evaluator's state was not changed to closed after completion.");
  } else {
    LOG.log(Level.FINEST, "Evaluator state was changed properly (RUNNING -> CLOSING -> CLOSED).");
  }
}
 
Example #14
Source File: EvaluatorFailureDuringAlarmDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  if (failedEvaluatorReceived.get()) {
    LOG.log(Level.FINEST, "Received FailedEvaluator.");
  } else {
    throw new DriverSideFailure("Never Received the FailedEvaluator.");
  }

  if (otherFailuresReceived.get()) {
    throw new DriverSideFailure("Received more events than the FailedEvaluator.");
  }
}
 
Example #15
Source File: EvaluatorExitTestDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  synchronized (failedEvaluatorReceived) {
    if (failedEvaluatorReceived.get()) {
      LOG.log(Level.FINE, "Received an expected FailedEvaluator before exit. All good.");
    } else {
      throw new DriverSideFailure("Did not receive an expected FailedEvaluator.");
    }
  }
}
 
Example #16
Source File: FailureDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  final int numEvaluatorsToClose = FailureDriver.this.numEvaluatorsLeftToClose.get();
  if (numEvaluatorsToClose != 0){
    final String message = "Got RuntimeStop Event. Expected to close " + numEvaluatorsToSubmit + " Evaluators " +
        "but only " + (numEvaluatorsToSubmit - numEvaluatorsToClose) + " Evaluators were closed.";
    LOG.log(Level.SEVERE, message);
    throw new DriverSideFailure(message);
  }
}
 
Example #17
Source File: NemoDriver.java    From nemo with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  handler.close();
}
 
Example #18
Source File: MockApplication.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  running = false;
}
 
Example #19
Source File: MockRuntimeDriver.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void stop() {
  post(this.driverStopHandlers, new StopTime(this.clock.get().getCurrentTime()));
}
 
Example #20
Source File: MockRuntimeDriver.java    From reef with Apache License 2.0 4 votes vote down vote up
@Inject
MockRuntimeDriver(
    final InjectionFuture<MockClock> clock,
    final MockTaskReturnValueProvider taskReturnValueProvider,
    @Parameter(DriverStartHandler.class) final Set<EventHandler<StartTime>> driverStartHandlers,
    @Parameter(Clock.StopHandler.class) final Set<EventHandler<StopTime>> driverStopHandlers,
    @Parameter(EvaluatorAllocatedHandlers.class) final Set<EventHandler<AllocatedEvaluator>>
        allocatedEvaluatorHandlers,
    @Parameter(EvaluatorCompletedHandlers.class) final Set<EventHandler<CompletedEvaluator>>
        completedEvaluatorHandlers,
    @Parameter(EvaluatorFailedHandlers.class) final Set<EventHandler<FailedEvaluator>> failedEvaluatorHandlers,
    @Parameter(TaskRunningHandlers.class) final Set<EventHandler<TaskRunningHandlers>> taskRunningHandlers,
    @Parameter(TaskFailedHandlers.class) final Set<EventHandler<FailedTask>> taskFailedHandlers,
    @Parameter(TaskMessageHandlers.class) final Set<EventHandler<TaskMessage>> taskMessageHandlers,
    @Parameter(TaskCompletedHandlers.class) final Set<EventHandler<CompletedTask>> taskCompletedHandlers,
    @Parameter(TaskSuspendedHandlers.class) final Set<EventHandler<SuspendedTask>> taskSuspendedHandlers,
    @Parameter(ContextActiveHandlers.class) final Set<EventHandler<ActiveContext>> contextActiveHandlers,
    @Parameter(ContextClosedHandlers.class) final Set<EventHandler<CloseContext>> contextClosedHandlers,
    @Parameter(ContextMessageHandlers.class) final Set<EventHandler<ContextMessage>> contextMessageHandlers,
    @Parameter(ContextFailedHandlers.class) final Set<EventHandler<FailedContext>> contextFailedHandlers,
    @Parameter(DriverRestartHandler.class) final Set<EventHandler<DriverRestarted>>
        driverRestartHandlers,
    @Parameter(DriverRestartTaskRunningHandlers.class) final Set<EventHandler<RunningTask>>
        driverRestartRunningTaskHandlers,
    @Parameter(DriverRestartContextActiveHandlers.class) final Set<EventHandler<ActiveContext>>
        driverRestartActiveContextHandlers,
    @Parameter(DriverRestartCompletedHandlers.class) final Set<EventHandler<DriverRestartCompleted>>
        driverRestartCompletedHandlers,
    @Parameter(DriverRestartFailedEvaluatorHandlers.class) final Set<EventHandler<FailedEvaluator>>
        driverRestartFailedEvaluatorHandlers){
  this.clock = clock;
  this.taskReturnValueProvider = taskReturnValueProvider;
  this.driverStartHandlers = driverStartHandlers;
  this.driverStopHandlers = driverStopHandlers;
  this.allocatedEvaluatorHandlers = allocatedEvaluatorHandlers;
  this.completedEvaluatorHandlers = completedEvaluatorHandlers;
  this.failedEvaluatorHandlers = failedEvaluatorHandlers;
  this.taskRunningHandlers = taskRunningHandlers;
  this.taskFailedHandlers = taskFailedHandlers;
  this.taskMessageHandlers = taskMessageHandlers;
  this.taskCompletedHandlers = taskCompletedHandlers;
  this.taskSuspendedHandlers = taskSuspendedHandlers;
  this.contextActiveHandlers = contextActiveHandlers;
  this.contextClosedHandlers = contextClosedHandlers;
  this.contextMessageHandlers = contextMessageHandlers;
  this.contextFailedHandlers = contextFailedHandlers;
  this.driverRestartHandlers = driverRestartHandlers;
  this.driverRestartRunningTaskHandlers = driverRestartRunningTaskHandlers;
  this.driverRestartActiveContextHandlers = driverRestartActiveContextHandlers;
  this.driverRestartCompletedHandlers = driverRestartCompletedHandlers;
  this.driverRestartFailedEvaluatorHandlers = driverRestartFailedEvaluatorHandlers;
}
 
Example #21
Source File: WatcherAvroUtil.java    From reef with Apache License 2.0 4 votes vote down vote up
public static AvroStopTime toAvroStopTime(final StopTime stopTime) {
  return AvroStopTime.newBuilder()
      .setTimestamp(stopTime.getTimestamp())
      .build();
}
 
Example #22
Source File: Watcher.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final StopTime stopTime) {
  onEvent(EventType.StopTime, WatcherAvroUtil.toString(WatcherAvroUtil.toAvroStopTime(stopTime)));
}
 
Example #23
Source File: ReefEventStateManager.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("checkstyle:hiddenfield")
public void onNext(final StopTime stopTime) {
  LOG.log(Level.INFO, "StopStateHandler called. StopTime: {0}", stopTime);
  ReefEventStateManager.this.stopTime = stopTime;
}
 
Example #24
Source File: FailDriver.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final StopTime time) {
  FailDriver.this.checkMsgOrder(time);
  // noop
}
 
Example #25
Source File: FailDriverTest.java    From reef with Apache License 2.0 4 votes vote down vote up
@Test
public void testFailDriverStop() throws BindException, InjectionException {
  failOn(StopTime.class);
}
 
Example #26
Source File: FailBridgeDriverTest.java    From reef with Apache License 2.0 4 votes vote down vote up
@Test
public void testFailDriverStop() throws BindException, InjectionException {
  failOn(StopTime.class);
}
 
Example #27
Source File: DefaultDriverClientStopHandler.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final StopTime value) {
  LOG.log(Level.FINEST, "Stop time {0}", value);
}
 
Example #28
Source File: REEFEnvironmentFailDriverTest.java    From reef with Apache License 2.0 4 votes vote down vote up
@Test
public void testFailDriverStop() throws BindException, InjectionException {
  failOn(StopTime.class);
}
 
Example #29
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 4 votes vote down vote up
@Inject
private DriverClientDispatcher(
    final DriverClientExceptionHandler driverExceptionHandler,
    final AlarmDispatchHandler alarmDispatchHandler,
    @Parameter(DriverClientDispatchThreadCount.class)
    final Integer numberOfThreads,
    // Application-provided start and stop handlers
    @Parameter(DriverStartHandler.class)
    final Set<EventHandler<StartTime>> startHandlers,
    @Parameter(ClientDriverStopHandler.class)
    final Set<EventHandler<StopTime>> stopHandlers,
    // Application-provided Context event handlers
    @Parameter(ContextActiveHandlers.class)
    final Set<EventHandler<ActiveContext>> contextActiveHandlers,
    @Parameter(ContextClosedHandlers.class)
    final Set<EventHandler<ClosedContext>> contextClosedHandlers,
    @Parameter(ContextFailedHandlers.class)
    final Set<EventHandler<FailedContext>> contextFailedHandlers,
    @Parameter(ContextMessageHandlers.class)
    final Set<EventHandler<ContextMessage>> contextMessageHandlers,
    // Application-provided Task event handlers
    @Parameter(TaskRunningHandlers.class)
    final Set<EventHandler<RunningTask>> taskRunningHandlers,
    @Parameter(TaskCompletedHandlers.class)
    final Set<EventHandler<CompletedTask>> taskCompletedHandlers,
    @Parameter(TaskSuspendedHandlers.class)
    final Set<EventHandler<SuspendedTask>> taskSuspendedHandlers,
    @Parameter(TaskMessageHandlers.class)
    final Set<EventHandler<TaskMessage>> taskMessageEventHandlers,
    @Parameter(TaskFailedHandlers.class)
    final Set<EventHandler<FailedTask>> taskExceptionEventHandlers,
    // Application-provided Evaluator event handlers
    @Parameter(EvaluatorAllocatedHandlers.class)
    final Set<EventHandler<AllocatedEvaluator>> evaluatorAllocatedHandlers,
    @Parameter(EvaluatorFailedHandlers.class)
    final Set<EventHandler<FailedEvaluator>> evaluatorFailedHandlers,
    @Parameter(EvaluatorCompletedHandlers.class)
    final Set<EventHandler<CompletedEvaluator>> evaluatorCompletedHandlers,
    // Client handlers
    @Parameter(ClientCloseHandlers.class)
    final Set<EventHandler<Void>> clientCloseHandlers,
    @Parameter(ClientCloseWithMessageHandlers.class)
    final Set<EventHandler<byte[]>> clientCloseWithMessageHandlers,
    @Parameter(ClientMessageHandlers.class)
    final Set<EventHandler<byte[]>> clientMessageHandlers,
    // Driver restart handlers
    @Parameter(DriverRestartHandler.class)
    final Set<EventHandler<DriverRestarted>> driverRestartHandlers,
    @Parameter(DriverRestartTaskRunningHandlers.class)
    final Set<EventHandler<RunningTask>> driverRestartTaskRunningHandlers,
    @Parameter(DriverRestartContextActiveHandlers.class)
    final Set<EventHandler<ActiveContext>> driverRestartActiveContextHandlers,
    @Parameter(DriverRestartCompletedHandlers.class)
    final Set<EventHandler<DriverRestartCompleted>> driverRestartCompletedHandlers,
    @Parameter(DriverRestartFailedEvaluatorHandlers.class)
    final Set<EventHandler<FailedEvaluator>> driverRestartFailedEvaluatorHandlers) {
  this(
      driverExceptionHandler,
      alarmDispatchHandler,
      numberOfThreads,
      startHandlers,
      stopHandlers,
      contextActiveHandlers,
      contextClosedHandlers,
      contextFailedHandlers,
      contextMessageHandlers,
      taskRunningHandlers,
      taskCompletedHandlers,
      taskSuspendedHandlers,
      taskMessageEventHandlers,
      taskExceptionEventHandlers,
      evaluatorAllocatedHandlers,
      evaluatorFailedHandlers,
      evaluatorCompletedHandlers,
      clientCloseHandlers,
      clientCloseWithMessageHandlers,
      clientMessageHandlers);
  // Register driver restart handlers.
  this.driverRestartDispatcher.register(DriverRestarted.class, driverRestartHandlers);
  this.driverRestartDispatcher.register(RunningTask.class, driverRestartTaskRunningHandlers);
  this.driverRestartDispatcher.register(ActiveContext.class, driverRestartActiveContextHandlers);
  this.driverRestartDispatcher.register(DriverRestartCompleted.class, driverRestartCompletedHandlers);
  this.driverRestartDispatcher.register(FailedEvaluator.class, driverRestartFailedEvaluatorHandlers);
}
 
Example #30
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 4 votes vote down vote up
@Inject
private DriverClientDispatcher(
    final DriverClientExceptionHandler driverExceptionHandler,
    final AlarmDispatchHandler alarmDispatchHandler,
    @Parameter(DriverClientDispatchThreadCount.class)
    final Integer numberOfThreads,
    // Application-provided start and stop handlers
    @Parameter(DriverStartHandler.class)
    final Set<EventHandler<StartTime>> startHandlers,
    @Parameter(ClientDriverStopHandler.class)
    final Set<EventHandler<StopTime>> stopHandlers,
    // Application-provided Context event handlers
    @Parameter(ContextActiveHandlers.class)
    final Set<EventHandler<ActiveContext>> contextActiveHandlers,
    @Parameter(ContextClosedHandlers.class)
    final Set<EventHandler<ClosedContext>> contextClosedHandlers,
    @Parameter(ContextFailedHandlers.class)
    final Set<EventHandler<FailedContext>> contextFailedHandlers,
    @Parameter(ContextMessageHandlers.class)
    final Set<EventHandler<ContextMessage>> contextMessageHandlers,
    // Application-provided Task event handlers
    @Parameter(TaskRunningHandlers.class)
    final Set<EventHandler<RunningTask>> taskRunningHandlers,
    @Parameter(TaskCompletedHandlers.class)
    final Set<EventHandler<CompletedTask>> taskCompletedHandlers,
    @Parameter(TaskSuspendedHandlers.class)
    final Set<EventHandler<SuspendedTask>> taskSuspendedHandlers,
    @Parameter(TaskMessageHandlers.class)
    final Set<EventHandler<TaskMessage>> taskMessageEventHandlers,
    @Parameter(TaskFailedHandlers.class)
    final Set<EventHandler<FailedTask>> taskExceptionEventHandlers,
    // Application-provided Evaluator event handlers
    @Parameter(EvaluatorAllocatedHandlers.class)
    final Set<EventHandler<AllocatedEvaluator>> evaluatorAllocatedHandlers,
    @Parameter(EvaluatorFailedHandlers.class)
    final Set<EventHandler<FailedEvaluator>> evaluatorFailedHandlers,
    @Parameter(EvaluatorCompletedHandlers.class)
    final Set<EventHandler<CompletedEvaluator>> evaluatorCompletedHandlers,
    // Client handlers
    @Parameter(ClientCloseHandlers.class)
    final Set<EventHandler<Void>> clientCloseHandlers,
    @Parameter(ClientCloseWithMessageHandlers.class)
    final Set<EventHandler<byte[]>> clientCloseWithMessageHandlers,
    @Parameter(ClientMessageHandlers.class)
    final Set<EventHandler<byte[]>> clientMessageHandlers) {
  this.applicationDispatcher = new DispatchingEStage(
      driverExceptionHandler, numberOfThreads, "ClientDriverDispatcher");
  // Application start and stop handlers
  this.applicationDispatcher.register(StartTime.class, startHandlers);
  this.stopHandlers = stopHandlers; // must be called synchronously
  // Application Context event handlers
  this.applicationDispatcher.register(ActiveContext.class, contextActiveHandlers);
  this.applicationDispatcher.register(ClosedContext.class, contextClosedHandlers);
  this.applicationDispatcher.register(FailedContext.class, contextFailedHandlers);
  this.applicationDispatcher.register(ContextMessage.class, contextMessageHandlers);

  // Application Task event handlers.
  this.applicationDispatcher.register(RunningTask.class, taskRunningHandlers);
  this.applicationDispatcher.register(CompletedTask.class, taskCompletedHandlers);
  this.applicationDispatcher.register(SuspendedTask.class, taskSuspendedHandlers);
  this.applicationDispatcher.register(TaskMessage.class, taskMessageEventHandlers);
  this.applicationDispatcher.register(FailedTask.class, taskExceptionEventHandlers);

  // Application Evaluator event handlers
  this.applicationDispatcher.register(AllocatedEvaluator.class, evaluatorAllocatedHandlers);
  this.applicationDispatcher.register(CompletedEvaluator.class, evaluatorCompletedHandlers);
  this.applicationDispatcher.register(FailedEvaluator.class, evaluatorFailedHandlers);

  // Client event handlers;
  this.clientCloseDispatcher = new DispatchingEStage(this.applicationDispatcher);
  this.clientCloseDispatcher.register(Void.class, clientCloseHandlers);

  this.clientCloseWithMessageDispatcher = new DispatchingEStage(this.applicationDispatcher);
  this.clientCloseWithMessageDispatcher.register(byte[].class, clientCloseWithMessageHandlers);

  this.clientMessageDispatcher = new DispatchingEStage(this.applicationDispatcher);
  this.clientMessageDispatcher.register(byte[].class, clientMessageHandlers);

  // Alarm event handlers
  this.alarmDispatcher = new DispatchingEStage(this.applicationDispatcher);
  this.alarmDispatcher.register(String.class,
      Sets.newHashSet((EventHandler<String>)alarmDispatchHandler));

  // Driver restart dispatcher
  this.driverRestartDispatcher = new DispatchingEStage(this.applicationDispatcher);
}