Search in sources :

Example 1 with NoOpFailureDetector

use of io.prestosql.failuredetector.NoOpFailureDetector in project hetu-core by openlookeng.

the class TestHttpPageBufferClient method testHappyPath.

@Test
public void testHappyPath() throws Exception {
    Page expectedPage = new Page(100);
    DataSize expectedMaxSize = new DataSize(11, Unit.MEGABYTE);
    MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(expectedMaxSize);
    CyclicBarrier requestComplete = new CyclicBarrier(2);
    TestingClientCallback callback = new TestingClientCallback(requestComplete);
    URI location = URI.create("http://localhost:8080");
    String instanceId = "testing instance id";
    HttpPageBufferClient client = new HttpPageBufferClient(new TestingHttpClient(processor, scheduler), expectedMaxSize, new Duration(1, TimeUnit.MINUTES), true, new TaskLocation(location, instanceId), callback, scheduler, pageBufferClientCallbackExecutor, false, null, new NoOpFailureDetector(), false, 10);
    assertStatus(client, location, "queued", 0, 0, 0, 0, "not scheduled");
    // fetch a page and verify
    processor.addPage(location, expectedPage);
    callback.resetStats();
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 1);
    assertPageEquals(expectedPage, callback.getPages().get(0));
    assertEquals(callback.getCompletedRequests(), 1);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertStatus(client, location, "queued", 1, 1, 1, 0, "not scheduled");
    // fetch no data and verify
    callback.resetStats();
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 1);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertStatus(client, location, "queued", 1, 2, 2, 0, "not scheduled");
    // fetch two more pages and verify
    processor.addPage(location, expectedPage);
    processor.addPage(location, expectedPage);
    callback.resetStats();
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 2);
    assertPageEquals(expectedPage, callback.getPages().get(0));
    assertPageEquals(expectedPage, callback.getPages().get(1));
    assertEquals(callback.getCompletedRequests(), 1);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertEquals(callback.getFailedBuffers(), 0);
    callback.resetStats();
    assertStatus(client, location, "queued", 3, 3, 3, 0, "not scheduled");
    // finish and verify
    callback.resetStats();
    processor.setComplete(location);
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    // get the buffer complete signal
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 1);
    // schedule the delete call to the buffer
    callback.resetStats();
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getFinishedBuffers(), 1);
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 0);
    assertEquals(callback.getFailedBuffers(), 0);
    assertStatus(client, location, "closed", 3, 5, 5, 0, "not scheduled");
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) DataSize(io.airlift.units.DataSize) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage) Page(io.prestosql.spi.Page) Duration(io.airlift.units.Duration) URI(java.net.URI) CyclicBarrier(java.util.concurrent.CyclicBarrier) Test(org.testng.annotations.Test)

Example 2 with NoOpFailureDetector

use of io.prestosql.failuredetector.NoOpFailureDetector in project hetu-core by openlookeng.

the class TestHttpPageBufferClient method testExceptionFromResponseHandler.

