Search in sources :

Example 1 with UnknownTaskExecutorException

use of org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException in project flink by apache.

the class ResourceManager method requestTaskManagerFileUploadByName.

@Override
public CompletableFuture<TransientBlobKey> requestTaskManagerFileUploadByName(ResourceID taskManagerId, String fileName, Time timeout) {
    log.debug("Request upload of file {} from TaskExecutor {}.", fileName, taskManagerId.getStringWithMetadata());
    final WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(taskManagerId);
    if (taskExecutor == null) {
        log.debug("Request upload of file {} from unregistered TaskExecutor {}.", fileName, taskManagerId.getStringWithMetadata());
        return FutureUtils.completedExceptionally(new UnknownTaskExecutorException(taskManagerId));
    } else {
        return taskExecutor.getTaskExecutorGateway().requestFileUploadByName(fileName, timeout);
    }
}
Also used : UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)

Example 2 with UnknownTaskExecutorException

use of org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException in project flink by apache.

the class ResourceManager method requestTaskManagerDetailsInfo.

@Override
public CompletableFuture<TaskManagerInfoWithSlots> requestTaskManagerDetailsInfo(ResourceID resourceId, Time timeout) {
    final WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(resourceId);
    if (taskExecutor == null) {
        return FutureUtils.completedExceptionally(new UnknownTaskExecutorException(resourceId));
    } else {
        final InstanceID instanceId = taskExecutor.getInstanceID();
        final TaskManagerInfoWithSlots taskManagerInfoWithSlots = new TaskManagerInfoWithSlots(new TaskManagerInfo(resourceId, taskExecutor.getTaskExecutorGateway().getAddress(), taskExecutor.getDataPort(), taskExecutor.getJmxPort(), taskManagerHeartbeatManager.getLastHeartbeatFrom(resourceId), slotManager.getNumberRegisteredSlotsOf(instanceId), slotManager.getNumberFreeSlotsOf(instanceId), slotManager.getRegisteredResourceOf(instanceId), slotManager.getFreeResourceOf(instanceId), taskExecutor.getHardwareDescription(), taskExecutor.getMemoryConfiguration()), slotManager.getAllocatedSlotsOf(instanceId));
        return CompletableFuture.completedFuture(taskManagerInfoWithSlots);
    }
}
Also used : InstanceID(org.apache.flink.runtime.instance.InstanceID) TaskManagerInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerInfo) UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)

Example 3 with UnknownTaskExecutorException

use of org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException in project flink by apache.

the class ResourceManager method requestTaskManagerFileUploadByType.

@Override
public CompletableFuture<TransientBlobKey> requestTaskManagerFileUploadByType(ResourceID taskManagerId, FileType fileType, Time timeout) {
    log.debug("Request {} file upload from TaskExecutor {}.", fileType, taskManagerId.getStringWithMetadata());
    final WorkerRegistration<WorkerType> taskExecutor = taskExecutors.get(taskManagerId);
    if (taskExecutor == null) {
        log.debug("Request upload of file {} from unregistered TaskExecutor {}.", fileType, taskManagerId.getStringWithMetadata());
        return FutureUtils.completedExceptionally(new UnknownTaskExecutorException(taskManagerId));
    } else {
        return taskExecutor.getTaskExecutorGateway().requestFileUploadByType(fileType, timeout);
    }
}
Also used : UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)

Example 4 with UnknownTaskExecutorException

use of org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException in project flink by apache.

the class AbstractTaskManagerFileHandler method respondToRequest.

@Override
protected CompletableFuture<Void> respondToRequest(ChannelHandlerContext ctx, HttpRequest httpRequest, HandlerRequest<EmptyRequestBody> handlerRequest, RestfulGateway gateway) throws RestHandlerException {
    final ResourceID taskManagerId = handlerRequest.getPathParameter(TaskManagerIdPathParameter.class);
    String filename = getFileName(handlerRequest);
    final Tuple2<ResourceID, String> taskManagerIdAndFileName = new Tuple2<>(taskManagerId, filename);
    final CompletableFuture<TransientBlobKey> blobKeyFuture;
    try {
        blobKeyFuture = fileBlobKeys.get(taskManagerIdAndFileName);
    } catch (ExecutionException e) {
        final Throwable cause = ExceptionUtils.stripExecutionException(e);
        throw new RestHandlerException("Could not retrieve file blob key future.", HttpResponseStatus.INTERNAL_SERVER_ERROR, cause);
    }
    final CompletableFuture<Void> resultFuture = blobKeyFuture.thenAcceptAsync((TransientBlobKey blobKey) -> {
        final File file;
        try {
            file = transientBlobService.getFile(blobKey);
        } catch (IOException e) {
            throw new CompletionException(new FlinkException("Could not retrieve file from transient blob store.", e));
        }
        try {
            HandlerUtils.transferFile(ctx, file, httpRequest);
        } catch (FlinkException e) {
            throw new CompletionException(new FlinkException("Could not transfer file to client.", e));
        }
    }, ctx.executor());
    return resultFuture.whenComplete((Void ignored, Throwable throwable) -> {
        if (throwable != null) {
            log.error("Failed to transfer file from TaskExecutor {}.", taskManagerId, throwable);
            fileBlobKeys.invalidate(taskManagerId);
            final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(throwable);
            if (strippedThrowable instanceof UnknownTaskExecutorException) {
                throw new CompletionException(new NotFoundException(String.format("Failed to transfer file from TaskExecutor %s because it was unknown.", taskManagerId), strippedThrowable));
            } else {
                throw new CompletionException(new FlinkException(String.format("Failed to transfer file from TaskExecutor %s.", taskManagerId), strippedThrowable));
            }
        }
    });
}
Also used : TransientBlobKey(org.apache.flink.runtime.blob.TransientBlobKey) UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException) NotFoundException(org.apache.flink.runtime.rest.NotFoundException) IOException(java.io.IOException) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) FlinkException(org.apache.flink.util.FlinkException) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) Tuple2(org.apache.flink.api.java.tuple.Tuple2) CompletionException(java.util.concurrent.CompletionException) ExecutionException(java.util.concurrent.ExecutionException) File(java.io.File)

