Search in sources :

Example 1 with JaxrsTestingHttpProcessor

use of io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor in project hetu-core by openlookeng.

the class TestHttpRemoteTask method createHttpRemoteTaskFactory.

private static HttpRemoteTaskFactory createHttpRemoteTaskFactory(TestingTaskResource testingTaskResource) throws Exception {
    Bootstrap app = new Bootstrap(new JsonModule(), new SmileModule(), new HandleJsonModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            binder.bind(JsonMapper.class);
            binder.bind(Metadata.class).toInstance(createTestMetadataManager());
            jsonBinder(binder).addDeserializerBinding(Type.class).to(TypeDeserializer.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskStatus.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskInfo.class);
            jsonCodecBinder(binder).bindJsonCodec(TaskUpdateRequest.class);
            smileCodecBinder(binder).bindSmileCodec(TaskStatus.class);
            smileCodecBinder(binder).bindSmileCodec(TaskInfo.class);
            smileCodecBinder(binder).bindSmileCodec(TaskUpdateRequest.class);
        }

        @Provides
        private HttpRemoteTaskFactory createHttpRemoteTaskFactory(JsonMapper jsonMapper, JsonCodec<TaskStatus> taskStatusJsonCodec, SmileCodec<TaskStatus> taskStatusSmileCodec, JsonCodec<TaskInfo> taskInfoJsonCodec, SmileCodec<TaskInfo> taskInfoSmileCodec, JsonCodec<TaskUpdateRequest> taskUpdateRequestJsonCodec, SmileCodec<TaskUpdateRequest> taskUpdateRequestSmileCodec) {
            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(), taskStatusJsonCodec, taskStatusSmileCodec, taskInfoJsonCodec, taskInfoSmileCodec, taskUpdateRequestJsonCodec, taskUpdateRequestSmileCodec, new RemoteTaskStats(), new InternalCommunicationConfig());
        }
    });
    Injector injector = app.strictConfig().doNotInitializeLogging().quiet().initialize();
    HandleResolver handleResolver = injector.getInstance(HandleResolver.class);
    handleResolver.addConnectorName("test", new TestingHandleResolver());
    return injector.getInstance(HttpRemoteTaskFactory.class);
}
Also used : TestingHandleResolver(io.prestosql.testing.TestingHandleResolver) HandleResolver(io.prestosql.metadata.HandleResolver) JsonMapper(io.airlift.jaxrs.JsonMapper) TaskInfo(io.prestosql.execution.TaskInfo) JsonBinder.jsonBinder(io.airlift.json.JsonBinder.jsonBinder) JsonCodecBinder.jsonCodecBinder(io.airlift.json.JsonCodecBinder.jsonCodecBinder) Binder(com.google.inject.Binder) SmileCodecBinder.smileCodecBinder(io.prestosql.protocol.SmileCodecBinder.smileCodecBinder) InternalCommunicationConfig(io.prestosql.server.InternalCommunicationConfig) JaxrsTestingHttpProcessor(io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor) HandleJsonModule(io.prestosql.metadata.HandleJsonModule) Injector(com.google.inject.Injector) HttpRemoteTaskFactory(io.prestosql.server.HttpRemoteTaskFactory) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) Bootstrap(io.airlift.bootstrap.Bootstrap) TypeDeserializer(io.prestosql.type.TypeDeserializer) TestingHandleResolver(io.prestosql.testing.TestingHandleResolver) TaskUpdateRequest(io.prestosql.server.TaskUpdateRequest) TaskStatus(io.prestosql.execution.TaskStatus) Provides(com.google.inject.Provides) JsonModule(io.airlift.json.JsonModule) HandleJsonModule(io.prestosql.metadata.HandleJsonModule) SmileModule(io.prestosql.protocol.SmileModule) QueryManagerConfig(io.prestosql.execution.QueryManagerConfig) Module(com.google.inject.Module) SmileModule(io.prestosql.protocol.SmileModule) JsonModule(io.airlift.json.JsonModule) HandleJsonModule(io.prestosql.metadata.HandleJsonModule)

Example 2 with JaxrsTestingHttpProcessor

use of io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor 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

Binder (com.google.inject.Binder)2 Injector (com.google.inject.Injector)2 Module (com.google.inject.Module)2 Provides (com.google.inject.Provides)2 Bootstrap (io.airlift.bootstrap.Bootstrap)2 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)2 JsonMapper (io.airlift.jaxrs.JsonMapper)2 JaxrsTestingHttpProcessor (io.airlift.jaxrs.testing.JaxrsTestingHttpProcessor)2 JsonBinder.jsonBinder (io.airlift.json.JsonBinder.jsonBinder)2 JsonCodecBinder.jsonCodecBinder (io.airlift.json.JsonCodecBinder.jsonCodecBinder)2 JsonModule (io.airlift.json.JsonModule)2 QueryManagerConfig (io.prestosql.execution.QueryManagerConfig)1 TaskInfo (io.prestosql.execution.TaskInfo)1 TaskStatus (io.prestosql.execution.TaskStatus)1 HandleJsonModule (io.prestosql.metadata.HandleJsonModule)1 HandleResolver (io.prestosql.metadata.HandleResolver)1 SmileCodecBinder.smileCodecBinder (io.prestosql.protocol.SmileCodecBinder.smileCodecBinder)1 SmileModule (io.prestosql.protocol.SmileModule)1 HttpRemoteTaskFactory (io.prestosql.server.HttpRemoteTaskFactory)1 InternalCommunicationConfig (io.prestosql.server.InternalCommunicationConfig)1