@Override public void notifyPartitionConsumable(JobID jobId, ResultPartitionID partitionId, final TaskActions taskActions) { Future<Acknowledge> acknowledgeFuture = jobMasterGateway.scheduleOrUpdateConsumers( jobMasterLeaderId, partitionId, timeout); acknowledgeFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable value) { LOG.error("Could not schedule or update consumers at the JobManager.", value); taskActions.failExternally(new RuntimeException("Could not notify JobManager to schedule or update consumers.", value)); return null; } }, executor); } }
/** * This method sends a CancelTask message to the instance of the assigned slot. * * The sending is tried up to NUM_CANCEL_CALL_TRIES times. */ private void sendCancelRpcCall() { final SimpleSlot slot = assignedResource; if (slot != null) { final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway(); Future<Acknowledge> cancelResultFuture = FutureUtils.retry( new Callable<Future<Acknowledge>>() { @Override public Future<Acknowledge> call() throws Exception { return taskManagerGateway.cancelTask(attemptId, timeout); } }, NUM_CANCEL_CALL_TRIES, executor); cancelResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { fail(new Exception("Task could not be canceled.", failure)); return null; } }, executor); } }
private void updateTaskExecutionState( final UUID jobMasterLeaderId, final JobMasterGateway jobMasterGateway, final TaskExecutionState taskExecutionState) { final ExecutionAttemptID executionAttemptID = taskExecutionState.getID(); Future<Acknowledge> futureAcknowledge = jobMasterGateway.updateTaskExecutionState( jobMasterLeaderId, taskExecutionState); futureAcknowledge.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable value) { failTask(executionAttemptID, value); return null; } }, getMainThreadExecutor()); }
/** * Update the partition infos on the assigned resource. * * @param partitionInfos for the remote task */ private void sendUpdatePartitionInfoRpcCall( final Iterable<PartitionInfo> partitionInfos) { final SimpleSlot slot = assignedResource; if (slot != null) { final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway(); final TaskManagerLocation taskManagerLocation = slot.getTaskManagerLocation(); Future<Acknowledge> updatePartitionsResultFuture = taskManagerGateway.updatePartitions(attemptId, partitionInfos, timeout); updatePartitionsResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { fail(new IllegalStateException("Update task on TaskManager " + taskManagerLocation + " failed due to:", failure)); return null; } }, executor); } }
private void requestSlotFromResourceManager( final AllocationID allocationID, final FlinkCompletableFuture<SimpleSlot> future, final ResourceProfile resources) { LOG.info("Requesting slot with profile {} from resource manager (request = {}).", resources, allocationID); pendingRequests.put(allocationID, new PendingRequest(allocationID, future, resources)); Future<Acknowledge> rmResponse = resourceManagerGateway.requestSlot( jobManagerLeaderId, resourceManagerLeaderId, new SlotRequest(jobId, allocationID, resources, jobManagerAddress), resourceManagerRequestsTimeout); Future<Void> slotRequestProcessingFuture = rmResponse.thenAcceptAsync(new AcceptFunction<Acknowledge>() { @Override public void accept(Acknowledge value) { slotRequestToResourceManagerSuccess(allocationID); } }, getMainThreadExecutor()); // on failure, fail the request future slotRequestProcessingFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { slotRequestToResourceManagerFailed(allocationID, failure); return null; } }, getMainThreadExecutor()); }
/** * Registers an info message listener * * @param address address of infoMessage listener to register to this resource manager */ @RpcMethod public void registerInfoMessageListener(final String address) { if(infoMessageListeners.containsKey(address)) { log.warn("Receive a duplicate registration from info message listener on ({})", address); } else { Future<InfoMessageListenerRpcGateway> infoMessageListenerRpcGatewayFuture = getRpcService().connect(address, InfoMessageListenerRpcGateway.class); Future<Void> infoMessageListenerAcceptFuture = infoMessageListenerRpcGatewayFuture.thenAcceptAsync(new AcceptFunction<InfoMessageListenerRpcGateway>() { @Override public void accept(InfoMessageListenerRpcGateway gateway) { log.info("Receive a registration from info message listener on ({})", address); infoMessageListeners.put(address, gateway); } }, getMainThreadExecutor()); infoMessageListenerAcceptFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { log.warn("Receive a registration from unreachable info message listener on ({})", address); return null; } }, getRpcService().getExecutor()); } }
registrationAcceptFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) {
resourceManagerAcceptFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) {
submitResultFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) {
@SuppressWarnings("unchecked") public void start() { checkState(!closed, "The RPC connection is already closed"); checkState(!isConnected() && pendingRegistration == null, "The RPC connection is already started"); pendingRegistration = checkNotNull(generateRegistration()); pendingRegistration.startRegistration(); Future<Tuple2<Gateway, Success>> future = pendingRegistration.getFuture(); Future<Void> registrationSuccessFuture = future.thenAcceptAsync(new AcceptFunction<Tuple2<Gateway, Success>>() { @Override public void accept(Tuple2<Gateway, Success> result) { targetGateway = result.f0; onRegistrationSuccess(result.f1); } }, executor); // this future should only ever fail if there is a bug, not if the registration is declined registrationSuccessFuture.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable failure) { onRegistrationFailure(failure); return null; } }, executor); }
result.exceptionallyAsync(new ApplyFunction<Throwable, Void>() { @Override public Void apply(Throwable value) {