org.apache.reef.driver.context.FailedContext Java Examples

The following examples show how to use org.apache.reef.driver.context.FailedContext. 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: WatcherAvroUtil.java    From reef with Apache License 2.0 6 votes vote down vote up
public static AvroFailedEvaluator toAvroFailedEvaluator(final FailedEvaluator failedEvaluator) {
  final AvroFailedTask avroFailedTask;
  if (failedEvaluator.getFailedTask().isPresent()) {
    avroFailedTask = toAvroFailedTask(failedEvaluator.getFailedTask().get());
  } else {
    avroFailedTask = null;
  }

  final List<AvroFailedContext> avroFailedContextList = new ArrayList<>();
  for (final FailedContext failedContext : failedEvaluator.getFailedContextList()) {
    avroFailedContextList.add(toAvroFailedContext(failedContext));
  }

  return AvroFailedEvaluator.newBuilder()
      .setId(failedEvaluator.getId())
      .setEvaluatorException(convertThrowableToString(failedEvaluator.getEvaluatorException()))
      .setFailedContextList(avroFailedContextList)
      .setFailedTask(avroFailedTask)
      .build();
}
 
Example #2
Source File: JobDriver.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public void onNext(final FailedContext context) {
  LOG.log(Level.SEVERE, "FailedContext", context);
  try (LoggingScope ls = loggingScopeFactory.evaluatorFailed(context.getId())) {
    if (JobDriver.this.handlerManager.getFailedContextHandler() != 0) {
      final FailedContextBridge failedContextBridge = new FailedContextBridge(context, activeContextBridgeFactory);
      // if CLR implements the failed context handler, handle it in CLR
      LOG.log(Level.INFO, "Handling the event of failed context in CLR bridge.");
      NativeInterop.clrSystemFailedContextHandlerOnNext(JobDriver.this.handlerManager.getFailedContextHandler(),
          failedContextBridge);
    }
    JobDriver.this.contexts.remove(context.getId());
    final Optional<byte[]> err = context.getData();
    if (err.isPresent()) {
      JobDriver.this.jobMessageObserver.sendMessageToClient(err.get());
    }
  }
}
 
Example #3
Source File: JobDriver.java    From reef with Apache License 2.0 6 votes vote down vote up
private void handleFailedEvaluator(final FailedEvaluator eval, final boolean isRestartFailed) {
  try (LoggingScope ls = loggingScopeFactory.evaluatorFailed(eval.getId())) {
    LOG.log(Level.SEVERE, "FailedEvaluator", eval);
    for (final FailedContext failedContext : eval.getFailedContextList()) {
      final String failedContextId = failedContext.getId();
      LOG.log(Level.INFO, "removing context " + failedContextId + " from job driver contexts.");
      JobDriver.this.contexts.remove(failedContextId);
    }
    final String message = "Evaluator " + eval.getId() + " failed with message: "
        + eval.getEvaluatorException().getMessage();
    JobDriver.this.jobMessageObserver.sendMessageToClient(message.getBytes(StandardCharsets.UTF_8));

    if (isRestartFailed) {
      evaluatorFailedHandlerWaitForCLRBridgeSetup(
          JobDriver.this.handlerManager.getDriverRestartFailedEvaluatorHandler(), eval, isRestartFailed);
    } else {
      evaluatorFailedHandlerWaitForCLRBridgeSetup(JobDriver.this.handlerManager.getFailedEvaluatorHandler(),
          eval, isRestartFailed);
    }
  }
}
 
Example #4
Source File: GRPCDriverService.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public void failedContextHandler(final FailedContext context) {
  synchronized (this) {
    if (this.clientStub != null) {
      final ExceptionInfo error;
      if (context.getReason().isPresent()) {
        final Throwable reason = context.getReason().get();
        error = GRPCUtils.createExceptionInfo(this.exceptionCodec, reason);
      } else if (context.getData().isPresent()) {
        error = ExceptionInfo.newBuilder()
            .setName(context.toString())
            .setMessage(context.getDescription().orElse(
                context.getMessage() != null ? context.getMessage() : ""))
            .setData(ByteString.copyFrom(context.getData().get()))
            .build();
      } else {
        error = GRPCUtils.createExceptionInfo(this.exceptionCodec, context.asError());
      }
      this.activeContextMap.remove(context.getId());
      this.clientStub.failedContextHandler(GRPCUtils.toContextInfo(context, error));
    } else {
      LOG.log(Level.WARNING, "client shutdown has already completed");
    }
  }
}
 
