Search in sources :

Example 6 with ThrowingNodeTtlFetcherManager

use of com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager in project presto by prestodb.

the class TaskTestUtils method createTestingPlanner.

public static LocalExecutionPlanner createTestingPlanner() {
    MetadataManager metadata = MetadataManager.createTestMetadataManager();
    PageSourceManager pageSourceManager = new PageSourceManager();
    pageSourceManager.addConnectorPageSourceProvider(CONNECTOR_ID, new TestingPageSourceProvider());
    // we don't start the finalizer so nothing will be collected, which is ok for a test
    FinalizerService finalizerService = new FinalizerService();
    NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    NodePartitioningManager nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    PageFunctionCompiler pageFunctionCompiler = new PageFunctionCompiler(metadata, 0);
    return new LocalExecutionPlanner(metadata, Optional.empty(), pageSourceManager, new IndexManager(), partitioningProviderManager, nodePartitioningManager, new PageSinkManager(), new ConnectorMetadataUpdaterManager(), new ExpressionCompiler(metadata, pageFunctionCompiler), pageFunctionCompiler, new JoinFilterFunctionCompiler(metadata), new IndexJoinLookupStats(), new TaskManagerConfig(), new MemoryManagerConfig(), new GenericSpillerFactory((types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }), (types, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, (types, partitionFunction, spillContext, memoryContext) -> {
        throw new UnsupportedOperationException();
    }, new BlockEncodingManager(), new PagesIndex.TestingFactory(false), new JoinCompiler(MetadataManager.createTestMetadataManager(), new FeaturesConfig()), new LookupJoinOperators(), new OrderingCompiler(), jsonCodec(TableCommitContext.class), new RowExpressionDeterminismEvaluator(metadata), new NoOpFragmentResultCacheManager(), new ObjectMapper(), (session) -> {
        throw new UnsupportedOperationException();
    });
}
Also used : WarningCollector(com.facebook.presto.spi.WarningCollector) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) MetadataManager(com.facebook.presto.metadata.MetadataManager) VariableReferenceExpression(com.facebook.presto.spi.relation.VariableReferenceExpression) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) EventListenerManager(com.facebook.presto.eventlistener.EventListenerManager) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) TableWriteInfo(com.facebook.presto.execution.scheduler.TableWriteInfo) PagesIndex(com.facebook.presto.operator.PagesIndex) StageExecutionDescriptor(com.facebook.presto.operator.StageExecutionDescriptor) PlanFragment(com.facebook.presto.sql.planner.PlanFragment) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) NoOpFragmentResultCacheManager(com.facebook.presto.operator.NoOpFragmentResultCacheManager) FinalizerService(com.facebook.presto.util.FinalizerService) JsonObjectMapperProvider(com.facebook.airlift.json.JsonObjectMapperProvider) PartitioningScheme(com.facebook.presto.sql.planner.PartitioningScheme) URI(java.net.URI) PageFunctionCompiler(com.facebook.presto.sql.gen.PageFunctionCompiler) ConnectorMetadataUpdaterManager(com.facebook.presto.metadata.ConnectorMetadataUpdaterManager) ImmutableSet(com.google.common.collect.ImmutableSet) PageSinkManager(com.facebook.presto.split.PageSinkManager) ImmutableMap(com.google.common.collect.ImmutableMap) ResourceGroupId(com.facebook.presto.spi.resourceGroups.ResourceGroupId) JsonCodec.jsonCodec(com.facebook.airlift.json.JsonCodec.jsonCodec) SOURCE_DISTRIBUTION(com.facebook.presto.sql.planner.SystemPartitioningHandle.SOURCE_DISTRIBUTION) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) List(java.util.List) Optional(java.util.Optional) ConnectorId(com.facebook.presto.spi.ConnectorId) AllowAllAccessControl(com.facebook.presto.security.AllowAllAccessControl) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanNodeId(com.facebook.presto.spi.plan.PlanNodeId) OutputBuffers(com.facebook.presto.execution.buffer.OutputBuffers) SINGLE_DISTRIBUTION(com.facebook.presto.sql.planner.SystemPartitioningHandle.SINGLE_DISTRIBUTION) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) TestingSplit(com.facebook.presto.testing.TestingSplit) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) TEST_SESSION(com.facebook.presto.SessionTestUtils.TEST_SESSION) ImmutableList(com.google.common.collect.ImmutableList) PageSourceManager(com.facebook.presto.split.PageSourceManager) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) BlockEncodingManager(com.facebook.presto.common.block.BlockEncodingManager) GenericSpillerFactory(com.facebook.presto.spiller.GenericSpillerFactory) IndexManager(com.facebook.presto.index.IndexManager) TableHandle(com.facebook.presto.spi.TableHandle) MemoryManagerConfig(com.facebook.presto.memory.MemoryManagerConfig) PlanFragmentId(com.facebook.presto.sql.planner.plan.PlanFragmentId) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) TransactionManager(com.facebook.presto.transaction.TransactionManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) Partitioning(com.facebook.presto.sql.planner.Partitioning) BIGINT(com.facebook.presto.common.type.BigintType.BIGINT) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) TableCommitContext(com.facebook.presto.operator.TableCommitContext) SplitMonitor(com.facebook.presto.event.SplitMonitor) Executor(java.util.concurrent.Executor) Session(com.facebook.presto.Session) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JoinFilterFunctionCompiler(com.facebook.presto.sql.gen.JoinFilterFunctionCompiler) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) TupleDomain(com.facebook.presto.common.predicate.TupleDomain) TestingColumnHandle(com.facebook.presto.testing.TestingMetadata.TestingColumnHandle) TableScanNode(com.facebook.presto.spi.plan.TableScanNode) StatsAndCosts(com.facebook.presto.cost.StatsAndCosts) Split(com.facebook.presto.metadata.Split) TestingTableHandle(com.facebook.presto.testing.TestingMetadata.TestingTableHandle) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) PageFunctionCompiler(com.facebook.presto.sql.gen.PageFunctionCompiler) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) TableCommitContext(com.facebook.presto.operator.TableCommitContext) PagesIndex(com.facebook.presto.operator.PagesIndex) PageSourceManager(com.facebook.presto.split.PageSourceManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) NoOpFragmentResultCacheManager(com.facebook.presto.operator.NoOpFragmentResultCacheManager) OrderingCompiler(com.facebook.presto.sql.gen.OrderingCompiler) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) GenericSpillerFactory(com.facebook.presto.spiller.GenericSpillerFactory) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PageSinkManager(com.facebook.presto.split.PageSinkManager) LookupJoinOperators(com.facebook.presto.operator.LookupJoinOperators) JoinCompiler(com.facebook.presto.sql.gen.JoinCompiler) RowExpressionDeterminismEvaluator(com.facebook.presto.sql.relational.RowExpressionDeterminismEvaluator) LocalExecutionPlanner(com.facebook.presto.sql.planner.LocalExecutionPlanner) IndexJoinLookupStats(com.facebook.presto.operator.index.IndexJoinLookupStats) JoinFilterFunctionCompiler(com.facebook.presto.sql.gen.JoinFilterFunctionCompiler) MemoryManagerConfig(com.facebook.presto.memory.MemoryManagerConfig) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) IndexManager(com.facebook.presto.index.IndexManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) MetadataManager(com.facebook.presto.metadata.MetadataManager) BlockEncodingManager(com.facebook.presto.common.block.BlockEncodingManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) ConnectorMetadataUpdaterManager(com.facebook.presto.metadata.ConnectorMetadataUpdaterManager) ExpressionCompiler(com.facebook.presto.sql.gen.ExpressionCompiler)

