Search in sources :

Example 6 with NotFoundException

use of org.apache.flink.runtime.rest.NotFoundException in project flink by apache.

the class JobVertexDetailsHandler method handleRequest.

@Override
protected JobVertexDetailsInfo handleRequest(HandlerRequest<EmptyRequestBody> request, AccessExecutionGraph executionGraph) throws NotFoundException {
    JobID jobID = request.getPathParameter(JobIDPathParameter.class);
    JobVertexID jobVertexID = request.getPathParameter(JobVertexIdPathParameter.class);
    AccessExecutionJobVertex jobVertex = executionGraph.getJobVertex(jobVertexID);
    if (jobVertex == null) {
        throw new NotFoundException(String.format("JobVertex %s not found", jobVertexID));
    }
    return createJobVertexDetailsInfo(jobVertex, jobID, metricFetcher);
}
Also used : AccessExecutionJobVertex(org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex) JobVertexID(org.apache.flink.runtime.jobgraph.JobVertexID) NotFoundException(org.apache.flink.runtime.rest.NotFoundException) JobID(org.apache.flink.api.common.JobID)

Example 7 with NotFoundException

use of org.apache.flink.runtime.rest.NotFoundException 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)

Aggregations

NotFoundException (org.apache.flink.runtime.rest.NotFoundException)7 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)4 File (java.io.File)3 IOException (java.io.IOException)3 JobID (org.apache.flink.api.common.JobID)3 JobVertexID (org.apache.flink.runtime.jobgraph.JobVertexID)3 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 RandomAccessFile (java.io.RandomAccessFile)2 URI (java.net.URI)2 URL (java.net.URL)2 ParseException (java.text.ParseException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 CompletionException (java.util.concurrent.CompletionException)2 AccessExecutionJobVertex (org.apache.flink.runtime.executiongraph.AccessExecutionJobVertex)2 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 ExecutionException (java.util.concurrent.ExecutionException)1