use of com.facebook.presto.spi.Node in project presto by prestodb.
the class AtopSplitManager method getSplits.
@Override
public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layoutHandle) {
AtopTableLayoutHandle handle = (AtopTableLayoutHandle) layoutHandle;
AtopTableHandle table = handle.getTableHandle();
List<ConnectorSplit> splits = new ArrayList<>();
ZonedDateTime end = ZonedDateTime.now(timeZone);
for (Node node : nodeManager.getWorkerNodes()) {
ZonedDateTime start = end.minusDays(maxHistoryDays - 1).withHour(0).withMinute(0).withSecond(0).withNano(0);
while (start.isBefore(end)) {
ZonedDateTime splitEnd = start.withHour(23).withMinute(59).withSecond(59).withNano(0);
Domain splitDomain = Domain.create(ValueSet.ofRanges(Range.range(TIMESTAMP_WITH_TIME_ZONE, 1000 * start.toEpochSecond(), true, 1000 * splitEnd.toEpochSecond(), true)), false);
if (handle.getStartTimeConstraint().overlaps(splitDomain) && handle.getEndTimeConstraint().overlaps(splitDomain)) {
splits.add(new AtopSplit(table.getTable(), node.getHostAndPort(), start.toEpochSecond(), start.getZone()));
}
start = start.plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
}
}
return new FixedSplitSource(splits);
}
use of com.facebook.presto.spi.Node in project presto by prestodb.
the class BlackHoleNodePartitioningProvider method getBucketToNode.
@Override
public Map<Integer, Node> getBucketToNode(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorPartitioningHandle partitioningHandle) {
Set<Node> nodes = nodeManager.getRequiredWorkerNodes();
// create on part per node
ImmutableMap.Builder<Integer, Node> distribution = ImmutableMap.builder();
int partNumber = 0;
for (Node node : nodes) {
distribution.put(partNumber, node);
partNumber++;
}
return distribution.build();
}
use of com.facebook.presto.spi.Node in project presto by prestodb.
the class RaptorNodePartitioningProvider method getBucketToNode.
@Override
public Map<Integer, Node> getBucketToNode(ConnectorTransactionHandle transaction, ConnectorSession session, ConnectorPartitioningHandle partitioning) {
RaptorPartitioningHandle handle = (RaptorPartitioningHandle) partitioning;
Map<String, Node> nodesById = uniqueIndex(nodeSupplier.getWorkerNodes(), Node::getNodeIdentifier);
ImmutableMap.Builder<Integer, Node> bucketToNode = ImmutableMap.builder();
for (Entry<Integer, String> entry : handle.getBucketToNode().entrySet()) {
Node node = nodesById.get(entry.getValue());
if (node == null) {
throw new PrestoException(NO_NODES_AVAILABLE, "Node for bucket is offline: " + entry.getValue());
}
bucketToNode.put(entry.getKey(), node);
}
return bucketToNode.build();
}
use of com.facebook.presto.spi.Node in project presto by prestodb.
the class TestShardEjector method createNodeManager.
private static NodeManager createNodeManager(String current, String... others) {
Node currentNode = createTestingNode(current);
TestingNodeManager nodeManager = new TestingNodeManager(currentNode);
for (String other : others) {
nodeManager.addNode(createTestingNode(other));
}
return nodeManager;
}
use of com.facebook.presto.spi.Node in project presto by prestodb.
the class DistributedQueryRunner method isConnectionVisibleToAllNodes.
private boolean isConnectionVisibleToAllNodes(ConnectorId connectorId) {
for (TestingPrestoServer server : servers) {
server.refreshNodes();
Set<Node> activeNodesWithConnector = server.getActiveNodesWithConnector(connectorId);
if (activeNodesWithConnector.size() != servers.size()) {
return false;
}
}
return true;
}
Aggregations