Example 7 with ThrowingNodeTtlFetcherManager

use of com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager in project presto by prestodb.

the class TestCostCalculator method setUp.

@BeforeClass
public void setUp() {
    TaskCountEstimator taskCountEstimator = new TaskCountEstimator(() -> NUMBER_OF_NODES);
    costCalculatorUsingExchanges = new CostCalculatorUsingExchanges(taskCountEstimator);
    costCalculatorWithEstimatedExchanges = new CostCalculatorWithEstimatedExchanges(costCalculatorUsingExchanges, taskCountEstimator);
    session = testSessionBuilder().setCatalog("tpch").build();
    CatalogManager catalogManager = new CatalogManager();
    catalogManager.registerCatalog(createBogusTestingCatalog("tpch"));
    transactionManager = createTestTransactionManager(catalogManager);
    metadata = createTestMetadataManager(transactionManager, new FeaturesConfig());
    finalizerService = new FinalizerService();
    finalizerService.start();
    nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), new InMemoryNodeManager(), new NodeSelectionStats(), new NodeSchedulerConfig().setIncludeCoordinator(true), new NodeTaskMap(finalizerService), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    PartitioningProviderManager partitioningProviderManager = new PartitioningProviderManager();
    nodePartitioningManager = new NodePartitioningManager(nodeScheduler, partitioningProviderManager, new NodeSelectionStats());
    planFragmenter = new PlanFragmenter(metadata, nodePartitioningManager, new QueryManagerConfig(), new SqlParser(), new FeaturesConfig());
}
Also used : NodeTaskMap(com.facebook.presto.execution.NodeTaskMap) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) PartitioningProviderManager(com.facebook.presto.sql.planner.PartitioningProviderManager) SqlParser(com.facebook.presto.sql.parser.SqlParser) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) PlanFragmenter(com.facebook.presto.sql.planner.PlanFragmenter) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) NodePartitioningManager(com.facebook.presto.sql.planner.NodePartitioningManager) InMemoryNodeManager(com.facebook.presto.metadata.InMemoryNodeManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) FinalizerService(com.facebook.presto.util.FinalizerService) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with ThrowingNodeTtlFetcherManager

