@Override public String toString() { return String.format( "REEFErrorHandler: { remoteManager:{%s}, launchID:%s, errorHandlerRID:%s }", this.remoteManager.get(), this.launchID, this.errorHandlerRID); } }
final String key = fut.getNode().getFullName(); try { final InjectionFuture<?> ret = new InjectionFuture<>( this, javaNamespace.classForName(fut.getNode().getFullName())); pendingFutures.add(ret);
private synchronized EventHandler<Void> getClientCloseDispatcher() { if (clientCloseDispatcher != null) { return clientCloseDispatcher; } else { synchronized (this) { if (clientCloseDispatcher == null) { clientCloseDispatcher = new BroadCastEventHandler<>(clientCloseHandlers.get()); } } return clientCloseDispatcher; } }
@Override public IdleMessage getIdleStatus() { if (this.evaluators.get().allEvaluatorsAreClosed()) { return IDLE_MESSAGE; } else { return NOT_IDLE_MESSAGE; } }
@Override public synchronized void onNext(final IdleClock idleClock) { this.driverIdleManager.get().onPotentiallyIdle(IDLE_MESSAGE); } }
@Override protected void initChannel(final SocketChannel ch) { final ContextManager contextManager = new ContextManager(pipeManagerWorker.get(), blockManagerWorker.get(), byteTransfer.get(), byteTransport.get().getChannelGroup(), localExecutorId, ch); ch.pipeline() // inbound .addLast(new FrameDecoder(contextManager)) // outbound .addLast(controlFrameEncoder) .addLast(dataFrameEncoder) // inbound .addLast(contextManager); } }
private EventHandler<byte[]> getClientCloseWithMessageDispatcher() { if (clientCloseWithMessageDispatcher != null) { return clientCloseWithMessageDispatcher; } else { synchronized (this) { if (clientCloseWithMessageDispatcher == null) { clientCloseWithMessageDispatcher = new BroadCastEventHandler<>(clientCloseWithMessageHandlers.get()); } } return clientCloseWithMessageDispatcher; } }
@Override protected void initChannel(final SocketChannel ch) { final ContextManager contextManager = new ContextManager(pipeManagerWorker.get(), blockManagerWorker.get(), byteTransfer.get(), byteTransport.get().getChannelGroup(), localExecutorId, ch); ch.pipeline() // inbound .addLast(new FrameDecoder(contextManager)) // outbound .addLast(controlFrameEncoder) .addLast(dataFrameEncoder) // inbound .addLast(contextManager); } }
private EventHandler<byte[]> getClientMessageDispatcher() { if (clientMessageDispatcher != null) { return clientMessageDispatcher; } else { synchronized (this) { if (clientMessageDispatcher == null) { clientMessageDispatcher = new BroadCastEventHandler<>(clientMessageHandlers.get()); } } return clientMessageDispatcher; } }
/** * RM Callback: Report application progress to RM. * Progress is a floating point number between 0 and 1. * @return a floating point number between 0 and 1. */ @Override public float getProgress() { try { return Math.max(Math.min(1, progressProvider.get().getProgress()), 0); } catch (final Exception e) { // An Exception must be caught and logged here because YARN swallows the Exception and fails the job. LOG.log(Level.WARNING, "Cannot get the application progress. Will return 0.", e); return 0; } }
@Override public void onNext(final ResourceReleaseEvent resourceReleaseEvent) { final String containerId = resourceReleaseEvent.getIdentifier(); LOG.log(Level.FINEST, "Releasing container {0}", containerId); this.yarnContainerManager.get().release(containerId); } }
private <U> U getInstance(final Node n) throws InjectionException { assertNotConcurrent(); @SuppressWarnings("unchecked") final InjectionPlan<U> plan = (InjectionPlan<U>) getInjectionPlan(n); final U u = (U) injectFromPlan(plan); while (!pendingFutures.isEmpty()) { final Iterator<InjectionFuture<?>> i = pendingFutures.iterator(); final InjectionFuture<?> f = i.next(); pendingFutures.remove(f); f.get(); } return u; }
/** * Instantiate a new Context representer with the given id and parent id. * * @param contextId * @param parentID * @return a new Context representer with the given id and parent id. */ public EvaluatorContext newContext(final String contextId, final Optional<String> parentID) { synchronized (this.priorIds) { if (this.priorIds.contains(contextId)) { throw new IllegalStateException("Creating second EvaluatorContext instance for id " + contextId); } this.priorIds.add(contextId); } return new EvaluatorContext(contextId, this.evaluatorId, this.evaluatorDescriptor, parentID, this.configurationSerializer, this.contextControlHandler, this.messageDispatcher, this.exceptionCodec, this.contextRepresenters.get()); } }
@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 ContextStatus that must be delivered to the driver. */ public synchronized void sendContextStatus( final ReefServiceProtos.ContextStatusProto contextStatusProto) { // TODO[JIRA REEF-833]: Write a test that verifies correct order of heartbeats. 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); }
@SuppressWarnings("checkstyle:illegalcatch") public void close() { LOG.entering(CLASS_NAME, "close"); try { this.remoteManager.get().close(); } catch (final Throwable ex) { LOG.log(Level.SEVERE, "Unable to close the remote manager", ex); } LOG.exiting(CLASS_NAME, "close"); }
/** * Calls the configured Task close handler and catches exceptions it may throw. */ @SuppressWarnings("checkstyle:illegalcatch") private void closeTask(final byte[] message) throws TaskCloseHandlerFailure { LOG.log(Level.FINEST, "Invoking close handler."); try { this.fCloseHandler.get().onNext(new CloseEventImpl(message)); } catch (final Throwable throwable) { throw new TaskCloseHandlerFailure(throwable); } }
/** * 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); } } } }