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();
}
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;
}
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());
}
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);
}
Aggregations