use of com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager in project presto by prestodb.

the class TestNodeScheduler method testAffinityAssignmentNotSupported.

@Test
public void testAffinityAssignmentNotSupported() {
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    TestingTransactionHandle transactionHandle = TestingTransactionHandle.create();
    NodeSchedulerConfig nodeSchedulerConfig = new NodeSchedulerConfig().setMaxSplitsPerNode(20).setIncludeCoordinator(false).setMaxPendingSplitsPerTask(10);
    LegacyNetworkTopology legacyNetworkTopology = new LegacyNetworkTopology();
    NodeScheduler nodeScheduler = new NodeScheduler(new NetworkLocationCache(legacyNetworkTopology), legacyNetworkTopology, nodeManager, new NodeSelectionStats(), nodeSchedulerConfig, nodeTaskMap, new Duration(0, SECONDS), new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    NodeSelector nodeSelector = nodeScheduler.createNodeSelector(session, CONNECTOR_ID, 2);
    Set<Split> splits = new HashSet<>();
    splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote(HostAddress.fromString("127.0.0.1:10"))));
    splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote(HostAddress.fromString("127.0.0.1:10"))));
    SplitPlacementResult splitPlacementResult = nodeSelector.computeAssignments(splits, ImmutableList.of());
    Set<InternalNode> internalNodes = splitPlacementResult.getAssignments().keySet();
    // Split doesn't support affinity schedule, fall back to random schedule
    assertEquals(internalNodes.size(), 2);
}
Also used : NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) NetworkLocationCache(com.facebook.presto.execution.scheduler.NetworkLocationCache) Duration(io.airlift.units.Duration) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) NodeSelector(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector) InternalNode(com.facebook.presto.metadata.InternalNode) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) SplitPlacementResult(com.facebook.presto.execution.scheduler.SplitPlacementResult) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 9 with ThrowingNodeTtlFetcherManager

use of com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager in project presto by prestodb.

the class TestNodeScheduler method testMaxTasksPerStageWittLimit.

@Test
public void testMaxTasksPerStageWittLimit() {
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    TestingTransactionHandle transactionHandle = TestingTransactionHandle.create();
    NodeSchedulerConfig nodeSchedulerConfig = new NodeSchedulerConfig().setMaxSplitsPerNode(20).setIncludeCoordinator(false).setMaxPendingSplitsPerTask(10);
    NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, new NodeSelectionStats(), nodeSchedulerConfig, nodeTaskMap, new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    NodeSelector nodeSelector = nodeScheduler.createNodeSelector(session, CONNECTOR_ID, 2);
    Set<Split> splits = new HashSet<>();
    splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote()));
    SplitPlacementResult splitPlacementResult = nodeSelector.computeAssignments(splits, ImmutableList.of());
    Set<InternalNode> internalNodes = splitPlacementResult.getAssignments().keySet();
    assertEquals(internalNodes.size(), 1);
    // adding one more split. Total 2
    splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote()));
    splitPlacementResult = nodeSelector.computeAssignments(splits, getRemoteTableScanTask(splitPlacementResult));
    Set<InternalNode> internalNodesSecondCall = splitPlacementResult.getAssignments().keySet();
    assertEquals(internalNodesSecondCall.size(), 2);
    assertTrue(internalNodesSecondCall.containsAll(internalNodes));
    // adding one more split. Total 3
    splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestSplitRemote()));
    splitPlacementResult = nodeSelector.computeAssignments(splits, getRemoteTableScanTask(splitPlacementResult));
    assertEquals(splitPlacementResult.getAssignments().keySet().size(), 2);
    assertEquals(splitPlacementResult.getAssignments().keySet(), internalNodesSecondCall);
}
Also used : NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) NodeSelector(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector) InternalNode(com.facebook.presto.metadata.InternalNode) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) SplitPlacementResult(com.facebook.presto.execution.scheduler.SplitPlacementResult) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Example 10 with ThrowingNodeTtlFetcherManager

