use of com.facebook.presto.raptor.NodeSupplier in project presto by prestodb.
the class TestRaptorSplitManager method setup.
@BeforeMethod
public void setup() throws Exception {
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
DBI dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime() + "_" + ThreadLocalRandom.current().nextInt());
dbi.registerMapper(new TableColumn.Mapper(functionAndTypeManager));
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 InternalNode(nodeName, new URI("http://127.0.0.1/"), NodeVersion.UNKNOWN, false));
RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
metadata = new RaptorMetadata(connectorId.toString(), dbi, shardManager, createTestFunctionAndTypeManager());
metadata.createTable(SESSION, TEST_TABLE, false);
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);
}
use of com.facebook.presto.raptor.NodeSupplier in project presto by prestodb.
the class TestBucketBalancer method setup.
@BeforeMethod
public void setup() {
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime() + "_" + ThreadLocalRandom.current().nextInt());
dbi.registerMapper(new Distribution.Mapper(functionAndTypeManager));
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), 0, true, true, "test");
}
use of com.facebook.presto.raptor.NodeSupplier in project presto by prestodb.
the class TestRaptorMetadata method setupDatabase.
@BeforeMethod
public void setupDatabase() {
FunctionAndTypeManager functionAndTypeManager = createTestFunctionAndTypeManager();
dbi = new DBI("jdbc:h2:mem:test" + System.nanoTime() + "_" + ThreadLocalRandom.current().nextInt());
dbi.registerMapper(new TableColumn.Mapper(functionAndTypeManager));
dbi.registerMapper(new Distribution.Mapper(functionAndTypeManager));
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, createTestFunctionAndTypeManager());
}
use of com.facebook.presto.raptor.NodeSupplier in project presto by prestodb.
the class TestRaptorSplitManager method testAssignRandomNodeWhenBackupAvailable.
@Test
public void testAssignRandomNodeWhenBackupAvailable() throws URISyntaxException {
TestingNodeManager nodeManager = new TestingNodeManager();
RaptorConnectorId connectorId = new RaptorConnectorId("raptor");
NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
InternalNode node = new InternalNode(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 = getSplits(partitionSplit, 1);
assertEquals(getOnlyElement(((RaptorSplit) getOnlyElement(batch)).getAddresses()), node.getHostAndPort());
}
Aggregations