Search in sources :

Example 1 with NodeSupplier

use of io.trino.plugin.raptor.legacy.NodeSupplier in project trino by trinodb.

the class TestRaptorMetadata method setupDatabase.

@BeforeMethod
public void setupDatabase() {
    dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    NodeManager nodeManager = new TestingNodeManager();
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    shardManager = createShardManager(dbi, nodeSupplier, systemTicker());
    metadata = new RaptorMetadata(dbi, shardManager);
}
Also used : NodeManager(io.trino.spi.NodeManager) TestingNodeManager(io.trino.testing.TestingNodeManager) TestingNodeManager(io.trino.testing.TestingNodeManager) RaptorMetadata(io.trino.plugin.raptor.legacy.RaptorMetadata) NodeSupplier(io.trino.plugin.raptor.legacy.NodeSupplier) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with NodeSupplier

use of io.trino.plugin.raptor.legacy.NodeSupplier in project trino by trinodb.

the class TestRaptorSplitManager method setup.

@BeforeMethod
public void setup() throws Exception {
    Jdbi dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    temporary = createTempDirectory(null);
    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));
    CatalogName connectorId = new CatalogName("raptor");
    metadata = new RaptorMetadata(dbi, shardManager);
    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);
}
Also used : DatabaseTesting.createTestingJdbi(io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi) Jdbi(org.jdbi.v3.core.Jdbi) RaptorColumnHandle(io.trino.plugin.raptor.legacy.RaptorColumnHandle) RaptorMetadata(io.trino.plugin.raptor.legacy.RaptorMetadata) Duration(io.airlift.units.Duration) DaoSupplier(io.trino.plugin.raptor.legacy.util.DaoSupplier) URI(java.net.URI) ImmutableSet(com.google.common.collect.ImmutableSet) TestingNodeManager(io.trino.testing.TestingNodeManager) CatalogName(io.trino.plugin.base.CatalogName) InternalNode(io.trino.metadata.InternalNode) NodeSupplier(io.trino.plugin.raptor.legacy.NodeSupplier) RaptorSplitManager(io.trino.plugin.raptor.legacy.RaptorSplitManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with NodeSupplier

use of io.trino.plugin.raptor.legacy.NodeSupplier in project trino by trinodb.

the class TestRaptorSplitManager method testAssignRandomNodeWhenBackupAvailable.

@Test
public void testAssignRandomNodeWhenBackupAvailable() throws URISyntaxException {
    TestingNodeManager nodeManager = new TestingNodeManager();
    CatalogName connectorId = new CatalogName("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();
    ConnectorSplitSource partitionSplit = getSplits(raptorSplitManagerWithBackup, tableHandle);
    List<ConnectorSplit> batch = getSplits(partitionSplit, 1);
    assertEquals(getOnlyElement(getOnlyElement(batch).getAddresses()), node.getHostAndPort());
}
Also used : TestingNodeManager(io.trino.testing.TestingNodeManager) CatalogName(io.trino.plugin.base.CatalogName) InternalNode(io.trino.metadata.InternalNode) ConnectorSplitSource(io.trino.spi.connector.ConnectorSplitSource) URI(java.net.URI) ConnectorSplit(io.trino.spi.connector.ConnectorSplit) NodeSupplier(io.trino.plugin.raptor.legacy.NodeSupplier) RaptorSplitManager(io.trino.plugin.raptor.legacy.RaptorSplitManager) Test(org.testng.annotations.Test)

Example 4 with NodeSupplier

use of io.trino.plugin.raptor.legacy.NodeSupplier in project trino by trinodb.

the class TestBucketBalancer method setup.

@BeforeMethod
public void setup() {
    dbi = createTestingJdbi();
    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");
}
Also used : TestingNodeManager(io.trino.testing.TestingNodeManager) Duration(io.airlift.units.Duration) NodeSupplier(io.trino.plugin.raptor.legacy.NodeSupplier) MetadataDao(io.trino.plugin.raptor.legacy.metadata.MetadataDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

NodeSupplier (io.trino.plugin.raptor.legacy.NodeSupplier)4 TestingNodeManager (io.trino.testing.TestingNodeManager)4 BeforeMethod (org.testng.annotations.BeforeMethod)3 Duration (io.airlift.units.Duration)2 InternalNode (io.trino.metadata.InternalNode)2 CatalogName (io.trino.plugin.base.CatalogName)2 RaptorMetadata (io.trino.plugin.raptor.legacy.RaptorMetadata)2 RaptorSplitManager (io.trino.plugin.raptor.legacy.RaptorSplitManager)2 URI (java.net.URI)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 DatabaseTesting.createTestingJdbi (io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi)1 RaptorColumnHandle (io.trino.plugin.raptor.legacy.RaptorColumnHandle)1 MetadataDao (io.trino.plugin.raptor.legacy.metadata.MetadataDao)1 DaoSupplier (io.trino.plugin.raptor.legacy.util.DaoSupplier)1 NodeManager (io.trino.spi.NodeManager)1 ConnectorSplit (io.trino.spi.connector.ConnectorSplit)1 ConnectorSplitSource (io.trino.spi.connector.ConnectorSplitSource)1 Jdbi (org.jdbi.v3.core.Jdbi)1 Test (org.testng.annotations.Test)1