Search in sources :

Example 1 with FailTaskRequest

use of io.trino.server.FailTaskRequest in project trino by trinodb.

the class HttpRemoteTask method failRemotely.

/**
 * Trigger remote task failure. Task status will be updated only when request sent to remote node returns.
 */
@Override
public synchronized void failRemotely(Throwable cause) {
    try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) {
        TaskStatus taskStatus = getTaskStatus();
        if (taskStatus.getState().isDone()) {
            return;
        }
        scheduleAsyncCleanupRequest(new Backoff(maxErrorDuration), "fail", new FailTaskRequest(Failures.toFailure(cause)));
    }
}
Also used : FailTaskRequest(io.trino.server.FailTaskRequest) SetThreadName(io.airlift.concurrent.SetThreadName) TaskStatus(io.trino.execution.TaskStatus)

Example 2 with FailTaskRequest

use of io.trino.server.FailTaskRequest in project trino by trinodb.

the class TestHttpRemoteTask method createHttpRemoteTaskFactory.

private static HttpRemoteTaskFactory createHttpRemoteTaskFactory(TestingTaskResource testingTaskResource, DynamicFilterService dynamicFilterService) {
    Bootstrap app = new Bootstrap(new JsonModule(), new HandleJsonModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(JsonMapper.class).in(SINGLETON);
            binder.bind(Metadata.class).toInstance(createTestMetadataManager());
            jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class);
            jsonCodecBinder(binder).bindJsonCodec(VersionedDynamicFilterDomains.class);
            jsonBinder(binder).addSerializerBinding(Block.class).to(BlockJsonSerde.Serializer.class);
            jsonBinder(binder).addDeserializerBinding(Block.class).to(BlockJsonSerde.Deserializer.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class);
            jsonCodecBinder(binder).bindJsonCodec(FailTaskRequest.class);
            binder.bind(TypeManager.class).toInstance(TESTING_TYPE_MANAGER);
            binder.bind(BlockEncodingManager.class).in(SINGLETON);
            binder.bind(BlockEncodingSerde.class).to(InternalBlockEncodingSerde.class).in(SINGLETON);
        }

        @Provides
        private HttpRemoteTaskFactory createHttpRemoteTaskFactory(JsonMapper jsonMapper, JsonCodec<TaskStatus> taskStatusCodec, JsonCodec<VersionedDynamicFilterDomains> dynamicFilterDomainsCodec, JsonCodec<TaskInfo> taskInfoCodec, JsonCodec<TaskUpdateRequest> taskUpdateRequestCodec, JsonCodec<FailTaskRequest> failTaskRequestCodec) {
            JaxrsTestingHttpProcessor jaxrsTestingHttpProcessor = new JaxrsTestingHttpProcessor(URI.create("http://fake.invalid/"), testingTaskResource, jsonMapper);
            TestingHttpClient testingHttpClient = new TestingHttpClient(jaxrsTestingHttpProcessor.setTrace(TRACE_HTTP));
            testingTaskResource.setHttpClient(testingHttpClient);
            return new HttpRemoteTaskFactory(new QueryManagerConfig(), TASK_MANAGER_CONFIG, testingHttpClient, new TestSqlTaskManager.MockLocationFactory(), taskStatusCodec, dynamicFilterDomainsCodec, taskInfoCodec, taskUpdateRequestCodec, failTaskRequestCodec, new RemoteTaskStats(), dynamicFilterService);
        }
    });
    Injector injector = app.doNotInitializeLogging().quiet().initialize();
    return injector.getInstance(HttpRemoteTaskFactory.class);
}
Also used : VersionedDynamicFilterDomains(io.trino.execution.DynamicFiltersCollector.VersionedDynamicFilterDomains) TaskInfo(io.trino.execution.TaskInfo) JsonMapper(io.airlift.jaxrs.JsonMapper) JsonCodecBinder.jsonCodecBinder(io.airlift.json.JsonCodecBinder.jsonCodecBinder) Binder(com.google.inject.Binder) JsonBinder.jsonBinder(io.airlift.json.JsonBinder.jsonBinder) FailTaskRequest(io.trino.server.FailTaskRequest) JaxrsTestingHttpProcessor(io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor) HandleJsonModule(io.trino.metadata.HandleJsonModule) Injector(com.google.inject.Injector) HttpRemoteTaskFactory(io.trino.server.HttpRemoteTaskFactory) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) Bootstrap(io.airlift.bootstrap.Bootstrap) TypeDeserializer(io.trino.type.TypeDeserializer) TaskUpdateRequest(io.trino.server.TaskUpdateRequest) InternalBlockEncodingSerde(io.trino.metadata.InternalBlockEncodingSerde) BlockEncodingSerde(io.trino.spi.block.BlockEncodingSerde) TaskStatus(io.trino.execution.TaskStatus) Provides(com.google.inject.Provides) JsonModule(io.airlift.json.JsonModule) HandleJsonModule(io.trino.metadata.HandleJsonModule) TypeDeserializer(io.trino.type.TypeDeserializer) QueryManagerConfig(io.trino.execution.QueryManagerConfig) JsonModule(io.airlift.json.JsonModule) Module(com.google.inject.Module) HandleJsonModule(io.trino.metadata.HandleJsonModule)

Aggregations

TaskStatus (io.trino.execution.TaskStatus)2 FailTaskRequest (io.trino.server.FailTaskRequest)2 Binder (com.google.inject.Binder)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 Provides (com.google.inject.Provides)1 Bootstrap (io.airlift.bootstrap.Bootstrap)1 SetThreadName (io.airlift.concurrent.SetThreadName)1 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)1 JsonMapper (io.airlift.jaxrs.JsonMapper)1 JaxrsTestingHttpProcessor (io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor)1 JsonBinder.jsonBinder (io.airlift.json.JsonBinder.jsonBinder)1 JsonCodecBinder.jsonCodecBinder (io.airlift.json.JsonCodecBinder.jsonCodecBinder)1 JsonModule (io.airlift.json.JsonModule)1 VersionedDynamicFilterDomains (io.trino.execution.DynamicFiltersCollector.VersionedDynamicFilterDomains)1 QueryManagerConfig (io.trino.execution.QueryManagerConfig)1 TaskInfo (io.trino.execution.TaskInfo)1 HandleJsonModule (io.trino.metadata.HandleJsonModule)1 InternalBlockEncodingSerde (io.trino.metadata.InternalBlockEncodingSerde)1 HttpRemoteTaskFactory (io.trino.server.HttpRemoteTaskFactory)1