private synchronized EventHandler<Void> getClientCloseDispatcher() { if (clientCloseDispatcher != null) { return clientCloseDispatcher; } else { synchronized (this) { if (clientCloseDispatcher == null) clientCloseDispatcher = new BroadCastEventHandler<>(clientCloseHandlers.get()); } return clientCloseDispatcher; } }
private EventHandler<byte[]> getClientMessageDispatcher() { if (clientMessageDispatcher != null) { return clientMessageDispatcher; } else { synchronized (this) { if (clientMessageDispatcher == null) clientMessageDispatcher = new BroadCastEventHandler<>(clientMessageHandlers.get()); } return clientMessageDispatcher; } }
@Override public synchronized void onNext(final IdleClock idleClock) { this.driverIdleManager.get().onPotentiallyIdle(IDLE_MESSAGE); } }
@Override public IdleMessage getIdleStatus() { if (this.evaluators.get().allEvaluatorsAreClosed()) { return IDLE_MESSAGE; } else { return NOT_IDLE_MESSAGE; } }
public void close() { try { this.remoteManager.get().close(); } catch (final Throwable ex) { LOG.log(Level.SEVERE, "Unable to close the remote manager", ex); } }
private EventHandler<byte[]> getClientCloseWithMessageDispatcher() { if (clientCloseWithMessageDispatcher != null) { return clientCloseWithMessageDispatcher; } else { synchronized (this) { if (clientCloseWithMessageDispatcher == null) clientCloseWithMessageDispatcher = new BroadCastEventHandler<>(clientCloseWithMessageHandlers.get()); } return clientCloseWithMessageDispatcher; } }
@Override public void onNext(final DriverRuntimeProtocol.ResourceReleaseProto resourceReleaseProto) { final String containerId = resourceReleaseProto.getIdentifier(); LOG.log(Level.FINEST, "Releasing container {0}", containerId); this.yarnContainerManager.get().release(containerId); } }
@Override public void onNext(final Alarm alarm) { synchronized (HeartBeatManager.this) { if (evaluatorRuntime.get().isRunning()) { HeartBeatManager.this.sendHeartbeat(); HeartBeatManager.this.clock.scheduleAlarm(HeartBeatManager.this.heartbeatPeriod, this); } else { LOG.log(Level.FINEST, "Not triggering a heartbeat, because state is: {0}", evaluatorRuntime.get().getState()); } } } }
/** * Called with a specific TaskStatus that must be delivered to the driver. */ public synchronized void sendContextStatus( final ReefServiceProtos.ContextStatusProto contextStatusProto) { // TODO: Write a test that checks for the order. final Collection<ReefServiceProtos.ContextStatusProto> contextStatusList = new ArrayList<>(); contextStatusList.add(contextStatusProto); contextStatusList.addAll(this.contextManager.get().getContextStatusCollection()); final EvaluatorRuntimeProtocol.EvaluatorHeartbeatProto heartbeatProto = this.getEvaluatorHeartbeatProto( this.evaluatorRuntime.get().getEvaluatorStatus(), contextStatusList, Optional.<ReefServiceProtos.TaskStatusProto>empty()); this.sendHeartBeat(heartbeatProto); }
/** * Start the context manager. This initiates the root context. * * @throws ContextClientCodeException if the root context can't be instantiated. */ public void start() throws ContextClientCodeException { synchronized (this.contextStack) { LOG.log(Level.FINEST, "Instantiating root context."); this.contextStack.push(this.launchContext.get().getRootContext()); if (this.launchContext.get().getInitialTaskConfiguration().isPresent()) { LOG.log(Level.FINEST, "Launching the initial Task"); try { this.contextStack.peek().startTask(this.launchContext.get().getInitialTaskConfiguration().get()); } catch (final TaskClientCodeException e) { this.handleTaskException(e); } } } }
/** * Calls the configured Task close handler and catches exceptions it may throw. */ private void closeTask(final byte[] message) throws TaskCloseHandlerFailure { LOG.log(Level.FINEST, "Invoking close handler."); try { this.f_closeHandler.get().onNext(new CloseEventImpl(message)); } catch (final Throwable throwable) { throw new TaskCloseHandlerFailure(throwable); } }
/** * Called with a specific TaskStatus that must be delivered to the driver. */ public synchronized void sendTaskStatus(final ReefServiceProtos.TaskStatusProto taskStatusProto) { this.sendHeartBeat(this.getEvaluatorHeartbeatProto( this.evaluatorRuntime.get().getEvaluatorStatus(), this.contextManager.get().getContextStatusCollection(), Optional.of(taskStatusProto))); }
/** * Calls the configured Task message handler and catches exceptions it may throw. */ private void deliverMessageToTask(final byte[] message) throws TaskMessageHandlerFailure { try { this.f_messageHandler.get().onNext(new DriverMessageImpl(message)); } catch (final Throwable throwable) { throw new TaskMessageHandlerFailure(throwable); } }
/** * Calls the configured Task suspend handler and catches exceptions it may throw. */ private void suspendTask(final byte[] message) throws TaskSuspendHandlerFailure { try { this.f_suspendHandler.get().onNext(new SuspendEventImpl(message)); } catch (final Throwable throwable) { throw new TaskSuspendHandlerFailure(throwable); } } }
@Override public void onNext(final RemoteMessage<ReefServiceProtos.RuntimeErrorProto> error) { LOG.log(Level.WARNING, "{0} Runtime Error: {1}", new Object[]{ error.getIdentifier(), error.getMessage().getMessage()}); this.runningJobs.get().onRuntimeErrorMessage(error); } }
private synchronized void onRMRunning(final DriverRuntimeProtocol.RuntimeStatusProto runtimeStatusProto) { assert (runtimeStatusProto.getState() == ReefServiceProtos.State.RUNNING); if (this.isIdle()) { this.driverIdleManager.get().onPotentiallyIdle(IDLE_MESSAGE); } }
@Override public void onProcessExit(final String processId, final int exitCode) { // Note that the order here matters: We need to first inform the Driver's event handlers about the process exit // and then release the resources. Otherwise, the Driver might be shutdown because of an idle condition before the // message about the evaluator exit could have been sent and processed. switch (exitCode) { case 0: this.onCleanExit(processId); break; default: this.onUncleanExit(processId, exitCode); } this.resourceManager.get().onEvaluatorExit(processId); }
@Override public synchronized void onRuntimeErrorMessage(RemoteMessage<ReefServiceProtos.RuntimeErrorProto> runtimeFailure) { try { this.remove(runtimeFailure.getMessage().getIdentifier()); } finally { this.failedRuntimeEventHandler.get().onNext(new FailedRuntime(runtimeFailure.getMessage())); } }