org.apache.reef.driver.evaluator.FailedEvaluator Java Examples

The following examples show how to use org.apache.reef.driver.evaluator.FailedEvaluator. 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: HeronMasterDriver.java    From incubator-heron with Apache License 2.0 6 votes vote down vote up
@Override
public void onNext(FailedEvaluator evaluator) {
  LOG.log(Level.WARNING, "Container:{0} failed", evaluator.getId());
  Optional<HeronWorker> worker = multiKeyWorkerMap.lookupByEvaluatorId(evaluator.getId());
  if (!worker.isPresent()) {
    LOG.log(Level.WARNING,
        "Unknown executor id for failed container: {0}, skip renew action",
        evaluator.getId());
    return;
  }
  LOG.log(Level.INFO, "Trying to relaunch worker {0} running on failed container {1}",
      new Object[]{worker.get().workerId, evaluator.getId()});
  multiKeyWorkerMap.detachEvaluatorAndRemove(worker.get());

  requestContainerForWorker(worker.get().workerId, worker.get());
}
 
Example #2
Source File: HeronMasterDriverTest.java    From incubator-heron with Apache License 2.0 6 votes vote down vote up
@Test
public void onNextFailedEvaluatorRestartsContainer() throws Exception {
  int numContainers = 3;
  AllocatedEvaluator[] mockEvaluators = createApplicationWithContainers(numContainers);

  FailedEvaluator mockFailedContainer = mock(FailedEvaluator.class);
  when(mockFailedContainer.getId()).thenReturn("e1");
  verify(spyDriver, never()).requestContainerForWorker(anyInt(), anyHeronWorker());
  spyDriver.new FailedContainerHandler().onNext(mockFailedContainer);

  for (int id = 0; id < numContainers; id++) {
    if (id == 1) {
      verify(spyDriver, times(1)).requestContainerForWorker(eq(id), anyHeronWorker());
      assertFalse(spyDriver.lookupByEvaluatorId("e" + id).isPresent());
      continue;
    }
    verify(mockEvaluators[id], never()).close();
    assertEquals(Integer.valueOf(id), spyDriver.lookupByEvaluatorId("e" + id).get());
  }
}
 
Example #3
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private CommunicationGroupDriverImpl(
    @Parameter(CommGroupNameClass.class) final Class<? extends Name<String>> groupName,
    final ConfigurationSerializer confSerializer,
    @Parameter(GroupCommRunningTaskHandler.class)
        final BroadcastingEventHandler<RunningTask> groupCommRunningTaskHandler,
    @Parameter(GroupCommFailedTaskHandler.class)
        final BroadcastingEventHandler<FailedTask> groupCommFailedTaskHandler,
    @Parameter(GroupCommFailedEvalHandler.class)
        final BroadcastingEventHandler<FailedEvaluator> groupCommFailedEvaluatorHandler,
        final GroupCommMessageHandler groupCommMessageHandler,
    @Parameter(DriverIdentifier.class) final String driverId,
    @Parameter(CommGroupNumTask.class) final int numberOfTasks,
    final TopologyFactory topologyFactory,
    @Parameter(TopologyClass.class) final Class<? extends Topology> topologyClass) {
  super();
  this.groupName = groupName;
  this.driverId = driverId;
  this.confSerializer = confSerializer;
  this.allInitialTasksRunning = new CountingSemaphore(numberOfTasks, getQualifiedName(), topologiesLock);

  registerHandlers(groupCommRunningTaskHandler, groupCommFailedTaskHandler,
      groupCommFailedEvaluatorHandler, groupCommMessageHandler);
  this.topologyFactory = topologyFactory;
  this.topologyClass = topologyClass;
}
 
Example #4
Source File: CommunicationGroupDriverFactory.java    From reef with Apache License 2.0 6 votes vote down vote up
@Inject
private CommunicationGroupDriverFactory(
    @Parameter(DriverIdentifier.class) final String driverId,
    @Parameter(GroupCommSenderStage.class) final EStage<GroupCommunicationMessage> senderStage,
    @Parameter(GroupCommRunningTaskHandler.class)
        final BroadcastingEventHandler<RunningTask> groupCommRunningTaskHandler,
    @Parameter(GroupCommFailedTaskHandler.class)
        final BroadcastingEventHandler<FailedTask> groupCommFailedTaskHandler,
    @Parameter(GroupCommFailedEvalHandler.class)
        final BroadcastingEventHandler<FailedEvaluator> groupCommFailedEvaluatorHandler,
    final GroupCommMessageHandler groupCommMessageHandler) {
  injector = Tang.Factory.getTang().newInjector();
  injector.bindVolatileParameter(GroupCommSenderStage.class, senderStage);
  injector.bindVolatileParameter(DriverIdentifier.class, driverId);
  injector.bindVolatileParameter(GroupCommRunningTaskHandler.class, groupCommRunningTaskHandler);
  injector.bindVolatileParameter(GroupCommFailedTaskHandler.class, groupCommFailedTaskHandler);
  injector.bindVolatileParameter(GroupCommFailedEvalHandler.class, groupCommFailedEvaluatorHandler);
  injector.bindVolatileInstance(GroupCommMessageHandler.class, groupCommMessageHandler);
}
 
