Search in sources :

Example 6 with TestingNodeManager

use of com.facebook.presto.testing.TestingNodeManager in project presto by prestodb.

the class TestRaptorMetadata method setupDatabase.

@BeforeMethod
public void setupDatabase() throws Exception {
    TypeRegistry typeRegistry = new TypeRegistry();
    dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dbi.registerMapper(new TableColumn.Mapper(typeRegistry));
    dbi.registerMapper(new Distribution.Mapper(typeRegistry));
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
    NodeManager nodeManager = new TestingNodeManager();
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    shardManager = createShardManager(dbi, nodeSupplier, systemTicker());
    metadata = new RaptorMetadata(connectorId.toString(), dbi, shardManager);
}
Also used : NodeManager(com.facebook.presto.spi.NodeManager) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) TestingNodeManager(com.facebook.presto.testing.TestingNodeManager) RaptorMetadata(com.facebook.presto.raptor.RaptorMetadata) DBI(org.skife.jdbi.v2.DBI) TypeRegistry(com.facebook.presto.type.TypeRegistry) RaptorConnectorId(com.facebook.presto.raptor.RaptorConnectorId) NodeSupplier(com.facebook.presto.raptor.NodeSupplier) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 7 with TestingNodeManager

use of com.facebook.presto.testing.TestingNodeManager 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)

Aggregations

TestingNodeManager (com.facebook.presto.testing.TestingNodeManager)7 NodeSupplier (com.facebook.presto.raptor.NodeSupplier)4 TypeRegistry (com.facebook.presto.type.TypeRegistry)4 DBI (org.skife.jdbi.v2.DBI)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 PrestoNode (com.facebook.presto.metadata.PrestoNode)3 RaptorConnectorId (com.facebook.presto.raptor.RaptorConnectorId)3 RaptorMetadata (com.facebook.presto.raptor.RaptorMetadata)2 RaptorSplitManager (com.facebook.presto.raptor.RaptorSplitManager)2 MetadataDao (com.facebook.presto.raptor.metadata.MetadataDao)2 ShardManager (com.facebook.presto.raptor.metadata.ShardManager)2 TestDatabaseShardManager.createShardManager (com.facebook.presto.raptor.metadata.TestDatabaseShardManager.createShardManager)2 NodeManager (com.facebook.presto.spi.NodeManager)2 Duration (io.airlift.units.Duration)2 URI (java.net.URI)2 PagesIndexPageSorter (com.facebook.presto.PagesIndexPageSorter)1 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)1 BackupStore (com.facebook.presto.raptor.backup.BackupStore)1 FileBackupStore (com.facebook.presto.raptor.backup.FileBackupStore)1 Distribution (com.facebook.presto.raptor.metadata.Distribution)1