Search in sources :

Example 16 with ConnectorSplitSource

use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.

the class TestRaptorSplitManager method testAssignRandomNodeWhenBackupAvailable.

@Test
public void testAssignRandomNodeWhenBackupAvailable() throws InterruptedException, URISyntaxException {
    TestingNodeManager nodeManager = new TestingNodeManager();
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    PrestoNode node = new PrestoNode(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 = getFutureValue(partitionSplit.getNextBatch(1), PrestoException.class);
    assertEquals(getOnlyElement(getOnlyElement(batch).getAddresses()), node.getHostAndPort());
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) 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) PrestoNode(com.facebook.presto.metadata.PrestoNode) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) Test(org.testng.annotations.Test)

Example 17 with ConnectorSplitSource

use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.

the class TestRaptorSplitManager method testNoNodes.

@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "No nodes available to run query")
public void testNoNodes() throws InterruptedException, URISyntaxException {
    deleteShardNodes();
    RaptorSplitManager raptorSplitManagerWithBackup = new RaptorSplitManager(new RaptorConnectorId("fbraptor"), ImmutableSet::of, shardManager, true);
    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource splitSource = getSplits(raptorSplitManagerWithBackup, layout);
    getFutureValue(splitSource.getNextBatch(1000), PrestoException.class);
}
Also used : ImmutableSet(com.google.common.collect.ImmutableSet) ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) Test(org.testng.annotations.Test)

Example 18 with ConnectorSplitSource

use of com.facebook.presto.spi.ConnectorSplitSource in project presto by prestodb.

the class TestRaptorSplitManager method testNoHostForShard.

@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "No host for shard .* found: \\[\\]")
public void testNoHostForShard() throws InterruptedException {
    deleteShardNodes();
    ConnectorTableLayoutResult layout = getOnlyElement(metadata.getTableLayouts(SESSION, tableHandle, Constraint.alwaysTrue(), Optional.empty()));
    ConnectorSplitSource splitSource = getSplits(raptorSplitManager, layout);
    getFutureValue(splitSource.getNextBatch(1000));
}
Also used : ConnectorTableLayoutResult(com.facebook.presto.spi.ConnectorTableLayoutResult) ConnectorSplitSource(com.facebook.presto.spi.ConnectorSplitSource) Test(org.testng.annotations.Test)

Aggregations

ConnectorSplitSource (com.facebook.presto.spi.ConnectorSplitSource)18 Test (org.testng.annotations.Test)12 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)11 ColumnHandle (com.facebook.presto.spi.ColumnHandle)9 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)9 ConnectorSession (com.facebook.presto.spi.ConnectorSession)8 ConnectorTableLayoutHandle (com.facebook.presto.spi.ConnectorTableLayoutHandle)8 ConnectorSplitManager (com.facebook.presto.spi.connector.ConnectorSplitManager)8 ImmutableList (com.google.common.collect.ImmutableList)7 ImmutableMap (com.google.common.collect.ImmutableMap)7 List (java.util.List)7 SchemaTableName (com.facebook.presto.spi.SchemaTableName)6 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)6 TupleDomain (com.facebook.presto.spi.predicate.TupleDomain)6 GroupByHashPageIndexerFactory (com.facebook.presto.GroupByHashPageIndexerFactory)5 TYPE_MANAGER (com.facebook.presto.hive.HiveTestUtils.TYPE_MANAGER)5 HiveTestUtils.getDefaultHiveDataStreamFactories (com.facebook.presto.hive.HiveTestUtils.getDefaultHiveDataStreamFactories)5 HiveTestUtils.getDefaultHiveFileWriterFactories (com.facebook.presto.hive.HiveTestUtils.getDefaultHiveFileWriterFactories)5 HiveTestUtils.getDefaultHiveRecordCursorProvider (com.facebook.presto.hive.HiveTestUtils.getDefaultHiveRecordCursorProvider)5 HiveTestUtils.getTypes (com.facebook.presto.hive.HiveTestUtils.getTypes)5