Example #5
Source File: RuntimeMaster.java    From incubator-nemo with Apache License 2.0 5 votes vote down vote up
/**
 * Called when an executor fails due to container failure on this runtime.
 *
 * @param failedEvaluator that failed.
 */
public void onExecutorFailed(final FailedEvaluator failedEvaluator) {
  runtimeMasterThread.execute(() -> {
    metricCountDownLatch.countDown();

    // Note that getFailedContextList() can be empty if the failure occurred
    // prior to launching an Executor on the Evaluator.
    failedEvaluator.getFailedContextList().forEach(failedContext -> {
      final String failedExecutorId = failedContext.getId();
      scheduler.onExecutorRemoved(failedExecutorId);
    });

    containerManager.onContainerFailed(failedEvaluator.getId());
  });
}
 
Example #6
Source File: FailedEvaluatorBridge.java    From reef with Apache License 2.0 5 votes vote down vote up
public FailedEvaluatorBridge(final FailedEvaluator failedEvaluator,
                             final EvaluatorRequestor evaluatorRequestor,
                             final boolean blockedForAdditionalEvaluator,
                             final LoggingScopeFactory loggingScopeFactory,
                             final ActiveContextBridgeFactory activeContextBridgeFactory,
                             final Set<String> definedRuntimes) {
  this.jfailedEvaluator = failedEvaluator;
  this.evaluatorId = failedEvaluator.getId();
  this.evaluatorRequestorBridge =
      new EvaluatorRequestorBridge(evaluatorRequestor, blockedForAdditionalEvaluator, loggingScopeFactory,
              definedRuntimes);
  this.activeContextBridgeFactory = activeContextBridgeFactory;
}
 
Example #7
Source File: MockApplication.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedEvaluator eval) {
  evaluatorMap.remove(eval.getId());
  evaluatorId2ContextId2ContextMap.remove(eval.getId());
  evaluatorIdRunningTaskMap.remove(eval.getId());
  failedEvaluatorMap.put(eval.getId(), eval);
  failedContextSet.addAll(eval.getFailedContextList());
}
 
Example #8
Source File: MockRuntimeDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void restart(final MockDriverRestartContext restartContext, final boolean isTimeout, final long duration) {
  post(this.driverRestartHandlers, restartContext.getDriverRestarted());
  for (final RunningTask runningTask : restartContext.getRunningTasks()) {
    post(this.driverRestartRunningTaskHandlers, runningTask);
  }
  for (final ActiveContext activeContext : restartContext.getIdleActiveContexts()) {
    post(this.driverRestartActiveContextHandlers, activeContext);
  }
  post(this.driverRestartCompletedHandlers, restartContext.getDriverRestartCompleted(isTimeout, duration));
  for (final FailedEvaluator failedEvaluator : restartContext.getFailedEvaluators()) {
    post(this.driverRestartFailedEvaluatorHandlers, failedEvaluator);
  }
}
 
Example #9
Source File: HttpShellJobDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedEvaluator eval) {
  synchronized (HttpShellJobDriver.this) {
    LOG.log(Level.SEVERE, "FailedEvaluator", eval);
    for (final FailedContext failedContext : eval.getFailedContextList()) {
      HttpShellJobDriver.this.contexts.remove(failedContext.getId());
    }
    throw new RuntimeException("Failed Evaluator: ", eval.getEvaluatorException());
  }
}
 
Example #10
Source File: EvaluatorFailureDuringAlarmDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  if (TestUtils.hasCause(failedEvaluator.getEvaluatorException(), ExpectedException.class)) {
    failedEvaluatorReceived.set(true);
    LOG.log(Level.FINEST, "Received an expected exception. All good.");
  } else {
    throw new DriverSideFailure("Received an unexpected exception", failedEvaluator.getEvaluatorException());
  }
}
 