@Test
public void testExceptionFromResponseHandler() throws Exception {
    TestingTicker ticker = new TestingTicker();
    AtomicReference<Duration> tickerIncrement = new AtomicReference<>(new Duration(0, TimeUnit.SECONDS));
    TestingHttpClient.Processor processor = (input) -> {
        Duration delta = tickerIncrement.get();
        ticker.increment(delta.toMillis(), TimeUnit.MILLISECONDS);
        throw new RuntimeException("Foo");
    };
    CyclicBarrier requestComplete = new CyclicBarrier(2);
    TestingClientCallback callback = new TestingClientCallback(requestComplete);
    URI location = URI.create("http://localhost:8080");
    String instanceId = "testing instance id";
    HttpPageBufferClient client = new HttpPageBufferClient(new TestingHttpClient(processor, scheduler), new DataSize(10, Unit.MEGABYTE), new Duration(30, TimeUnit.SECONDS), true, new TaskLocation(location, instanceId), callback, scheduler, ticker, pageBufferClientCallbackExecutor, false, null, new NoOpFailureDetector(), true, 10);
    assertStatus(client, location, "queued", 0, 0, 0, 0, "not scheduled");
    // request processor will throw exception, verify the request is marked a completed
    // this starts the error stopwatch
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 1);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertEquals(callback.getFailedBuffers(), 0);
    assertStatus(client, location, "queued", 0, 1, 1, 1, "not scheduled");
    // advance time forward, but not enough to fail the client
    tickerIncrement.set(new Duration(30, TimeUnit.SECONDS));
    // verify that the client has not failed
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 2);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertEquals(callback.getFailedBuffers(), 0);
    assertStatus(client, location, "queued", 0, 2, 2, 2, "not scheduled");
    // advance time forward beyond the minimum error duration
    tickerIncrement.set(new Duration(31, TimeUnit.SECONDS));
    // verify that the client has failed
    client.scheduleRequest();
    requestComplete.await(10, TimeUnit.SECONDS);
    assertEquals(callback.getPages().size(), 0);
    assertEquals(callback.getCompletedRequests(), 3);
    assertEquals(callback.getFinishedBuffers(), 0);
    assertEquals(callback.getFailedBuffers(), 1);
    assertInstanceOf(callback.getFailure(), PageTransportTimeoutException.class);
    assertContains(callback.getFailure().getMessage(), WORKER_NODE_ERROR + " (http://localhost:8080/0 - 3 failures, failure duration 31.00s, total failed request time 31.00s)");
    assertStatus(client, location, "queued", 0, 3, 3, 3, "not scheduled");
}
Also used : TestingTicker(io.airlift.testing.TestingTicker) Assertions.assertContains(io.airlift.testing.Assertions.assertContains) Assertions.assertInstanceOf(io.airlift.testing.Assertions.assertInstanceOf) PAGE_TOO_LARGE(io.prestosql.spi.StandardErrorCode.PAGE_TOO_LARGE) TestingPagesSerdeFactory.testingPagesSerde(io.prestosql.testing.TestingPagesSerdeFactory.testingPagesSerde) TimeoutException(java.util.concurrent.TimeoutException) Test(org.testng.annotations.Test) Unit(io.airlift.units.DataSize.Unit) Duration(io.airlift.units.Duration) ClientCallback(io.prestosql.operator.HttpPageBufferClient.ClientCallback) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Executors.newScheduledThreadPool(java.util.concurrent.Executors.newScheduledThreadPool) URI(java.net.URI) CyclicBarrier(java.util.concurrent.CyclicBarrier) ImmutableSet(com.google.common.collect.ImmutableSet) BeforeClass(org.testng.annotations.BeforeClass) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) Set(java.util.Set) Collectors(java.util.stream.Collectors) PAGE_TRANSPORT_TIMEOUT(io.prestosql.spi.StandardErrorCode.PAGE_TRANSPORT_TIMEOUT) Executors(java.util.concurrent.Executors) DataSize(io.airlift.units.DataSize) List(java.util.List) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage) ServiceDescriptor(io.airlift.discovery.client.ServiceDescriptor) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Assert.assertEquals(org.testng.Assert.assertEquals) AtomicReference(java.util.concurrent.atomic.AtomicReference) CONTENT_TYPE(com.google.common.net.HttpHeaders.CONTENT_TYPE) ArrayList(java.util.ArrayList) PagesSerde(io.hetu.core.transport.execution.buffer.PagesSerde) Threads.daemonThreadsNamed(io.airlift.concurrent.Threads.daemonThreadsNamed) Request(io.airlift.http.client.Request) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) TestingResponse(io.airlift.http.client.testing.TestingResponse) PAGE_TRANSPORT_ERROR(io.prestosql.spi.StandardErrorCode.PAGE_TRANSPORT_ERROR) WORKER_NODE_ERROR(io.prestosql.util.Failures.WORKER_NODE_ERROR) ExecutorService(java.util.concurrent.ExecutorService) PRESTO_PAGES(io.prestosql.PrestoMediaTypes.PRESTO_PAGES) AfterClass(org.testng.annotations.AfterClass) HostAddress(io.prestosql.spi.HostAddress) NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) Page(io.prestosql.spi.Page) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) TimeUnit(java.util.concurrent.TimeUnit) HttpStatus(io.airlift.http.client.HttpStatus) Response(io.airlift.http.client.Response) FailureDetector(io.prestosql.failuredetector.FailureDetector) Collections(java.util.Collections) NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) TestingTicker(io.airlift.testing.TestingTicker) Duration(io.airlift.units.Duration) AtomicReference(java.util.concurrent.atomic.AtomicReference) URI(java.net.URI) CyclicBarrier(java.util.concurrent.CyclicBarrier) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) DataSize(io.airlift.units.DataSize) Test(org.testng.annotations.Test)

