/** * Sends stop RPC call. */ public void stop() { final SimpleSlot slot = assignedResource; if (slot != null) { final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway(); Future<Acknowledge> stopResultFuture = FutureUtils.retry( new Callable<Future<Acknowledge>>() { @Override public Future<Acknowledge> call() throws Exception { return taskManagerGateway.stopTask(attemptId, timeout); } }, NUM_STOP_CALL_TRIES, executor); stopResultFuture.exceptionally(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { LOG.info("Stopping task was not successful.", failure); return null; } }); } }
@Override public void requestHeartbeat(final ResourceID requestOrigin, I heartbeatPayload) { if (!stopped) { log.debug("Received heartbeat request from {}.", requestOrigin); final HeartbeatTarget<O> heartbeatTarget = reportHeartbeat(requestOrigin); if (heartbeatTarget != null) { if (heartbeatPayload != null) { heartbeatListener.reportPayload(requestOrigin, heartbeatPayload); } Future<O> futurePayload = heartbeatListener.retrievePayload(); if (futurePayload != null) { Future<Void> sendHeartbeatFuture = futurePayload.thenAcceptAsync(new AcceptFunction<O>() { @Override public void accept(O retrievedPayload) { heartbeatTarget.receiveHeartbeat(getOwnResourceID(), retrievedPayload); } }, executor); sendHeartbeatFuture.exceptionally(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { log.warn("Could not send heartbeat to target with id {}.", requestOrigin, failure); return null; } }); } else { heartbeatTarget.receiveHeartbeat(ownResourceID, null); } } } }
@Override public void run() { if (!stopped) { log.debug("Trigger heartbeat request."); for (HeartbeatMonitor<O> heartbeatMonitor : getHeartbeatTargets()) { Future<O> futurePayload = getHeartbeatListener().retrievePayload(); final HeartbeatTarget<O> heartbeatTarget = heartbeatMonitor.getHeartbeatTarget(); if (futurePayload != null) { Future<Void> requestHeartbeatFuture = futurePayload.thenAcceptAsync(new AcceptFunction<O>() { @Override public void accept(O payload) { heartbeatTarget.requestHeartbeat(getOwnResourceID(), payload); } }, getExecutor()); requestHeartbeatFuture.exceptionally(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { log.warn("Could not request the heartbeat from target {}.", heartbeatTarget, failure); return null; } }); } else { heartbeatTarget.requestHeartbeat(getOwnResourceID(), null); } } } }
acceptedSlotsAcceptFuture.exceptionally(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable throwable) {
logPathFuture.exceptionally(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) {