Example #11
Source File: GroupCommDriverImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * @return the groupCommFailedEvaluatorStage
 */
@Override
public EStage<FailedEvaluator> getGroupCommFailedEvaluatorStage() {
  LOG.entering("GroupCommDriverImpl", "getGroupCommFailedEvaluatorStage");
  LOG.exiting("GroupCommDriverImpl", "getGroupCommFailedEvaluatorStage", "Returning GroupCommFailedEvaluatorStage");
  return groupCommFailedEvaluatorStage;
}
 
Example #12
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
private void registerHandlers(
    final BroadcastingEventHandler<RunningTask> runningTaskHandler,
    final BroadcastingEventHandler<FailedTask> failedTaskHandler,
    final BroadcastingEventHandler<FailedEvaluator> failedEvaluatorHandler,
    final GroupCommMessageHandler groupCommMessageHandler) {
  runningTaskHandler.addHandler(new TopologyRunningTaskHandler(this));
  failedTaskHandler.addHandler(new TopologyFailedTaskHandler(this));
  failedEvaluatorHandler.addHandler(new TopologyFailedEvaluatorHandler(this));
  groupCommMessageHandler.addHandler(groupName, new SingleThreadStage<>(new TopologyMessageHandler(this), 100 * 100));
}
 
Example #13
Source File: TopologyFailedEvaluatorHandler.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  final String failedEvaluatorId = failedEvaluator.getId();
  LOG.entering("TopologyFailedEvaluatorHandler", "onNext", failedEvaluatorId);
  if (failedEvaluator.getFailedTask().isPresent()) {
    final String failedTaskId = failedEvaluator.getFailedTask().get().getId();
    LOG.finest("Failed Evaluator contains a failed task: " + failedTaskId);
    communicationGroupDriverImpl.failTask(failedTaskId);
    communicationGroupDriverImpl.removeTask(failedTaskId);
  }
  LOG.exiting("TopologyFailedEvaluatorHandler", "onNext", failedEvaluatorId);
}
 
Example #14
Source File: NemoDriver.java    From nemo with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  // The list size is 0 if the evaluator failed before an executor started. For now, the size is 1 otherwise.
  failedEvaluator.getFailedContextList().forEach(failedContext -> {
    final String failedExecutorId = failedContext.getId();
    runtimeMaster.onExecutorFailed(failedExecutorId);
  });
  throw new RuntimeException(failedEvaluator.getId()
      + " failed. See driver's log for the stack trace in executor.");
}
 
Example #15
Source File: CommunicationGroupDriverImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated in 0.14. Use Tang to obtain an instance of this instead.
 */
@Deprecated
public CommunicationGroupDriverImpl(final Class<? extends Name<String>> groupName,
                                    final ConfigurationSerializer confSerializer,
                                    final EStage<GroupCommunicationMessage> senderStage,
                                    final BroadcastingEventHandler<RunningTask> groupCommRunningTaskHandler,
                                    final BroadcastingEventHandler<FailedTask> groupCommFailedTaskHandler,
                                    final BroadcastingEventHandler<FailedEvaluator> groupCommFailedEvaluatorHandler,
                                    final BroadcastingEventHandler<GroupCommunicationMessage> commGroupMessageHandler,
                                    final String driverId, final int numberOfTasks, final int fanOut) {
  super();
  this.groupName = groupName;
  this.driverId = driverId;
  this.confSerializer = confSerializer;
  this.allInitialTasksRunning = new CountingSemaphore(numberOfTasks, getQualifiedName(), topologiesLock);

  groupCommRunningTaskHandler.addHandler(new TopologyRunningTaskHandler(this));
  groupCommFailedTaskHandler.addHandler(new TopologyFailedTaskHandler(this));
  groupCommFailedEvaluatorHandler.addHandler(new TopologyFailedEvaluatorHandler(this));
  commGroupMessageHandler.addHandler(new TopologyMessageHandler(this));
  final Injector injector = Tang.Factory.getTang().newInjector();
  injector.bindVolatileParameter(CommGroupNameClass.class, groupName);
  injector.bindVolatileParameter(GroupCommSenderStage.class, senderStage);
  injector.bindVolatileParameter(DriverIdentifier.class, driverId);
  injector.bindVolatileParameter(CommGroupNumTask.class, numberOfTasks);
  injector.bindVolatileParameter(TreeTopologyFanOut.class, fanOut);
  try {
    topologyFactory = injector.getInstance(TopologyFactory.class);
  } catch (final InjectionException e) {
    throw new RuntimeException(e);
  }
  this.topologyClass = TreeTopology.class;
}
 
