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);
}
}
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);
}
}
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);
}
}
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));
}
}
});
}
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);
}
});
}
Aggregations