Example #5
Source File: MockRuntimeDriver.java    From reef with Apache License 2.0 6 votes vote down vote up
@Override
public void fail(final AllocatedEvaluator evaluator) {
  if (this.clock.get().isClosed()) {
    throw new IllegalStateException("clock is closed");
  }
  if (this.allocatedEvaluatorMap.remove(evaluator.getId()) == null) {
    throw new IllegalStateException("unknown evaluator " + evaluator);
  }
  FailedTask failedTask = null;
  if (this.runningTasks.containsKey(evaluator.getId())) {
    final RunningTask task = this.runningTasks.remove(evaluator.getId());
    failedTask = new FailedTask(
        task.getId(),
        "mock",
        Optional.<String>empty(),
        Optional.<Throwable>empty(),
        Optional.<byte[]>empty(),
        Optional.<ActiveContext>of(task.getActiveContext()));
  }
  final List<FailedContext> failedContexts = new ArrayList<>();
  for (final MockActiveContext context : this.allocatedContextsMap.get(evaluator.getId())) {
    failedContexts.add(new MockFailedContext(context));
  }
  post(this.failedEvaluatorHandlers, new MockFailedEvaluator(
      evaluator.getId(), failedContexts, Optional.ofNullable(failedTask)));
}
 
Example #6
Source File: EvaluatorContext.java    From reef with Apache License 2.0 6 votes vote down vote up
/**
 * @return a FailedContext for the case of an EvaluatorFailure.
 */
public synchronized FailedContext getFailedContextForEvaluatorFailure() {

  final String id = this.getId();
  final Optional<String> description = Optional.empty();
  final Optional<byte[]> data = Optional.empty();
  final Optional<Throwable> cause = Optional.empty();
  final String message = "Evaluator Failure";

  final Optional<ActiveContext> parentContext = getParentId().isPresent() ?
      Optional.<ActiveContext>of(this.contextRepresenters.getContext(getParentId().get())) :
      Optional.<ActiveContext>empty();

  final String evaluatorID = getEvaluatorId();

  return new FailedContextImpl(
      id, message, description, cause, data, parentContext, this.evaluatorDescriptor, evaluatorID);
}
 
Example #7
Source File: DefaultContextFailureHandler.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedContext failedContext) {
  if (failedContext.getReason().isPresent()) {
    throw new RuntimeException(
        "No handler bound for FailedContext:" + failedContext, failedContext.getReason().get());
  } else {
    throw new RuntimeException("No handler bound for FailedContext:" + failedContext);
  }
}
 
Example #8
Source File: GRPCDriverClientService.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void driverRestartFailedEvaluatorHandler(
    final EvaluatorInfo request,
    final StreamObserver<Void> responseObserver) {
  try (ObserverCleanup cleanup = ObserverCleanup.of(responseObserver)) {
    this.clientDriverDispatcher.get().dispatchRestart(new FailedEvaluatorBridge(
        request.getEvaluatorId(),
        new EvaluatorException(request.getFailure() != null ?
            request.getFailure().getMessage() : "restart failed"),
        Lists.<FailedContext>newArrayList(),
        Optional.<FailedTask>empty()));
  }
}
 
Example #9
Source File: FailedEvaluatorBridge.java    From reef with Apache License 2.0 5 votes vote down vote up
public FailedEvaluatorBridge(
    final String id,
    final EvaluatorException evaluatorException,
    final List<FailedContext> failedContextList,
    final Optional<FailedTask> failedTask) {
  this.id = id;
  this.evaluatorException = evaluatorException;
  this.failedContextList = failedContextList;
  this.failedTask = failedTask;
}
 
Example #10
Source File: HttpShellJobDriver.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedContext context) {
  LOG.log(Level.SEVERE, "FailedContext", context);
  synchronized (HttpShellJobDriver.this) {
    HttpShellJobDriver.this.contexts.remove(context.getId());
  }
  throw new RuntimeException("Failed context: ", context.asError());
}
 
Example #11
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 #12
Source File: MockFailedEvaluator.java    From reef with Apache License 2.0 5 votes vote down vote up
public MockFailedEvaluator(
    final String evaluatorID,
    final List<FailedContext> failedContextList,
    final Optional<FailedTask> failedTask) {
  this.evaluatorID = evaluatorID;
  this.failedContextList = failedContextList;
  this.failedTask = failedTask;
}
 
Example #13
Source File: ContextRepresenters.java    From reef with Apache License 2.0 5 votes vote down vote up
/**
 * Create the failed contexts for a FailedEvaluator event.
 *
 * @return
 */
public synchronized List<FailedContext> getFailedContextsForEvaluatorFailure() {
  final List<FailedContext> failedContextList = new ArrayList<>();
  final List<EvaluatorContext> activeContexts = new ArrayList<>(this.contextStack);
  Collections.reverse(activeContexts);

  for (final EvaluatorContext context : activeContexts) {
    failedContextList.add(context.getFailedContextForEvaluatorFailure());
  }
  return failedContextList;
}
 