Example 3 with NoOpFailureDetector

use of io.prestosql.failuredetector.NoOpFailureDetector in project hetu-core by openlookeng.

the class TestDiscoveryNodeManager method testNodeChangeListener.

@Test(timeOut = 60000)
public void testNodeChangeListener() throws Exception {
    DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), expectedVersion, testHttpClient, internalCommunicationConfig, new MockMetadata());
    try {
        manager.startPollingNodeStates();
        BlockingQueue<AllNodes> notifications = new ArrayBlockingQueue<>(100);
        manager.addNodeChangeListener(notifications::add);
        AllNodes allNodes = notifications.take();
        assertEquals(allNodes.getActiveNodes(), activeNodes);
        assertEquals(allNodes.getInactiveNodes(), inactiveNodes);
        selector.announceNodes(ImmutableSet.of(currentNode), ImmutableSet.of(coordinator));
        allNodes = notifications.take();
        assertEquals(allNodes.getActiveNodes(), ImmutableSet.of(currentNode, coordinator));
        assertEquals(allNodes.getActiveCoordinators(), ImmutableSet.of(coordinator));
        selector.announceNodes(activeNodes, inactiveNodes);
        allNodes = notifications.take();
        assertEquals(allNodes.getActiveNodes(), activeNodes);
        assertEquals(allNodes.getInactiveNodes(), inactiveNodes);
    } finally {
        manager.stop();
    }
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Test(org.testng.annotations.Test)

Example 4 with NoOpFailureDetector

use of io.prestosql.failuredetector.NoOpFailureDetector in project hetu-core by openlookeng.

the class TestExchangeClient method testMarkers.

@Test
public void testMarkers() {
    DataSize maxResponseSize = new DataSize(10, Unit.MEGABYTE);
    MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
    URI location = URI.create("http://localhost:8080");
    String instanceId = "testing instance id";
    processor.addPage(location, createPage(1));
    MarkerPage marker = MarkerPage.snapshotPage(1);
    processor.addPage(location, marker);
    processor.addPage(location, createPage(2));
    processor.setComplete(location);
    @SuppressWarnings("resource") ExchangeClient exchangeClient = new ExchangeClient(new DataSize(32, Unit.MEGABYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), true, new TestingHttpClient(processor, scheduler), scheduler, new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), pageBufferClientCallbackExecutor, new NoOpFailureDetector());
    exchangeClient.setSnapshotEnabled(NOOP_SNAPSHOT_UTILS.getQuerySnapshotManager(new QueryId("query")));
    final String target1 = "target1";
    final String target2 = "target2";
    exchangeClient.addLocation(new TaskLocation(location, instanceId));
    exchangeClient.noMoreLocations();
    exchangeClient.addTarget(target1);
    exchangeClient.addTarget(target2);
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient, target1), createPage(1));
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient, target2), marker);
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient, target2), createPage(2));
    assertEquals(exchangeClient.isClosed(), false);
    // Target2 won't get any page, but because there are pending markers, it won't cause the client to close either
    assertTrue(exchangeClient.isBlocked().isDone());
    assertNull(getNextPage(exchangeClient, target2));
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient, target1), marker);
    // New target receives pending marker
    assertEquals(exchangeClient.isClosed(), false);
    final String target3 = "target3";
    exchangeClient.addTarget(target3);
    assertPageEquals(getNextPage(exchangeClient, target3), marker);
    assertFalse(exchangeClient.isBlocked().isDone());
    assertEquals(exchangeClient.isClosed(), false);
    exchangeClient.noMoreTargets();
    assertNull(getNextPage(exchangeClient));
    assertEquals(exchangeClient.isClosed(), true);
    ExchangeClientStatus status = exchangeClient.getStatus();
    assertEquals(status.getBufferedPages(), 0);
    assertEquals(status.getBufferedBytes(), 0);
    // client should have sent only 2 requests: one to get all pages and once to get the done signal
    assertStatus(status.getPageBufferClientStatuses().get(0), location, "closed", 3, 3, 3, "not scheduled");
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) MarkerPage(io.prestosql.spi.snapshot.MarkerPage) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) QueryId(io.prestosql.spi.QueryId) Duration(io.airlift.units.Duration) URI(java.net.URI) DataSize(io.airlift.units.DataSize) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) Test(org.testng.annotations.Test)