Example #16
Source File: NemoDriver.java    From incubator-nemo with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  runtimeMaster.onExecutorFailed(failedEvaluator);
}
 
Example #17
Source File: MockApplication.java    From reef with Apache License 2.0 4 votes vote down vote up
Collection<FailedEvaluator> getFailedEvaluators() {
  return Collections.unmodifiableCollection(this.failedEvaluatorMap.values());
}
 
Example #18
Source File: Watcher.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  onEvent(EventType.FailedEvaluator,
      WatcherAvroUtil.toString(WatcherAvroUtil.toAvroFailedEvaluator(failedEvaluator)));
}
 
Example #19
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 #20
Source File: AllocateEvaluator.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public FailedEvaluator getFailureEvent() {
  return new MockFailedEvaluator(evaluator.getId());
}
 
Example #21
Source File: CloseEvaluator.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public FailedEvaluator getFailureEvent() {
  // TODO[initialize remaining failed contstructer fields]
  return new MockFailedEvaluator(evaluator.getId());
}
 
Example #22
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 4 votes vote down vote up
public void dispatch(final FailedEvaluator evaluator) {
  this.applicationDispatcher.onNext(FailedEvaluator.class, evaluator);
}
 
Example #23
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 4 votes vote down vote up
public void dispatchRestart(final FailedEvaluator evaluator) {
  this.driverRestartDispatcher.onNext(FailedEvaluator.class, evaluator);
}
 
Example #24
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 #25
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);
}
 
Example #26
Source File: DriverServiceHandlers.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedEvaluator eval) {
  LOG.log(Level.INFO, "JavaBridge: driver restart failed evaluator {0}", eval.getId());
  DriverServiceHandlers.this.driverBridgeService.restartFailedEvalautor(eval);
}
 
Example #27
Source File: DriverServiceHandlers.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedEvaluator eval) {
  LOG.log(Level.INFO, "JavaBridge: Failed Evaluator {0}", eval.getId());
  DriverServiceHandlers.this.driverBridgeService.failedEvaluatorHandler(eval);
}
 
Example #28
Source File: DriverSingletons.java    From reef with Apache License 2.0 4 votes vote down vote up
@Inject
DriverSingletons(
    // Application event handlers
    @Parameter(ContextActiveHandlers.class) final Set<EventHandler<ActiveContext>> contextActiveEventHandlers,
    @Parameter(ContextClosedHandlers.class) final Set<EventHandler<ClosedContext>> contextClosedEventHandlers,
    @Parameter(ContextFailedHandlers.class) final Set<EventHandler<FailedContext>> contextFailedEventHandlers,
    @Parameter(ContextMessageHandlers.class) final Set<EventHandler<ContextMessage>> contextMessageHandlers,
    @Parameter(TaskRunningHandlers.class) final Set<EventHandler<RunningTask>> taskRunningEventHandlers,
    @Parameter(TaskCompletedHandlers.class) final Set<EventHandler<CompletedTask>> taskCompletedEventHandlers,
    @Parameter(TaskSuspendedHandlers.class) final Set<EventHandler<SuspendedTask>> taskSuspendedEventHandlers,
    @Parameter(TaskMessageHandlers.class) final Set<EventHandler<TaskMessage>> taskMessageEventHandlers,
    @Parameter(TaskFailedHandlers.class) final Set<EventHandler<FailedTask>> taskExceptionEventHandlers,
    @Parameter(EvaluatorAllocatedHandlers.class)
    final Set<EventHandler<AllocatedEvaluator>> evaluatorAllocatedEventHandlers,
    @Parameter(EvaluatorFailedHandlers.class) final Set<EventHandler<FailedEvaluator>> evaluatorFailedHandlers,
    @Parameter(EvaluatorCompletedHandlers.class)
    final Set<EventHandler<CompletedEvaluator>> evaluatorCompletedHandlers,

    // Service event handlers
    @Parameter(ServiceContextActiveHandlers.class)
    final Set<EventHandler<ActiveContext>> serviceContextActiveEventHandlers,
    @Parameter(ServiceContextClosedHandlers.class)
    final Set<EventHandler<ClosedContext>> serviceContextClosedEventHandlers,
    @Parameter(ServiceContextFailedHandlers.class)
    final Set<EventHandler<FailedContext>> serviceContextFailedEventHandlers,
    @Parameter(ServiceContextMessageHandlers.class)
    final Set<EventHandler<ContextMessage>> serviceContextMessageHandlers,
    @Parameter(ServiceTaskRunningHandlers.class)
    final Set<EventHandler<RunningTask>> serviceTaskRunningEventHandlers,
    @Parameter(ServiceTaskCompletedHandlers.class)
    final Set<EventHandler<CompletedTask>> serviceTaskCompletedEventHandlers,
    @Parameter(ServiceTaskSuspendedHandlers.class)
    final Set<EventHandler<SuspendedTask>> serviceTaskSuspendedEventHandlers,
    @Parameter(ServiceTaskMessageHandlers.class) final Set<EventHandler<TaskMessage>> serviceTaskMessageEventHandlers,
    @Parameter(ServiceTaskFailedHandlers.class) final Set<EventHandler<FailedTask>> serviceTaskExceptionEventHandlers,
    @Parameter(ServiceEvaluatorAllocatedHandlers.class)
    final Set<EventHandler<AllocatedEvaluator>> serviceEvaluatorAllocatedEventHandlers,
    @Parameter(ServiceEvaluatorFailedHandlers.class)
    final Set<EventHandler<FailedEvaluator>> serviceEvaluatorFailedHandlers,
    @Parameter(ServiceEvaluatorCompletedHandlers.class)
    final Set<EventHandler<CompletedEvaluator>> serviceEvaluatorCompletedHandlers,

    // Client event handler
    @Parameter(DriverRuntimeConfigurationOptions.JobControlHandler.class)
    final EventHandler<ClientRuntimeProtocol.JobControlProto> jobControlHandler,

    // Resource*Handlers - Should be invoked once
    // The YarnResourceLaunchHandler creates and uploads
    // the global jar file. If these handlers are
    // instantiated for each container allocation
    // we get container failures dure to modifications
    // to already submitted global jar file
    final ResourceLaunchHandler resourceLaunchHandler,
    final ResourceReleaseHandler resourceReleaseHandler,

    final EvaluatorIdlenessThreadPool evaluatorIdlenessThreadPool) {
}
 