Example #14
Source File: EvaluatorContext.java    From reef with Apache License 2.0 5 votes vote down vote up
public synchronized FailedContext getFailedContext(
    final ContextStatusPOJO contextStatus) {

  assert ContextState.FAIL == contextStatus.getContextState();

  final String id = this.getId();
  final Optional<String> description = Optional.empty();

  final Optional<byte[]> data = contextStatus.hasError() ?
      Optional.of(contextStatus.getError()) :
      Optional.<byte[]>empty();

  final Optional<Throwable> cause = data.isPresent() ?
      this.exceptionCodec.fromBytes(data) :
      Optional.<Throwable>empty();

  final String message = cause.isPresent() ? cause.get().getMessage() : "No message given";

  final Optional<ActiveContext> parentContext = getParentId().isPresent() ?
      Optional.<ActiveContext>of(this.contextRepresenters.getContext(getParentId().get())) :
      Optional.<ActiveContext>empty();

  final String evaluatorID = getEvaluatorId();

  return new FailedContextImpl(
      id, message, description, cause, data, parentContext, this.evaluatorDescriptor, evaluatorID);
}
 
Example #15
Source File: FailedEvaluatorImpl.java    From reef with Apache License 2.0 5 votes vote down vote up
FailedEvaluatorImpl(final EvaluatorException ex,
                    final List<FailedContext> ctx,
                    final Optional<FailedTask> task,
                    final String id) {
  this.ex = ex;
  this.ctx = ctx;
  this.task = task;
  this.id = id;
}
 
Example #16
Source File: MockApplication.java    From reef with Apache License 2.0 5 votes vote down vote up
@Override
public void onNext(final FailedContext value) {
  if (evaluatorId2ContextId2ContextMap.containsKey(value.getEvaluatorId()) &&
      evaluatorId2ContextId2ContextMap.get(value.getEvaluatorId()).containsKey(value.getId())) {
    evaluatorId2ContextId2ContextMap.get(value.getEvaluatorId()).remove(value.getEvaluatorId());
  } else {
    // must have failed before it succeeded
  }
  failedContextSet.add(value);
}
 
Example #17
Source File: WatcherAvroUtil.java    From reef with Apache License 2.0 5 votes vote down vote up
public static AvroFailedContext toAvroFailedContext(final FailedContext failedContext) {
  return AvroFailedContext.newBuilder()
      .setBase(toAvroContextBase(failedContext))
      .setParentContext(unwrapOptionalActiveContext(failedContext.getParentContext()))
      .setFailure(toAvroFailure(failedContext))
      .build();
}
 
Example #18
Source File: FailedContextBridge.java    From reef with Apache License 2.0 5 votes vote down vote up
public FailedContextBridge(final FailedContext failedContext, final ActiveContextBridgeFactory factory) {
  jfailedContext = failedContext;
  evaluatorDescriptor = failedContext.getEvaluatorDescriptor();
  evaluatorId = failedContext.getEvaluatorId();
  contextId = failedContext.getId();
  if (failedContext.getParentContext().isPresent()) {
    final ActiveContext parent = failedContext.getParentContext().get();
    this.parentContextId = parent.getId();
    this.parentContext = factory.getActiveContextBridge(parent);
  } else {
    this.parentContextId = null;
    this.parentContext = null;
  }

}
 
Example #19
Source File: DriverServiceHandlers.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedContext context) {
  LOG.log(Level.INFO, "JavaBridge: Context Failed {0}", context.getId());
  DriverServiceHandlers.this.driverBridgeService.failedContextHandler(context);
}
 
Example #20
Source File: MockFailedEvaluator.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public List<FailedContext> getFailedContextList() {
  return this.failedContextList;
}
 
Example #21
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 #22
Source File: MockApplication.java    From reef with Apache License 2.0 4 votes vote down vote up
Collection<FailedContext> getFailedContext() {
  return Collections.unmodifiableCollection(this.failedContextSet);
}
 
Example #23
Source File: CreateContext.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public FailedContext getFailureEvent() {
  return new MockFailedContext(this.context);
}
 
Example #24
Source File: CloseContext.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public FailedContext getFailureEvent() {
  return new MockFailedContext(this.context);
}
 
Example #25
Source File: FailedEvaluatorBridge.java    From reef with Apache License 2.0 4 votes vote down vote up
@Override
public List<FailedContext> getFailedContextList() {
  return this.failedContextList;
}
 
Example #26
Source File: DriverClientDispatcher.java    From reef with Apache License 2.0 4 votes vote down vote up
public void dispatch(final FailedContext context) {
  this.applicationDispatcher.onNext(FailedContext.class, context);
}
 
Example #27
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 #28
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 #29
Source File: NemoDriver.java    From incubator-nemo with Apache License 2.0 4 votes vote down vote up
@Override
public void onNext(final FailedContext failedContext) {
  throw new RuntimeException(failedContext.getId() + " failed. See driver's log for the stack trace in executor.",
    failedContext.asError());
}
 
Example #30
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) {
}