Search in sources :

Example 1 with HttpRemoteTaskFactory

use of io.prestosql.server.HttpRemoteTaskFactory in project hetu-core by openlookeng.

the class TestHttpRemoteTask method testEmptyTaskSource.

@Test(timeOut = 30000)
public void testEmptyTaskSource() throws Exception {
    AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
    TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, FailureScenario.NO_FAILURE);
    HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource);
    RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
    testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
    remoteTask.start();
    remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID, Lifespan.taskWide());
    poll(() -> testingTaskResource.getRequests().size() > 0);
    assertEquals(testingTaskResource.getRequests().get(0).getSources().size(), 1);
    assertEquals(testingTaskResource.getRequests().get(0).getSources().get(0).getSplits().size(), 0);
    httpRemoteTaskFactory.stop();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) HttpRemoteTaskFactory(io.prestosql.server.HttpRemoteTaskFactory) RemoteTask(io.prestosql.execution.RemoteTask) Test(org.testng.annotations.Test)

Example 2 with HttpRemoteTaskFactory

use of io.prestosql.server.HttpRemoteTaskFactory in project hetu-core by openlookeng.

the class TestHttpRemoteTask method runTest.

private void runTest(FailureScenario failureScenario) throws Exception {
    AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
    TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, failureScenario);
    HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource);
    RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
    testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
    remoteTask.start();
    waitUntilIdle(lastActivityNanos);
    httpRemoteTaskFactory.stop();
    assertTrue(remoteTask.getTaskStatus().getState().isDone(), format("TaskStatus is not in a done state: %s", remoteTask.getTaskStatus()));
    ErrorCode actualErrorCode = getOnlyElement(remoteTask.getTaskStatus().getFailures()).getErrorCode();
    switch(failureScenario) {
        case REJECTED_EXECUTION:
            // for a rejection to occur, the http client must be shutdown, which means we will not be able to ge the final task info
            assertEquals(actualErrorCode, REMOTE_TASK_ERROR.toErrorCode());
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) HttpRemoteTaskFactory(io.prestosql.server.HttpRemoteTaskFactory) RemoteTask(io.prestosql.execution.RemoteTask) ErrorCode(io.prestosql.spi.ErrorCode)

Example 3 with HttpRemoteTaskFactory

use of io.prestosql.server.HttpRemoteTaskFactory in project hetu-core by openlookeng.

the class TestHttpRemoteTask method testRegular.

@Test(timeOut = 30000)
public void testRegular() throws Exception {
    AtomicLong lastActivityNanos = new AtomicLong(System.nanoTime());
    TestingTaskResource testingTaskResource = new TestingTaskResource(lastActivityNanos, FailureScenario.NO_FAILURE);
    HttpRemoteTaskFactory httpRemoteTaskFactory = createHttpRemoteTaskFactory(testingTaskResource);
    RemoteTask remoteTask = createRemoteTask(httpRemoteTaskFactory);
    testingTaskResource.setInitialTaskInfo(remoteTask.getTaskInfo());
    remoteTask.start();
    Lifespan lifespan = Lifespan.driverGroup(3);
    remoteTask.addSplits(ImmutableMultimap.of(TABLE_SCAN_NODE_ID, new Split(new CatalogName("test"), TestingSplit.createLocalSplit(), lifespan)));
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID) != null);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getSplits().size() == 1);
    remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID, lifespan);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).getNoMoreSplitsForLifespan().size() == 1);
    remoteTask.noMoreSplits(TABLE_SCAN_NODE_ID);
    poll(() -> testingTaskResource.getTaskSource(TABLE_SCAN_NODE_ID).isNoMoreSplits());
    remoteTask.cancel();
    poll(() -> remoteTask.getTaskStatus().getState().isDone());
    poll(() -> remoteTask.getTaskInfo().getTaskStatus().getState().isDone());
    httpRemoteTaskFactory.stop();
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) HttpRemoteTaskFactory(io.prestosql.server.HttpRemoteTaskFactory) RemoteTask(io.prestosql.execution.RemoteTask) CatalogName(io.prestosql.spi.connector.CatalogName) Split(io.prestosql.metadata.Split) TestingSplit(io.prestosql.testing.TestingSplit) Lifespan(io.prestosql.execution.Lifespan) Test(org.testng.annotations.Test)

Example 4 with HttpRemoteTaskFactory

use of io.prestosql.server.HttpRemoteTaskFactory 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)

Aggregations

HttpRemoteTaskFactory (io.prestosql.server.HttpRemoteTaskFactory)4 RemoteTask (io.prestosql.execution.RemoteTask)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 Test (org.testng.annotations.Test)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 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 Lifespan (io.prestosql.execution.Lifespan)1 QueryManagerConfig (io.prestosql.execution.QueryManagerConfig)1 TaskInfo (io.prestosql.execution.TaskInfo)1 TaskStatus (io.prestosql.execution.TaskStatus)1 HandleJsonModule (io.prestosql.metadata.HandleJsonModule)1