Search in sources :

Example 1 with MockLocationFactory

use of io.prestosql.execution.TestSqlTaskManager.MockLocationFactory in project hetu-core by openlookeng.

the class TestSqlStageExecution method testFinalStageInfoInternal.

private void testFinalStageInfoInternal() throws Exception {
    NodeTaskMap nodeTaskMap = new NodeTaskMap(new FinalizerService());
    StageId stageId = new StageId(new QueryId("query"), 0);
    SqlStageExecution stage = createSqlStageExecution(stageId, new MockLocationFactory().createStageLocation(stageId), createExchangePlanFragment(), ImmutableMap.of(), new MockRemoteTaskFactory(executor, scheduledExecutor), TEST_SESSION, true, nodeTaskMap, executor, new NoOpFailureDetector(), new SplitSchedulerStats(), new DynamicFilterService(new LocalStateStoreProvider(new SeedStoreManager(new FileSystemClientManager()))), new QuerySnapshotManager(stageId.getQueryId(), NOOP_SNAPSHOT_UTILS, TEST_SESSION));
    stage.setOutputBuffers(createInitialEmptyOutputBuffers(ARBITRARY));
    // add listener that fetches stage info when the final status is available
    SettableFuture<StageInfo> finalStageInfo = SettableFuture.create();
    stage.addFinalStageInfoListener(finalStageInfo::set);
    // in a background thread add a ton of tasks
    CountDownLatch latch = new CountDownLatch(1000);
    Future<?> addTasksTask = executor.submit(() -> {
        try {
            for (int i = 0; i < 1_000_000; i++) {
                if (Thread.interrupted()) {
                    return;
                }
                InternalNode node = new InternalNode("source" + i, URI.create("http://10.0.0." + (i / 10_000) + ":" + (i % 10_000)), NodeVersion.UNKNOWN, false);
                stage.scheduleTask(node, i, OptionalInt.empty());
                latch.countDown();
            }
        } finally {
            while (latch.getCount() > 0) {
                latch.countDown();
            }
        }
    });
    // wait for some tasks to be created, and then abort the query
    latch.await(1, MINUTES);
    assertFalse(stage.getStageInfo().getTasks().isEmpty());
    stage.abort();
    // once the final stage info is available, verify that it is complete
    StageInfo stageInfo = finalStageInfo.get(1, MINUTES);
    assertFalse(stageInfo.getTasks().isEmpty());
    assertTrue(stageInfo.isCompleteInfo());
    assertSame(stage.getStageInfo(), stageInfo);
    // cancel the background thread adding tasks
    addTasksTask.cancel(true);
}
Also used : NoOpFailureDetector(io.prestosql.failuredetector.NoOpFailureDetector) QueryId(io.prestosql.spi.QueryId) MockLocationFactory(io.prestosql.execution.TestSqlTaskManager.MockLocationFactory) CountDownLatch(java.util.concurrent.CountDownLatch) SqlStageExecution.createSqlStageExecution(io.prestosql.execution.SqlStageExecution.createSqlStageExecution) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) QuerySnapshotManager(io.prestosql.snapshot.QuerySnapshotManager) LocalStateStoreProvider(io.prestosql.statestore.LocalStateStoreProvider) SplitSchedulerStats(io.prestosql.execution.scheduler.SplitSchedulerStats) SeedStoreManager(io.prestosql.seedstore.SeedStoreManager) FinalizerService(io.prestosql.util.FinalizerService) DynamicFilterService(io.prestosql.dynamicfilter.DynamicFilterService) InternalNode(io.prestosql.metadata.InternalNode)

Aggregations

DynamicFilterService (io.prestosql.dynamicfilter.DynamicFilterService)1 SqlStageExecution.createSqlStageExecution (io.prestosql.execution.SqlStageExecution.createSqlStageExecution)1 MockLocationFactory (io.prestosql.execution.TestSqlTaskManager.MockLocationFactory)1 SplitSchedulerStats (io.prestosql.execution.scheduler.SplitSchedulerStats)1 NoOpFailureDetector (io.prestosql.failuredetector.NoOpFailureDetector)1 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)1 InternalNode (io.prestosql.metadata.InternalNode)1 SeedStoreManager (io.prestosql.seedstore.SeedStoreManager)1 QuerySnapshotManager (io.prestosql.snapshot.QuerySnapshotManager)1 QueryId (io.prestosql.spi.QueryId)1 LocalStateStoreProvider (io.prestosql.statestore.LocalStateStoreProvider)1 FinalizerService (io.prestosql.util.FinalizerService)1 CountDownLatch (java.util.concurrent.CountDownLatch)1