Search in sources :

Example 1 with ShardManager

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

the class TestRaptorStorageManager method createRaptorStorageManager.

public static RaptorStorageManager createRaptorStorageManager(Jdbi dbi, File temporary, int maxShardRows) {
    File directory = new File(temporary, "data");
    StorageService storageService = new FileStorageService(directory);
    storageService.start();
    File backupDirectory = new File(temporary, "backup");
    FileBackupStore fileBackupStore = new FileBackupStore(backupDirectory);
    fileBackupStore.start();
    Optional<BackupStore> backupStore = Optional.of(fileBackupStore);
    ShardManager shardManager = createShardManager(dbi);
    ShardRecoveryManager recoveryManager = new ShardRecoveryManager(storageService, backupStore, new TestingNodeManager(), shardManager, MISSING_SHARD_DISCOVERY, 10);
    return createRaptorStorageManager(storageService, backupStore, recoveryManager, new InMemoryShardRecorder(), maxShardRows, MAX_FILE_SIZE);
}
Also used : FileBackupStore(io.trino.plugin.raptor.legacy.backup.FileBackupStore) BackupStore(io.trino.plugin.raptor.legacy.backup.BackupStore) FileBackupStore(io.trino.plugin.raptor.legacy.backup.FileBackupStore) TestingNodeManager(io.trino.testing.TestingNodeManager) TestDatabaseShardManager.createShardManager(io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) FileAssert.assertFile(org.testng.FileAssert.assertFile) File(java.io.File)

Example 2 with ShardManager

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

the class TestShardMetadataRecordCursor method testSimple.

@Test
public void testSimple() {
    ShardManager shardManager = createShardManager(dbi);
    // Add shards to the table
    long tableId = 1;
    OptionalInt bucketNumber = OptionalInt.empty();
    UUID uuid1 = UUID.randomUUID();
    UUID uuid2 = UUID.randomUUID();
    UUID uuid3 = UUID.randomUUID();
    ShardInfo shardInfo1 = new ShardInfo(uuid1, bucketNumber, ImmutableSet.of("node1"), ImmutableList.of(), 1, 10, 100, 0x1234);
    ShardInfo shardInfo2 = new ShardInfo(uuid2, bucketNumber, ImmutableSet.of("node2"), ImmutableList.of(), 2, 20, 200, 0xCAFEBABEDEADBEEFL);
    ShardInfo shardInfo3 = new ShardInfo(uuid3, bucketNumber, ImmutableSet.of("node3"), ImmutableList.of(), 3, 30, 300, 0xFEDCBA0987654321L);
    List<ShardInfo> shards = ImmutableList.of(shardInfo1, shardInfo2, shardInfo3);
    long transactionId = shardManager.beginTransaction();
    shardManager.commitShards(transactionId, tableId, ImmutableList.of(new ColumnInfo(1, BIGINT), new ColumnInfo(2, DATE)), shards, Optional.empty(), 0);
    Slice schema = utf8Slice(DEFAULT_TEST_ORDERS.getSchemaName());
    Slice table = utf8Slice(DEFAULT_TEST_ORDERS.getTableName());
    DateTime date1 = DateTime.parse("2015-01-01T00:00");
    DateTime date2 = DateTime.parse("2015-01-02T00:00");
    TupleDomain<Integer> tupleDomain = TupleDomain.withColumnDomains(ImmutableMap.<Integer, Domain>builder().put(0, Domain.singleValue(createVarcharType(10), schema)).put(1, Domain.create(ValueSet.ofRanges(lessThanOrEqual(createVarcharType(10), table)), true)).put(8, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)).put(9, Domain.create(ValueSet.ofRanges(lessThanOrEqual(BIGINT, date1.getMillis()), greaterThan(BIGINT, date2.getMillis())), true)).buildOrThrow());
    List<MaterializedRow> actual;
    try (RecordCursor cursor = new ShardMetadataSystemTable(dbi).cursor(null, SESSION, tupleDomain)) {
        actual = getMaterializedResults(cursor, SHARD_METADATA.getColumns());
    }
    assertEquals(actual.size(), 3);
    List<MaterializedRow> expected = ImmutableList.of(new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid1.toString()), null, 100L, 10L, 1L, utf8Slice("0000000000001234"), null, null, null, null), new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid2.toString()), null, 200L, 20L, 2L, utf8Slice("cafebabedeadbeef"), null, null, null, null), new MaterializedRow(DEFAULT_PRECISION, schema, table, utf8Slice(uuid3.toString()), null, 300L, 30L, 3L, utf8Slice("fedcba0987654321"), null, null, null, null));
    assertEquals(actual, expected);
}
Also used : RecordCursor(io.trino.spi.connector.RecordCursor) ColumnInfo(io.trino.plugin.raptor.legacy.metadata.ColumnInfo) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) TestDatabaseShardManager.createShardManager(io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager) OptionalInt(java.util.OptionalInt) DateTime(org.joda.time.DateTime) Slice(io.airlift.slice.Slice) Slices.utf8Slice(io.airlift.slice.Slices.utf8Slice) UUID(java.util.UUID) Domain(io.trino.spi.predicate.Domain) TupleDomain(io.trino.spi.predicate.TupleDomain) MaterializedRow(io.trino.testing.MaterializedRow) ShardInfo(io.trino.plugin.raptor.legacy.metadata.ShardInfo) Test(org.testng.annotations.Test)

