Search in sources :

Example 1 with Node

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);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) FixedSplitSource(com.facebook.presto.spi.FixedSplitSource) Node(com.facebook.presto.spi.Node) ArrayList(java.util.ArrayList) Domain(com.facebook.presto.spi.predicate.Domain) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit)

Example 2 with Node

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();
}
Also used : Node(com.facebook.presto.spi.Node) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with Node

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();
}
Also used : Node(com.facebook.presto.spi.Node) PrestoException(com.facebook.presto.spi.PrestoException) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 4 with Node

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;
}
Also used : TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) Node(com.facebook.presto.spi.Node) PrestoNode(com.facebook.presto.metadata.PrestoNode)

Example 5 with Node

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;
}
Also used : Node(com.facebook.presto.spi.Node) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer)

Aggregations

Node (com.facebook.presto.spi.Node)39 Split (com.facebook.presto.metadata.Split)15 PrestoNode (com.facebook.presto.metadata.PrestoNode)14 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)14 Test (org.testng.annotations.Test)14 ImmutableList (com.google.common.collect.ImmutableList)11 HashSet (java.util.HashSet)11 ImmutableSet (com.google.common.collect.ImmutableSet)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 HostAddress (com.facebook.presto.spi.HostAddress)6 ImmutableCollectors.toImmutableSet (com.facebook.presto.util.ImmutableCollectors.toImmutableSet)6 PrestoException (com.facebook.presto.spi.PrestoException)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Set (java.util.Set)5 ConnectorId (com.facebook.presto.connector.ConnectorId)4 ACTIVE (com.facebook.presto.spi.NodeState.ACTIVE)4 PlanNodeId (com.facebook.presto.sql.planner.plan.PlanNodeId)4 ImmutableCollectors.toImmutableList (com.facebook.presto.util.ImmutableCollectors.toImmutableList)4 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)4