Search in sources :

Example 1 with DaoSupplier

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

the class TestShardCleaner method setup.

@BeforeMethod
public void setup() throws IOException {
    dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    temporary = createTempDirectory(null);
    File directory = temporary.resolve("data").toFile();
    storageService = new FileStorageService(directory);
    storageService.start();
    File backupDirectory = temporary.resolve("backup").toFile();
    backupStore = new FileBackupStore(backupDirectory);
    ((FileBackupStore) backupStore).start();
    ticker = new TestingTicker();
    ShardCleanerConfig config = new ShardCleanerConfig();
    cleaner = new ShardCleaner(new DaoSupplier<>(dbi, H2ShardDao.class), "node1", true, ticker, storageService, Optional.of(backupStore), config.getMaxTransactionAge(), config.getTransactionCleanerInterval(), config.getLocalCleanerInterval(), config.getLocalCleanTime(), config.getBackupCleanerInterval(), config.getBackupCleanTime(), config.getBackupDeletionThreads(), config.getMaxCompletedTransactionAge());
}
Also used : FileBackupStore(io.trino.plugin.raptor.legacy.backup.FileBackupStore) TestingTicker(io.airlift.testing.TestingTicker) FileStorageService(io.trino.plugin.raptor.legacy.storage.FileStorageService) DaoSupplier(io.trino.plugin.raptor.legacy.util.DaoSupplier) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with DaoSupplier

use of io.trino.plugin.raptor.legacy.util.DaoSupplier 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 DaoSupplier

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

the class TestDatabaseShardManager method createShardManager.

public static ShardManager createShardManager(Jdbi dbi, NodeSupplier nodeSupplier, Ticker ticker) {
    DaoSupplier<ShardDao> shardDaoSupplier = new DaoSupplier<>(dbi, H2ShardDao.class);
    AssignmentLimiter assignmentLimiter = new AssignmentLimiter(nodeSupplier, ticker, new MetadataConfig());
    return new DatabaseShardManager(dbi, shardDaoSupplier, nodeSupplier, assignmentLimiter, ticker, new Duration(1, DAYS));
}
Also used : Duration(io.airlift.units.Duration) DaoSupplier(io.trino.plugin.raptor.legacy.util.DaoSupplier)

Aggregations

DaoSupplier (io.trino.plugin.raptor.legacy.util.DaoSupplier)3 Duration (io.airlift.units.Duration)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 TestingTicker (io.airlift.testing.TestingTicker)1 InternalNode (io.trino.metadata.InternalNode)1 CatalogName (io.trino.plugin.base.CatalogName)1 DatabaseTesting.createTestingJdbi (io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi)1 NodeSupplier (io.trino.plugin.raptor.legacy.NodeSupplier)1 RaptorColumnHandle (io.trino.plugin.raptor.legacy.RaptorColumnHandle)1 RaptorMetadata (io.trino.plugin.raptor.legacy.RaptorMetadata)1 RaptorSplitManager (io.trino.plugin.raptor.legacy.RaptorSplitManager)1 FileBackupStore (io.trino.plugin.raptor.legacy.backup.FileBackupStore)1 FileStorageService (io.trino.plugin.raptor.legacy.storage.FileStorageService)1 TestingNodeManager (io.trino.testing.TestingNodeManager)1 File (java.io.File)1 URI (java.net.URI)1 Jdbi (org.jdbi.v3.core.Jdbi)1