Example 5 with UnknownTaskExecutorException

use of org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException in project flink by apache.

the class TaskManagerDetailsHandler method handleRequest.

@Override
protected CompletableFuture<TaskManagerDetailsInfo> handleRequest(@Nonnull HandlerRequest<EmptyRequestBody> request, @Nonnull ResourceManagerGateway gateway) throws RestHandlerException {
    final ResourceID taskManagerResourceId = request.getPathParameter(TaskManagerIdPathParameter.class);
    CompletableFuture<TaskManagerInfoWithSlots> taskManagerInfoWithSlotsFuture = gateway.requestTaskManagerDetailsInfo(taskManagerResourceId, timeout);
    metricFetcher.update();
    return taskManagerInfoWithSlotsFuture.thenApply((taskManagerInfoWithSlots) -> {
        final MetricStore.TaskManagerMetricStore tmMetrics = metricStore.getTaskManagerMetricStore(taskManagerResourceId.getResourceIdString());
        final TaskManagerMetricsInfo taskManagerMetricsInfo;
        if (tmMetrics != null) {
            log.debug("Create metrics info for TaskManager {}.", taskManagerResourceId.getStringWithMetadata());
            taskManagerMetricsInfo = createTaskManagerMetricsInfo(tmMetrics);
        } else {
            log.debug("No metrics for TaskManager {}.", taskManagerResourceId.getStringWithMetadata());
            taskManagerMetricsInfo = TaskManagerMetricsInfo.empty();
        }
        return new TaskManagerDetailsInfo(taskManagerInfoWithSlots, taskManagerMetricsInfo);
    }).exceptionally((Throwable throwable) -> {
        final Throwable strippedThrowable = ExceptionUtils.stripExecutionException(throwable);
        if (strippedThrowable instanceof UnknownTaskExecutorException) {
            throw new CompletionException(new RestHandlerException("Could not find TaskExecutor " + taskManagerResourceId + '.', HttpResponseStatus.NOT_FOUND, strippedThrowable));
        } else {
            throw new CompletionException(strippedThrowable);
        }
    });
}
Also used : TaskManagerDetailsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo) ExceptionUtils(org.apache.flink.util.ExceptionUtils) CompletableFuture(java.util.concurrent.CompletableFuture) AbstractResourceManagerHandler(org.apache.flink.runtime.rest.handler.resourcemanager.AbstractResourceManagerHandler) MessageHeaders(org.apache.flink.runtime.rest.messages.MessageHeaders) HttpResponseStatus(org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) ArrayList(java.util.ArrayList) Map(java.util.Map) HandlerRequest(org.apache.flink.runtime.rest.handler.HandlerRequest) TaskManagerInfoWithSlots(org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) MetricFetcher(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricFetcher) TaskManagerMessageParameters(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMessageParameters) Nonnull(javax.annotation.Nonnull) TaskManagerIdPathParameter(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerIdPathParameter) TaskManagerMetricsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo) UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException) MetricStore(org.apache.flink.runtime.rest.handler.legacy.metrics.MetricStore) GatewayRetriever(org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever) RestfulGateway(org.apache.flink.runtime.webmonitor.RestfulGateway) CompletionException(java.util.concurrent.CompletionException) Preconditions(org.apache.flink.util.Preconditions) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException) List(java.util.List) Time(org.apache.flink.api.common.time.Time) ResourceManagerGateway(org.apache.flink.runtime.resourcemanager.ResourceManagerGateway) TaskManagerMetricsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerMetricsInfo) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) UnknownTaskExecutorException(org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException) CompletionException(java.util.concurrent.CompletionException) TaskManagerInfoWithSlots(org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots) TaskManagerDetailsInfo(org.apache.flink.runtime.rest.messages.taskmanager.TaskManagerDetailsInfo) RestHandlerException(org.apache.flink.runtime.rest.handler.RestHandlerException)

Aggregations

UnknownTaskExecutorException (org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)6 CompletionException (java.util.concurrent.CompletionException)3 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)3 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)3 ResourceManagerGateway (org.apache.flink.runtime.resourcemanager.ResourceManagerGateway)2 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1 Nonnull (javax.annotation.Nonnull)1 Time (org.apache.flink.api.common.time.Time)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 TransientBlobKey (org.apache.flink.runtime.blob.TransientBlobKey)1 InstanceID (org.apache.flink.runtime.instance.InstanceID)1 TaskManagerInfoWithSlots (org.apache.flink.runtime.resourcemanager.TaskManagerInfoWithSlots)1 NotFoundException (org.apache.flink.runtime.rest.NotFoundException)1