Search in sources :

Example 1 with NoOpFailureDetector

use of com.facebook.presto.failureDetector.NoOpFailureDetector in project presto by prestodb.

the class TestDiscoveryNodeManager method testGetCurrentNode.

@Test
public void testGetCurrentNode() {
    NodeInfo nodeInfo = new NodeInfo(new NodeConfig().setEnvironment("test").setNodeId(currentNode.getNodeIdentifier()));
    DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), Optional.empty(), expectedVersion, testHttpClient, new TestingDriftClient<>(), internalCommunicationConfig);
    try {
        assertEquals(manager.getCurrentNode(), currentNode);
    } finally {
        manager.stop();
    }
}
Also used : NoOpFailureDetector(com.facebook.presto.failureDetector.NoOpFailureDetector) NodeInfo(com.facebook.airlift.node.NodeInfo) NodeConfig(com.facebook.airlift.node.NodeConfig) Test(org.testng.annotations.Test)

Example 2 with NoOpFailureDetector

use of com.facebook.presto.failureDetector.NoOpFailureDetector in project presto by prestodb.

the class TestDiscoveryNodeManager method testGetAllNodes.

@Test
public void testGetAllNodes() {
    DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), Optional.empty(), expectedVersion, testHttpClient, new TestingDriftClient<>(), internalCommunicationConfig);
    try {
        AllNodes allNodes = manager.getAllNodes();
        Set<InternalNode> activeNodes = allNodes.getActiveNodes();
        assertEqualsIgnoreOrder(activeNodes, this.activeNodes);
        for (InternalNode actual : activeNodes) {
            for (InternalNode expected : this.activeNodes) {
                assertNotSame(actual, expected);
            }
        }
        assertEqualsIgnoreOrder(activeNodes, manager.getNodes(ACTIVE));
        Set<InternalNode> inactiveNodes = allNodes.getInactiveNodes();
        assertEqualsIgnoreOrder(inactiveNodes, this.inactiveNodes);
        for (InternalNode actual : inactiveNodes) {
            for (InternalNode expected : this.inactiveNodes) {
                assertNotSame(actual, expected);
            }
        }
        assertEqualsIgnoreOrder(inactiveNodes, manager.getNodes(INACTIVE));
    } finally {
        manager.stop();
    }
}
Also used : NoOpFailureDetector(com.facebook.presto.failureDetector.NoOpFailureDetector) Test(org.testng.annotations.Test)

Example 3 with NoOpFailureDetector

use of com.facebook.presto.failureDetector.NoOpFailureDetector in project presto by prestodb.

the class TestDiscoveryNodeManager method testNodeChangeListener.

@Test(timeOut = 60000)
public void testNodeChangeListener() throws Exception {
    DiscoveryNodeManager manager = new DiscoveryNodeManager(selector, nodeInfo, new NoOpFailureDetector(), Optional.empty(), expectedVersion, testHttpClient, new TestingDriftClient<>(), internalCommunicationConfig);
    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(com.facebook.presto.failureDetector.NoOpFailureDetector) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) Test(org.testng.annotations.Test)

Example 4 with NoOpFailureDetector

use of com.facebook.presto.failureDetector.NoOpFailureDetector in project presto by prestodb.

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(new StageExecutionId(stageId, 0), createExchangePlanFragment(), new MockRemoteTaskFactory(executor, scheduledExecutor), TEST_SESSION, true, nodeTaskMap, executor, new NoOpFailureDetector(), new SplitSchedulerStats(), new TableWriteInfo(Optional.empty(), Optional.empty(), Optional.empty()));
    stage.setOutputBuffers(createInitialEmptyOutputBuffers(ARBITRARY));
    // add listener that fetches stage info when the final status is available
    SettableFuture<StageExecutionInfo> 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);
                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.getStageExecutionInfo().getTasks().isEmpty());
    stage.abort();
    // once the final stage info is available, verify that it is complete
    StageExecutionInfo stageInfo = finalStageInfo.get(1, MINUTES);
    assertFalse(stageInfo.getTasks().isEmpty());
    assertTrue(stageInfo.isFinal());
    assertSame(stage.getStageExecutionInfo(), stageInfo);
    // cancel the background thread adding tasks
    addTasksTask.cancel(true);
}
Also used : NoOpFailureDetector(com.facebook.presto.failureDetector.NoOpFailureDetector) TableWriteInfo(com.facebook.presto.execution.scheduler.TableWriteInfo) QueryId(com.facebook.presto.spi.QueryId) CountDownLatch(java.util.concurrent.CountDownLatch) SqlStageExecution.createSqlStageExecution(com.facebook.presto.execution.SqlStageExecution.createSqlStageExecution) SplitSchedulerStats(com.facebook.presto.execution.scheduler.SplitSchedulerStats) FinalizerService(com.facebook.presto.util.FinalizerService) InternalNode(com.facebook.presto.metadata.InternalNode)

Example 5 with NoOpFailureDetector

use of com.facebook.presto.failureDetector.NoOpFailureDetector in project presto by prestodb.

the class TestSourcePartitionedScheduler method createSqlStageExecution.

private SqlStageExecution createSqlStageExecution(SubPlan tableScanPlan, NodeTaskMap nodeTaskMap) {
    StageId stageId = new StageId(new QueryId("query"), 0);
    SqlStageExecution stage = SqlStageExecution.createSqlStageExecution(new StageExecutionId(stageId, 0), tableScanPlan.getFragment(), new MockRemoteTaskFactory(queryExecutor, scheduledExecutor), TEST_SESSION, true, nodeTaskMap, queryExecutor, new NoOpFailureDetector(), new SplitSchedulerStats(), new TableWriteInfo(Optional.empty(), Optional.empty(), Optional.empty()));
    stage.setOutputBuffers(createInitialEmptyOutputBuffers(PARTITIONED).withBuffer(OUT, 0).withNoMoreBufferIds());
    return stage;
}
Also used : NoOpFailureDetector(com.facebook.presto.failureDetector.NoOpFailureDetector) StageId(com.facebook.presto.execution.StageId) QueryId(com.facebook.presto.spi.QueryId) SqlStageExecution(com.facebook.presto.execution.SqlStageExecution) StageExecutionId(com.facebook.presto.execution.StageExecutionId) MockRemoteTaskFactory(com.facebook.presto.execution.MockRemoteTaskFactory)

Aggregations

NoOpFailureDetector (com.facebook.presto.failureDetector.NoOpFailureDetector)5 Test (org.testng.annotations.Test)3 QueryId (com.facebook.presto.spi.QueryId)2 NodeConfig (com.facebook.airlift.node.NodeConfig)1 NodeInfo (com.facebook.airlift.node.NodeInfo)1 MockRemoteTaskFactory (com.facebook.presto.execution.MockRemoteTaskFactory)1 SqlStageExecution (com.facebook.presto.execution.SqlStageExecution)1 SqlStageExecution.createSqlStageExecution (com.facebook.presto.execution.SqlStageExecution.createSqlStageExecution)1 StageExecutionId (com.facebook.presto.execution.StageExecutionId)1 StageId (com.facebook.presto.execution.StageId)1 SplitSchedulerStats (com.facebook.presto.execution.scheduler.SplitSchedulerStats)1 TableWriteInfo (com.facebook.presto.execution.scheduler.TableWriteInfo)1 InternalNode (com.facebook.presto.metadata.InternalNode)1 FinalizerService (com.facebook.presto.util.FinalizerService)1 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)1 CountDownLatch (java.util.concurrent.CountDownLatch)1