Example #29
Source File: DefaultEvaluatorFailureHandler.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedEvaluator failedEvaluator) {
  throw new RuntimeException(
      "No handler bound for FailedEvaluator: " + failedEvaluator,
      failedEvaluator.getEvaluatorException());
}
 
Example #30
Source File: EvaluatorManager.java    From reef with Apache License 2.0 4 votes vote down vote up
/**
 * EvaluatorException will trigger is FailedEvaluator and state transition to FAILED.
 *
 * @param exception on the EvaluatorRuntime
 */
public void onEvaluatorException(final EvaluatorException exception) {
  synchronized (this.evaluatorDescriptor) {

    if (this.stateManager.isCompleted()) {
      LOG.log(Level.FINE,
          "Ignoring an exception received for Evaluator {0} which is already in state {1}.",
          new Object[] {this.getId(), this.stateManager});
      return;
    }

    LOG.log(Level.WARNING, "Failed evaluator: " + getId(), exception);

    try {

      final List<FailedContext> failedContextList = this.contextRepresenters.getFailedContextsForEvaluatorFailure();

      final Optional<FailedTask> failedTaskOptional;
      if (this.task.isPresent()) {

        final String taskId = this.task.get().getId();
        final Optional<ActiveContext> evaluatorContext = Optional.empty();
        final Optional<byte[]> bytes = Optional.empty();
        final Optional<Throwable> taskException = Optional.<Throwable>of(new Exception("Evaluator crash"));
        final String message = "Evaluator crash";
        final Optional<String> description = Optional.empty();
        final FailedTask failedTask =
            new FailedTask(taskId, message, description, taskException, bytes, evaluatorContext);

        failedTaskOptional = Optional.of(failedTask);

      } else {
        failedTaskOptional = Optional.empty();
      }

      final FailedEvaluator failedEvaluator = new FailedEvaluatorImpl(
          exception, failedContextList, failedTaskOptional, this.evaluatorId);

      if (driverRestartManager.getEvaluatorRestartState(evaluatorId).isFailedOrExpired()) {
        this.messageDispatcher.onDriverRestartEvaluatorFailed(failedEvaluator);
      } else {
        this.messageDispatcher.onEvaluatorFailed(failedEvaluator);
      }
    } catch (final Exception e) {
      LOG.log(Level.SEVERE, "Exception while handling FailedEvaluator", e);
    } finally {
      this.stateManager.setFailed();
      this.close();
    }
  }
}