Search in sources :

Example 1 with TaskManagerException

use of org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException in project flink by apache.

the class TaskExecutor method requestSlot.

// ----------------------------------------------------------------------
// Slot allocation RPCs
// ----------------------------------------------------------------------
@Override
public CompletableFuture<Acknowledge> requestSlot(final SlotID slotId, final JobID jobId, final AllocationID allocationId, final ResourceProfile resourceProfile, final String targetAddress, final ResourceManagerId resourceManagerId, final Time timeout) {
    // TODO: Filter invalid requests from the resource manager by using the
    // instance/registration Id
    log.info("Receive slot request {} for job {} from resource manager with leader id {}.", allocationId, jobId, resourceManagerId);
    if (!isConnectedToResourceManager(resourceManagerId)) {
        final String message = String.format("TaskManager is not connected to the resource manager %s.", resourceManagerId);
        log.debug(message);
        return FutureUtils.completedExceptionally(new TaskManagerException(message));
    }
    tryPersistAllocationSnapshot(new SlotAllocationSnapshot(slotId, jobId, targetAddress, allocationId, resourceProfile));
    try {
        final boolean isConnected = allocateSlotForJob(jobId, slotId, allocationId, resourceProfile, targetAddress);
        if (isConnected) {
            offerSlotsToJobManager(jobId);
        }
        return CompletableFuture.completedFuture(Acknowledge.get());
    } catch (SlotAllocationException e) {
        log.debug("Could not allocate slot for allocation id {}.", allocationId, e);
        return FutureUtils.completedExceptionally(e);
    }
}
Also used : TaskManagerException(org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException) SlotAllocationException(org.apache.flink.runtime.taskexecutor.exceptions.SlotAllocationException) SlotAllocationSnapshot(org.apache.flink.runtime.taskexecutor.slot.SlotAllocationSnapshot)

Example 2 with TaskManagerException

use of org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException in project flink by apache.

the class TaskExecutor method establishResourceManagerConnection.

private void establishResourceManagerConnection(ResourceManagerGateway resourceManagerGateway, ResourceID resourceManagerResourceId, InstanceID taskExecutorRegistrationId, ClusterInformation clusterInformation) {
    final CompletableFuture<Acknowledge> slotReportResponseFuture = resourceManagerGateway.sendSlotReport(getResourceID(), taskExecutorRegistrationId, taskSlotTable.createSlotReport(getResourceID()), taskManagerConfiguration.getRpcTimeout());
    slotReportResponseFuture.whenCompleteAsync((acknowledge, throwable) -> {
        if (throwable != null) {
            reconnectToResourceManager(new TaskManagerException("Failed to send initial slot report to ResourceManager.", throwable));
        }
    }, getMainThreadExecutor());
    // monitor the resource manager as heartbeat target
    resourceManagerHeartbeatManager.monitorTarget(resourceManagerResourceId, new ResourceManagerHeartbeatReceiver(resourceManagerGateway));
    // set the propagated blob server address
    final InetSocketAddress blobServerAddress = new InetSocketAddress(clusterInformation.getBlobServerHostname(), clusterInformation.getBlobServerPort());
    taskExecutorBlobService.setBlobServerAddress(blobServerAddress);
    establishedResourceManagerConnection = new EstablishedResourceManagerConnection(resourceManagerGateway, resourceManagerResourceId, taskExecutorRegistrationId);
    stopRegistrationTimeout();
}
Also used : Acknowledge(org.apache.flink.runtime.messages.Acknowledge) TaskManagerException(org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException) InetSocketAddress(java.net.InetSocketAddress)

Aggregations

TaskManagerException (org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException)2 InetSocketAddress (java.net.InetSocketAddress)1 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)1 SlotAllocationException (org.apache.flink.runtime.taskexecutor.exceptions.SlotAllocationException)1 SlotAllocationSnapshot (org.apache.flink.runtime.taskexecutor.slot.SlotAllocationSnapshot)1