use of com.facebook.presto.raptor.metadata.MetadataDao in project presto by prestodb.
the class ShardOrganizationManager method runOrganization.
private void runOrganization(long tableId) {
Set<ShardMetadata> shardMetadatas = shardManager.getNodeShards(currentNodeIdentifier, tableId);
Table tableInfo = metadataDao.getTableInformation(tableId);
Set<ShardMetadata> filteredShards = shardMetadatas.stream().filter(shard -> !organizer.inProgress(shard.getShardUuid())).collect(toSet());
Collection<ShardIndexInfo> indexInfos = getOrganizationEligibleShards(dbi, metadataDao, tableInfo, filteredShards, true);
Set<OrganizationSet> organizationSets = createOrganizationSets(tableInfo, indexInfos);
if (organizationSets.isEmpty()) {
return;
}
log.info("Created %s organization set(s) from %s shards for table ID %s", organizationSets.size(), filteredShards.size(), tableId);
long lastStartTime = System.currentTimeMillis();
tablesInProgress.add(tableId);
ImmutableList.Builder<CompletableFuture<?>> futures = ImmutableList.builder();
for (OrganizationSet organizationSet : organizationSets) {
futures.add(organizer.enqueue(organizationSet));
}
allAsList(futures.build()).whenComplete((value, throwable) -> {
tablesInProgress.remove(tableId);
organizerDao.updateLastStartTime(currentNodeIdentifier, tableId, lastStartTime);
});
}
use of com.facebook.presto.raptor.metadata.MetadataDao in project presto by prestodb.
the class RaptorMetadata method renameTable.
@Override
public void renameTable(ConnectorSession session, ConnectorTableHandle tableHandle, SchemaTableName newTableName) {
RaptorTableHandle table = (RaptorTableHandle) tableHandle;
runTransaction(dbi, (handle, status) -> {
MetadataDao dao = handle.attach(MetadataDao.class);
dao.renameTable(table.getTableId(), newTableName.getSchemaName(), newTableName.getTableName());
return null;
});
}
use of com.facebook.presto.raptor.metadata.MetadataDao in project presto by prestodb.
the class TestRaptorConnector 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();
metadataDao = dbi.onDemand(MetadataDao.class);
createTablesWithRetry(dbi);
dataDir = Files.createTempDir();
RaptorConnectorId connectorId = new RaptorConnectorId("test");
NodeManager nodeManager = new TestingNodeManager();
NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
ShardManager shardManager = createShardManager(dbi);
StorageManager storageManager = createOrcStorageManager(dbi, dataDir);
StorageManagerConfig config = new StorageManagerConfig().setDataDirectory(dataDir);
connector = new RaptorConnector(new LifeCycleManager(ImmutableList.of(), null), new TestingNodeManager(), new RaptorMetadataFactory(connectorId, dbi, shardManager), new RaptorSplitManager(connectorId, nodeSupplier, shardManager, false), new RaptorPageSourceProvider(storageManager), new RaptorPageSinkProvider(storageManager, new PagesIndexPageSorter(new PagesIndex.TestingFactory()), config), new RaptorNodePartitioningProvider(nodeSupplier), new RaptorSessionProperties(config), new RaptorTableProperties(typeRegistry), ImmutableSet.of(), dbi);
}
use of com.facebook.presto.raptor.metadata.MetadataDao in project presto by prestodb.
the class TestBucketBalancer method createBucketedTable.
private long createBucketedTable(String tableName, long distributionId, DataSize compressedSize) {
MetadataDao dao = dbi.onDemand(MetadataDao.class);
long tableId = dao.insertTable("test", tableName, false, false, distributionId, 0);
List<ColumnInfo> columnsA = ImmutableList.of(new ColumnInfo(1, BIGINT));
shardManager.createTable(tableId, columnsA, false, OptionalLong.empty());
metadataDao.updateTableStats(tableId, 1024, 1024 * 1024 * 1024, compressedSize.toBytes(), compressedSize.toBytes() * 2);
return tableId;
}
use of com.facebook.presto.raptor.metadata.MetadataDao in project presto by prestodb.
the class TestBucketBalancer method setup.
@BeforeMethod
public void setup() throws Exception {
TypeRegistry typeRegistry = new TypeRegistry();
dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime());
dbi.registerMapper(new Distribution.Mapper(typeRegistry));
dummyHandle = dbi.open();
createTablesWithRetry(dbi);
metadataDao = dbi.onDemand(MetadataDao.class);
nodeManager = new TestingNodeManager(AVAILABLE_WORKERS.stream().map(TestBucketBalancer::createTestingNode).collect(Collectors.toList()));
NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
shardManager = createShardManager(dbi, nodeSupplier);
balancer = new BucketBalancer(nodeSupplier, shardManager, true, new Duration(1, DAYS), true, true, "test");
}
Aggregations