Example 3 with ShardManager

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

the class TestRaptorStorageManager method setup.

@BeforeMethod
public void setup() throws IOException {
    temporary = createTempDirectory(null);
    File directory = temporary.resolve("data").toFile();
    storageService = new FileStorageService(directory);
    storageService.start();
    File backupDirectory = temporary.resolve("backup").toFile();
    fileBackupStore = new FileBackupStore(backupDirectory);
    fileBackupStore.start();
    backupStore = Optional.of(fileBackupStore);
    Jdbi dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    ShardManager shardManager = createShardManager(dbi);
    Duration discoveryInterval = new Duration(5, TimeUnit.MINUTES);
    recoveryManager = new ShardRecoveryManager(storageService, backupStore, nodeManager, shardManager, discoveryInterval, 10);
    shardRecorder = new InMemoryShardRecorder();
}
Also used : FileBackupStore(io.trino.plugin.raptor.legacy.backup.FileBackupStore) DatabaseTesting.createTestingJdbi(io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi) Jdbi(org.jdbi.v3.core.Jdbi) TestDatabaseShardManager.createShardManager(io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) Duration(io.airlift.units.Duration) FileAssert.assertFile(org.testng.FileAssert.assertFile) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with ShardManager

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

the class TestShardRecovery method setup.

@BeforeMethod
public void setup() throws IOException {
    temporary = createTempDirectory(null);
    File directory = temporary.resolve("data").toFile();
    File backupDirectory = temporary.resolve("backup").toFile();
    backupStore = new FileBackupStore(backupDirectory);
    backupStore.start();
    storageService = new FileStorageService(directory);
    storageService.start();
    Jdbi dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    createTablesWithRetry(dbi);
    ShardManager shardManager = createShardManager(dbi);
    recoveryManager = createShardRecoveryManager(storageService, Optional.of(backupStore), shardManager);
}
Also used : FileBackupStore(io.trino.plugin.raptor.legacy.backup.FileBackupStore) DatabaseTesting.createTestingJdbi(io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi) Jdbi(org.jdbi.v3.core.Jdbi) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) TestDatabaseShardManager.createShardManager(io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager) File(java.io.File) Files.createTempFile(java.nio.file.Files.createTempFile) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 5 with ShardManager

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

the class TestRaptorConnector method setup.

