Search in sources :

Example 1 with RaptorSplitManager

use of com.facebook.presto.raptor.RaptorSplitManager in project presto by prestodb.

the class TestRaptorSplitManager method setup.

@BeforeMethod
public void setup() throws Exception {
    TypeRegistry typeRegistry = new TypeRegistry();
    DBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dbi.registerMapper(new TableColumn.Mapper(typeRegistry));
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    temporary = createTempDir();
    AssignmentLimiter assignmentLimiter = new AssignmentLimiter(ImmutableSet::of, systemTicker(), new MetadataConfig());
    shardManager = new DatabaseShardManager(dbi, new DaoSupplier<>(dbi, ShardDao.class), ImmutableSet::of, assignmentLimiter, systemTicker(), new Duration(0, MINUTES));
    TestingNodeManager nodeManager = new TestingNodeManager();
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    String nodeName = UUID.randomUUID().toString();
    nodeManager.addNode(new PrestoNode(nodeName, new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false));
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    metadata = new RaptorMetadata(connectorId.toString(), dbi, shardManager);
    metadata.createTable(SESSION, TEST_TABLE);
    tableHandle = metadata.getTableHandle(SESSION, TEST_TABLE.getTable());
    List<ShardInfo> shards = ImmutableList.<ShardInfo>builder().add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).add(shardInfo(UUID.randomUUID(), nodeName)).build();
    tableId = ((RaptorTableHandle) tableHandle).getTableId();
    List<ColumnInfo> columns = metadata.getColumnHandles(SESSION, tableHandle).values().stream().map(RaptorColumnHandle.class::cast).map(ColumnInfo::fromHandle).collect(toList());
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, columns, shards, Optional.empty(), 0);
    raptorSplitManager = new RaptorSplitManager(connectorId, nodeSupplier, shardManager, false);
}
Also used : RaptorColumnHandle(com.facebook.presto.raptor.RaptorColumnHandle) RaptorMetadata(com.facebook.presto.raptor.RaptorMetadata) DBI(org.skife.jdbi.v2.DBI) Duration(io.airlift.units.Duration) DaoSupplier(com.facebook.presto.raptor.util.DaoSupplier) TypeRegistry(com.facebook.presto.type.TypeRegistry) URI(java.net.URI) PrestoNode(com.facebook.presto.metadata.PrestoNode) ImmutableSet(com.google.common.collect.ImmutableSet) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) NodeSupplier(com.facebook.presto.raptor.NodeSupplier) RaptorSplitManager(com.facebook.presto.raptor.RaptorSplitManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with RaptorSplitManager

use of com.facebook.presto.raptor.RaptorSplitManager 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 3 with RaptorSplitManager

use of com.facebook.presto.raptor.RaptorSplitManager 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)

Aggregations

RaptorConnectorId (com.facebook.presto.raptor.RaptorConnectorId)3 RaptorSplitManager (com.facebook.presto.raptor.RaptorSplitManager)3 PrestoNode (com.facebook.presto.metadata.PrestoNode)2 NodeSupplier (com.facebook.presto.raptor.NodeSupplier)2 ConnectorSplitSource (com.facebook.presto.spi.ConnectorSplitSource)2 ConnectorTableLayoutResult (com.facebook.presto.spi.ConnectorTableLayoutResult)2 TestingNodeManager (com.facebook.presto.testing.TestingNodeManager)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 URI (java.net.URI)2 Test (org.testng.annotations.Test)2 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)1 RaptorMetadata (com.facebook.presto.raptor.RaptorMetadata)1 DaoSupplier (com.facebook.presto.raptor.util.DaoSupplier)1 ConnectorSplit (com.facebook.presto.spi.ConnectorSplit)1 TypeRegistry (com.facebook.presto.type.TypeRegistry)1 Duration (io.airlift.units.Duration)1 DBI (org.skife.jdbi.v2.DBI)1 BeforeMethod (org.testng.annotations.BeforeMethod)1