Example 5 with NoOpFailureDetector

use of io.prestosql.failuredetector.NoOpFailureDetector in project hetu-core by openlookeng.

the class TestExchangeClient method testClose.

@Test
public void testClose() throws Exception {
    DataSize maxResponseSize = new DataSize(1, Unit.BYTE);
    MockExchangeRequestProcessor processor = new MockExchangeRequestProcessor(maxResponseSize);
    URI location = URI.create("http://localhost:8080");
    String instanceId = "testing instance id";
    processor.addPage(location, createPage(1));
    processor.addPage(location, createPage(2));
    processor.addPage(location, createPage(3));
    @SuppressWarnings("resource") ExchangeClient exchangeClient = new ExchangeClient(new DataSize(1, Unit.BYTE), maxResponseSize, 1, new Duration(1, TimeUnit.MINUTES), true, new TestingHttpClient(processor, newCachedThreadPool(daemonThreadsNamed("test-%s"))), scheduler, new SimpleLocalMemoryContext(newSimpleAggregatedMemoryContext(), "test"), pageBufferClientCallbackExecutor, new NoOpFailureDetector());
    exchangeClient.addLocation(new TaskLocation(location, instanceId));
    exchangeClient.noMoreLocations();
    // fetch a page
    assertEquals(exchangeClient.isClosed(), false);
    assertPageEquals(getNextPage(exchangeClient), createPage(1));
    // close client while pages are still available
    exchangeClient.close();
    while (!exchangeClient.isFinished()) {
        MILLISECONDS.sleep(10);
    }
    assertEquals(exchangeClient.isClosed(), true);
    Pair<SerializedPage, String> pair = exchangeClient.pollPage(null);
    assertNotNull(pair);
    assertNull(pair.getLeft());
    assertEquals(exchangeClient.getStatus().getBufferedPages(), 0);
    assertEquals(exchangeClient.getStatus().getBufferedBytes(), 0);
    // client should have sent only 2 requests: one to get all pages and once to get the done signal
    PageBufferClientStatus clientStatus = exchangeClient.getStatus().getPageBufferClientStatuses().get(0);
    assertEquals(clientStatus.getUri(), location);
    assertEquals(clientStatus.getState(), "closed", "status");
    assertEquals(clientStatus.getHttpRequestState(), "not scheduled", "httpRequestState");
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) SimpleLocalMemoryContext(io.prestosql.memory.context.SimpleLocalMemoryContext) Duration(io.airlift.units.Duration) URI(java.net.URI) DataSize(io.airlift.units.DataSize) TestingHttpClient(io.airlift.http.client.testing.TestingHttpClient) SerializedPage(io.hetu.core.transport.execution.buffer.SerializedPage) Test(org.testng.annotations.Test)

Aggregations

NoOpFailureDetector (io.prestosql.failuredetector.NoOpFailureDetector)24 Test (org.testng.annotations.Test)20 TestingHttpClient (io.airlift.http.client.testing.TestingHttpClient)12 DataSize (io.airlift.units.DataSize)12 Duration (io.airlift.units.Duration)12 QueryId (io.prestosql.spi.QueryId)11 URI (java.net.URI)10 DynamicFilterService (io.prestosql.dynamicfilter.DynamicFilterService)9 QuerySnapshotManager (io.prestosql.snapshot.QuerySnapshotManager)9 LocalStateStoreProvider (io.prestosql.statestore.LocalStateStoreProvider)9 MockRemoteTaskFactory (io.prestosql.execution.MockRemoteTaskFactory)8 SqlStageExecution (io.prestosql.execution.SqlStageExecution)8 SqlStageExecution.createSqlStageExecution (io.prestosql.execution.SqlStageExecution.createSqlStageExecution)8 StageId (io.prestosql.execution.StageId)8 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)8 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)8 FinalizerService (io.prestosql.util.FinalizerService)7 NodeTaskMap (io.prestosql.execution.NodeTaskMap)6 TableInfo (io.prestosql.execution.TableInfo)6 SplitSchedulerStats (io.prestosql.execution.scheduler.SplitSchedulerStats)6