use of com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager in project presto by prestodb.

the class TestNodeScheduler method testAffinityAssignmentWithConsistentHashingWithVirtualNodes.

@Test
public void testAffinityAssignmentWithConsistentHashingWithVirtualNodes() {
    NodeTaskMap nodeTaskMap = new NodeTaskMap(finalizerService);
    TestingTransactionHandle transactionHandle = TestingTransactionHandle.create();
    NodeSchedulerConfig nodeSchedulerConfig = new NodeSchedulerConfig().setNodeSelectionHashStrategy(CONSISTENT_HASHING).setMinVirtualNodeCount(5).setMaxSplitsPerNode(20).setIncludeCoordinator(false).setMaxPendingSplitsPerTask(10);
    NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, new NodeSelectionStats(), nodeSchedulerConfig, nodeTaskMap, new ThrowingNodeTtlFetcherManager(), new NoOpQueryManager(), new SimpleTtlNodeSelectorConfig());
    NodeSelector nodeSelector = nodeScheduler.createNodeSelector(session, CONNECTOR_ID, 3);
    Set<Split> splits = new HashSet<>();
    IntStream.range(0, 10).forEach(i -> splits.add(new Split(CONNECTOR_ID, transactionHandle, new TestAffinitySplitRemote(i))));
    InternalNode node1 = new InternalNode("other1", URI.create("http://127.0.0.1:11"), NodeVersion.UNKNOWN, false);
    InternalNode node2 = new InternalNode("other2", URI.create("http://127.0.0.1:12"), NodeVersion.UNKNOWN, false);
    InternalNode node3 = new InternalNode("other3", URI.create("http://127.0.0.1:13"), NodeVersion.UNKNOWN, false);
    InternalNode node4 = new InternalNode("other4", URI.create("http://127.0.0.1:14"), NodeVersion.UNKNOWN, false);
    // In setup node 1-3 are added to node manager
    // consistent hashing ring for nodes:
    // entry0 (-1907319920): node2
    // entry1 (-1028466245): node3
    // entry2 ( -546736344): node2
    // entry3 ( 1127574531): node3
    // entry4 ( 1166245243): node1
    // entry5 ( 2145381619): node1
    SplitPlacementResult splitPlacementResult = nodeSelector.computeAssignments(splits, ImmutableList.of());
    // hashing value for splits:
    // 0: -1962219106 -> entry0 -> node2
    // 1:   145569539 -> entry3 -> node3
    // 2: -1599101205 -> entry1 -> node3
    // 3:  -165119218 -> entry3 -> node3
    // 4:  1142216720 -> entry4 -> node1
    // 5:  1347620135 -> entry5 -> node1
    // 6:  1232195252 -> entry5 -> node1
    // 7:   427886318 -> entry3 -> node3
    // 8:  1469878697 -> entry5 -> node1
    // 9:   296801082 -> entry3 -> node3
    assertEquals(splitPlacementResult.getAssignments().keySet().size(), 3);
    // node1: split 4, 5, 6, 8
    Collection<ConnectorSplit> node1Splits = splitPlacementResult.getAssignments().get(node1).stream().map(Split::getConnectorSplit).collect(toImmutableSet());
    // node2: split 0
    Collection<Object> node2Splits = splitPlacementResult.getAssignments().get(node2).stream().map(Split::getConnectorSplit).collect(toImmutableSet());
    // node3: split 1, 2, 3, 7, 9
    Collection<Object> node3Splits = splitPlacementResult.getAssignments().get(node3).stream().map(Split::getConnectorSplit).collect(toImmutableSet());
    // Scheduling the same splits on the same set of nodes should give the same assignment
    nodeSelector = nodeScheduler.createNodeSelector(session, CONNECTOR_ID, 3);
    splitPlacementResult = nodeSelector.computeAssignments(splits, ImmutableList.of());
    assertEquals(splitPlacementResult.getAssignments().get(node1).stream().map(Split::getConnectorSplit).collect(toImmutableSet()), node1Splits);
    assertEquals(splitPlacementResult.getAssignments().get(node2).stream().map(Split::getConnectorSplit).collect(toImmutableSet()), node2Splits);
    assertEquals(splitPlacementResult.getAssignments().get(node3).stream().map(Split::getConnectorSplit).collect(toImmutableSet()), node3Splits);
    // Adding node4, consistent hashing ring for nodes:
    // entry0 (-1907319920): node2
    // entry1 (-1616890413): node4
    // entry2 (-1028466245): node3
    // entry3 ( -546736344): node2
    // entry4 ( 1127574531): node3
    // entry5 ( 1166245243): node1
    // entry6 ( 1691928386): node4
    // entry7 ( 2145381619): node1
    nodeManager.addNode(CONNECTOR_ID, node4);
    nodeSelector = nodeScheduler.createNodeSelector(session, CONNECTOR_ID, 3);
    splitPlacementResult = nodeSelector.computeAssignments(splits, ImmutableList.of());
    // hashing value for splits:
    // 0: -1962219106 -> entry0 -> node2
    // 1:   145569539 -> entry4 -> node3
    // 2: -1599101205 -> entry2 -> node3
    // 3:  -165119218 -> entry4 -> node3
    // 4:  1142216720 -> entry5 -> node1
    // 5:  1347620135 -> entry6 -> node4
    // 6:  1232195252 -> entry6 -> node4
    // 7:   427886318 -> entry4 -> node3
    // 8:  1469878697 -> entry6 -> node4
    // 9:   296801082 -> entry4 -> node3
    assertEquals(splitPlacementResult.getAssignments().keySet().size(), 4);
    assertEquals(splitPlacementResult.getAssignments().get(node1).stream().map(Split::getConnectorSplit).map(ConnectorSplit::getSplitIdentifier).collect(toImmutableSet()), ImmutableSet.of(4));
    assertEquals(splitPlacementResult.getAssignments().get(node2).stream().map(Split::getConnectorSplit).collect(toImmutableSet()), node2Splits);
    assertEquals(splitPlacementResult.getAssignments().get(node3).stream().map(Split::getConnectorSplit).map(ConnectorSplit::getSplitIdentifier).collect(toImmutableSet()), ImmutableSet.of(1, 2, 3, 7, 9));
    assertEquals(splitPlacementResult.getAssignments().get(node4).stream().map(Split::getConnectorSplit).map(ConnectorSplit::getSplitIdentifier).collect(toImmutableSet()), ImmutableSet.of(5, 6, 8));
}
Also used : NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) ThrowingNodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager) NoOpQueryManager(com.facebook.presto.dispatcher.NoOpQueryManager) NodeSelectionStats(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats) LegacyNetworkTopology(com.facebook.presto.execution.scheduler.LegacyNetworkTopology) NodeScheduler(com.facebook.presto.execution.scheduler.NodeScheduler) TestingTransactionHandle(com.facebook.presto.testing.TestingTransactionHandle) NodeSelector(com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector) InternalNode(com.facebook.presto.metadata.InternalNode) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) Split(com.facebook.presto.metadata.Split) SplitPlacementResult(com.facebook.presto.execution.scheduler.SplitPlacementResult) ConnectorSplit(com.facebook.presto.spi.ConnectorSplit) SimpleTtlNodeSelectorConfig(com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig) HashSet(java.util.HashSet) Test(org.testng.annotations.Test)

