Search in sources :

Example 71 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class NodePartitioningManager method getNodes.

public List<Node> getNodes(Session session, ConnectorId connectorId) {
    // Nodes returned by the node selector are already sorted based on nodeIdentifier. No need to sort again
    List<InternalNode> allNodes = nodeScheduler.createNodeSelector(session, connectorId).getAllNodes();
    ImmutableList.Builder<Node> nodeBuilder = ImmutableList.builder();
    int nodeCount = allNodes.size();
    for (int i = 0; i < nodeCount; i++) {
        InternalNode node = allNodes.get(i);
        if (node.getNodeStatus() == DEAD) {
            // Replace dead nodes with the first alive node to the right of it in the sorted node list
            int index = (i + 1) % nodeCount;
            while (node.getNodeStatus() == DEAD && index < nodeCount) {
                node = allNodes.get(index);
                index = (index + 1) % nodeCount;
            }
            nodeSelectionStats.incrementBucketedNonAliveNodeReplacedCount();
        }
        nodeBuilder.add(node);
    }
    return nodeBuilder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Node(com.facebook.presto.spi.Node) InternalNode(com.facebook.presto.metadata.InternalNode) InternalNode(com.facebook.presto.metadata.InternalNode)

Example 72 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class DistributedQueryRunner method isConnectorVisibleToAllNodes.

private boolean isConnectorVisibleToAllNodes(ConnectorId connectorId) {
    if (!externalWorkers.isEmpty()) {
        return true;
    }
    for (TestingPrestoServer server : servers) {
        server.refreshNodes();
        Set<InternalNode> activeNodesWithConnector = server.getActiveNodesWithConnector(connectorId);
        if (activeNodesWithConnector.size() != servers.size()) {
            return false;
        }
    }
    return true;
}
Also used : TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) InternalNode(com.facebook.presto.metadata.InternalNode)

Example 73 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class TestRaptorSplitManager method testAssignRandomNodeWhenBackupAvailable.

@Test
public void testAssignRandomNodeWhenBackupAvailable() throws URISyntaxException {
    TestingNodeManager nodeManager = new TestingNodeManager();
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    InternalNode node = new InternalNode(UUID.randomUUID().toString(), new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false);
    nodeManager.addNode(node);
    RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, true);
    deleteShardNodes();
    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource partitionSplit = getSplits(raptorSplitManagerWithBackup, layout);
    List<ConnectorSplit> batch = getSplits(partitionSplit, 1);
    assertEquals(getOnlyElement(((RaptorSplit) getOnlyElement(batch)).getAddresses()), node.getHostAndPort());
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) RaptorSplit(com.facebook.presto.raptor.RaptorSplit) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) InternalNode(com.facebook.presto.metadata.InternalNode) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) URI(java.net.URI) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) NodeSupplier(com.facebook.presto.raptor.NodeSupplier) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) Test(org.testng.annotations.Test)

Example 74 with InternalNode

use of com.facebook.presto.metadata.InternalNode in project presto by prestodb.

the class TestAssignmentLimiter method testNotEnoughNodes.

@Test
public void testNotEnoughNodes() throws Exception {
    TestingTicker ticker = new TestingTicker();
    HashSet<Node> nodes = new HashSet<>();
    Node node1 = new InternalNode("node1", new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false);
    Node node2 = new InternalNode("node2", new URI("http://127.0.0.2/"), NodeVersion.UNKNOWN, false);
    nodes.add(node1);
    nodes.add(node2);
    AssignmentLimiter limiter = new AssignmentLimiter(() -> nodes, ticker, new Duration(0, SECONDS), new Duration(0, SECONDS), 2);
    ticker.increment(1, SECONDS);
    limiter.checkAssignFrom("node3");
    nodes.remove(node1);
    assertCheckFails(limiter, "node3", RAPTOR_NOT_ENOUGH_NODES);
}
Also used : TestingTicker(com.facebook.airlift.testing.TestingTicker) InternalNode(com.facebook.presto.metadata.InternalNode) Node(com.facebook.presto.spi.Node) Duration(io.airlift.units.Duration) InternalNode(com.facebook.presto.metadata.InternalNode) URI(java.net.URI) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

InternalNode (com.facebook.presto.metadata.InternalNode)74 Split (com.facebook.presto.metadata.Split)34 Test (org.testng.annotations.Test)34 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)25 HashSet (java.util.HashSet)24 ImmutableList (com.google.common.collect.ImmutableList)17 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)14 SplitPlacementResult (com.facebook.presto.execution.scheduler.SplitPlacementResult)13 NodeSelectionStats (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats)12 NodeSelector (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 SimpleTtlNodeSelectorConfig (com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig)11 ConnectorId (com.facebook.presto.spi.ConnectorId)11 TestingTransactionHandle (com.facebook.presto.testing.TestingTransactionHandle)11 Duration (io.airlift.units.Duration)11 URI (java.net.URI)11 Map (java.util.Map)11 RemoteTask (com.facebook.presto.execution.RemoteTask)10 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)10 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)9