Search in sources :

Example 1 with RaptorMetadata

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

the class TestShardOrganizerUtil method setup.

@BeforeMethod
public void setup() {
    dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    dbi.registerMapper(new TableColumn.Mapper(new TypeRegistry()));
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    dataDir = Files.createTempDir();
    metadata = new RaptorMetadata("raptor", dbi, createShardManager(dbi));
    metadataDao = dbi.onDemand(MetadataDao.class);
    shardManager = createShardManager(dbi);
}
Also used : RaptorMetadata(com.facebook.presto.raptor.RaptorMetadata) DBI(org.skife.jdbi.v2.DBI) TableColumn(com.facebook.presto.raptor.metadata.TableColumn) TypeRegistry(com.facebook.presto.type.TypeRegistry) MetadataDao(com.facebook.presto.raptor.metadata.MetadataDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with RaptorMetadata

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

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

the class TestShardMetadataRecordCursor method setup.

@BeforeMethod
public void setup() {
    this.dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
    this.dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    this.metadata = new RaptorMetadata("raptor", dbi, createShardManager(dbi));
    // Create table
    metadata.createTable(SESSION, tableMetadataBuilder(DEFAULT_TEST_ORDERS).column("orderkey", BIGINT).column("orderdate", DATE).property("temporal_column", "orderdate").build());
}
Also used : RaptorMetadata(com.facebook.presto.raptor.RaptorMetadata) IDBI(org.skife.jdbi.v2.IDBI) DBI(org.skife.jdbi.v2.DBI) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with RaptorMetadata

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

Aggregations

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