Search in sources :

Example 1 with TransientBlobKey

use of org.apache.flink.runtime.blob.TransientBlobKey in project flink by apache.

the class TaskExecutorTest method testLogNotFoundHandling.

@Test(timeout = 10000L)
public void testLogNotFoundHandling() throws Throwable {
    try (NetUtils.Port port = NetUtils.getAvailablePort()) {
        int dataPort = port.getPort();
        configuration.setInteger(NettyShuffleEnvironmentOptions.DATA_PORT, dataPort);
        configuration.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_INITIAL, 100);
        configuration.setInteger(NettyShuffleEnvironmentOptions.NETWORK_REQUEST_BACKOFF_MAX, 200);
        configuration.setString(ConfigConstants.TASK_MANAGER_LOG_PATH_KEY, "/i/dont/exist");
        try (TaskSubmissionTestEnvironment env = new Builder(jobId).setConfiguration(configuration).setLocalCommunication(false).build()) {
            TaskExecutorGateway tmGateway = env.getTaskExecutorGateway();
            try {
                CompletableFuture<TransientBlobKey> logFuture = tmGateway.requestFileUploadByType(FileType.LOG, timeout);
                logFuture.get();
            } catch (Exception e) {
                assertThat(e.getMessage(), containsString("The file LOG does not exist on the TaskExecutor."));
            }
        }
    }
}
Also used : NetUtils(org.apache.flink.util.NetUtils) TransientBlobKey(org.apache.flink.runtime.blob.TransientBlobKey) TestingJobMasterGatewayBuilder(org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder) Builder(org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder) TaskDeploymentDescriptorBuilder(org.apache.flink.runtime.deployment.TaskDeploymentDescriptorBuilder) NettyShuffleEnvironmentBuilder(org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder) FlinkException(org.apache.flink.util.FlinkException) TaskSubmissionException(org.apache.flink.runtime.taskexecutor.exceptions.TaskSubmissionException) SlotNotFoundException(org.apache.flink.runtime.taskexecutor.slot.SlotNotFoundException) TriConsumerWithException(org.apache.flink.util.function.TriConsumerWithException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException) RegistrationTimeoutException(org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException) CompletionException(java.util.concurrent.CompletionException) TaskManagerException(org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException) RecipientUnreachableException(org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException) Test(org.junit.Test)

Example 2 with TransientBlobKey

use of org.apache.flink.runtime.blob.TransientBlobKey in project flink by apache.

the class TaskExecutor method putTransientBlobStream.

private CompletableFuture<TransientBlobKey> putTransientBlobStream(InputStream inputStream, String fileTag) {
    final TransientBlobService transientBlobService = taskExecutorBlobService.getTransientBlobService();
    final TransientBlobKey transientBlobKey;
    try {
        transientBlobKey = transientBlobService.putTransient(inputStream);
    } catch (IOException e) {
        log.debug("Could not upload file {}.", fileTag, e);
        return FutureUtils.completedExceptionally(new FlinkException("Could not upload file " + fileTag + '.', e));
    }
    return CompletableFuture.completedFuture(transientBlobKey);
}
Also used : TransientBlobService(org.apache.flink.runtime.blob.TransientBlobService) TransientBlobKey(org.apache.flink.runtime.blob.TransientBlobKey) IOException(java.io.IOException) FlinkException(org.apache.flink.util.FlinkException)

Example 3 with TransientBlobKey

use of org.apache.flink.runtime.blob.TransientBlobKey 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

IOException (java.io.IOException)3 TransientBlobKey (org.apache.flink.runtime.blob.TransientBlobKey)3 FlinkException (org.apache.flink.util.FlinkException)3 CompletionException (java.util.concurrent.CompletionException)2 ExecutionException (java.util.concurrent.ExecutionException)2 File (java.io.File)1 TimeoutException (java.util.concurrent.TimeoutException)1 Tuple2 (org.apache.flink.api.java.tuple.Tuple2)1 TransientBlobService (org.apache.flink.runtime.blob.TransientBlobService)1 ResourceID (org.apache.flink.runtime.clusterframework.types.ResourceID)1 TaskDeploymentDescriptorBuilder (org.apache.flink.runtime.deployment.TaskDeploymentDescriptorBuilder)1 NettyShuffleEnvironmentBuilder (org.apache.flink.runtime.io.network.NettyShuffleEnvironmentBuilder)1 TestingJobMasterGatewayBuilder (org.apache.flink.runtime.jobmaster.utils.TestingJobMasterGatewayBuilder)1 UnknownTaskExecutorException (org.apache.flink.runtime.resourcemanager.exceptions.UnknownTaskExecutorException)1 NotFoundException (org.apache.flink.runtime.rest.NotFoundException)1 RestHandlerException (org.apache.flink.runtime.rest.handler.RestHandlerException)1 RecipientUnreachableException (org.apache.flink.runtime.rpc.exceptions.RecipientUnreachableException)1 Builder (org.apache.flink.runtime.taskexecutor.TaskSubmissionTestEnvironment.Builder)1 RegistrationTimeoutException (org.apache.flink.runtime.taskexecutor.exceptions.RegistrationTimeoutException)1 TaskManagerException (org.apache.flink.runtime.taskexecutor.exceptions.TaskManagerException)1