@BeforeMethod
public void setup() {
    Jdbi dbi = createTestingJdbi();
    dummyHandle = dbi.open();
    metadataDao = dbi.onDemand(MetadataDao.class);
    createTablesWithRetry(dbi);
    dataDir = Files.createTempDir();
    CatalogName connectorId = new CatalogName("test");
    NodeManager nodeManager = new TestingNodeManager();
    NodeSupplier nodeSupplier = nodeManager::getWorkerNodes;
    ShardManager shardManager = createShardManager(dbi);
    StorageManager storageManager = createRaptorStorageManager(dbi, dataDir);
    StorageManagerConfig config = new StorageManagerConfig();
    connector = new RaptorConnector(new LifeCycleManager(ImmutableList.of(), null), new TestingNodeManager(), new RaptorMetadataFactory(dbi, shardManager), new RaptorSplitManager(connectorId, nodeSupplier, shardManager, false), new RaptorPageSourceProvider(storageManager), new RaptorPageSinkProvider(storageManager, new PagesIndexPageSorter(new PagesIndex.TestingFactory(false)), config), new RaptorNodePartitioningProvider(nodeSupplier), new RaptorSessionProperties(config), new RaptorTableProperties(TESTING_TYPE_MANAGER), ImmutableSet.of(), Optional.empty(), dbi);
}
Also used : DatabaseTesting.createTestingJdbi(io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi) Jdbi(org.jdbi.v3.core.Jdbi) StorageManager(io.trino.plugin.raptor.legacy.storage.StorageManager) TestRaptorStorageManager.createRaptorStorageManager(io.trino.plugin.raptor.legacy.storage.TestRaptorStorageManager.createRaptorStorageManager) TestDatabaseShardManager.createShardManager(io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager) ShardManager(io.trino.plugin.raptor.legacy.metadata.ShardManager) StorageManagerConfig(io.trino.plugin.raptor.legacy.storage.StorageManagerConfig) NodeManager(io.trino.spi.NodeManager) TestingNodeManager(io.trino.testing.TestingNodeManager) PagesIndexPageSorter(io.trino.operator.PagesIndexPageSorter) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) TestingNodeManager(io.trino.testing.TestingNodeManager) CatalogName(io.trino.plugin.base.CatalogName) MetadataDao(io.trino.plugin.raptor.legacy.metadata.MetadataDao) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

ShardManager (io.trino.plugin.raptor.legacy.metadata.ShardManager)5 TestDatabaseShardManager.createShardManager (io.trino.plugin.raptor.legacy.metadata.TestDatabaseShardManager.createShardManager)5 DatabaseTesting.createTestingJdbi (io.trino.plugin.raptor.legacy.DatabaseTesting.createTestingJdbi)3 FileBackupStore (io.trino.plugin.raptor.legacy.backup.FileBackupStore)3 File (java.io.File)3 Jdbi (org.jdbi.v3.core.Jdbi)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 TestingNodeManager (io.trino.testing.TestingNodeManager)2 FileAssert.assertFile (org.testng.FileAssert.assertFile)2 LifeCycleManager (io.airlift.bootstrap.LifeCycleManager)1 Slice (io.airlift.slice.Slice)1 Slices.utf8Slice (io.airlift.slice.Slices.utf8Slice)1 Duration (io.airlift.units.Duration)1 PagesIndexPageSorter (io.trino.operator.PagesIndexPageSorter)1 CatalogName (io.trino.plugin.base.CatalogName)1 BackupStore (io.trino.plugin.raptor.legacy.backup.BackupStore)1 ColumnInfo (io.trino.plugin.raptor.legacy.metadata.ColumnInfo)1 MetadataDao (io.trino.plugin.raptor.legacy.metadata.MetadataDao)1 ShardInfo (io.trino.plugin.raptor.legacy.metadata.ShardInfo)1 StorageManager (io.trino.plugin.raptor.legacy.storage.StorageManager)1