Aggregations

NoOpQueryManager (com.facebook.presto.dispatcher.NoOpQueryManager)13 NodeSelectionStats (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelectionStats)13 SimpleTtlNodeSelectorConfig (com.facebook.presto.execution.scheduler.nodeSelection.SimpleTtlNodeSelectorConfig)13 ThrowingNodeTtlFetcherManager (com.facebook.presto.ttl.nodettlfetchermanagers.ThrowingNodeTtlFetcherManager)13 NodeScheduler (com.facebook.presto.execution.scheduler.NodeScheduler)11 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)11 LegacyNetworkTopology (com.facebook.presto.execution.scheduler.LegacyNetworkTopology)10 Split (com.facebook.presto.metadata.Split)9 TestingTransactionHandle (com.facebook.presto.testing.TestingTransactionHandle)9 Test (org.testng.annotations.Test)9 NodeSelector (com.facebook.presto.execution.scheduler.nodeSelection.NodeSelector)8 InternalNode (com.facebook.presto.metadata.InternalNode)8 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)8 HashSet (java.util.HashSet)8 SplitPlacementResult (com.facebook.presto.execution.scheduler.SplitPlacementResult)7 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)6 NetworkLocationCache (com.facebook.presto.execution.scheduler.NetworkLocationCache)3 FinalizerService (com.facebook.presto.util.FinalizerService)3 ImmutableList (com.google.common.collect.ImmutableList)3 NodeTaskMap (com.facebook.presto.execution.NodeTaskMap)2