Search in sources :

Example 1 with KEYSPACE

use of com.instaclustr.esop.backup.embedded.TestEntity.KEYSPACE in project esop by instaclustr.

the class AbstractBackupTest method inPlaceBackupRestoreTest.

public void inPlaceBackupRestoreTest(final String[][] arguments) throws Exception {
    Cassandra cassandra = null;
    try {
        cassandra = getCassandra(cassandraDir, CASSANDRA_VERSION);
        cassandra.start();
        List<Long> insertionTimes;
        try (CqlSession session = CqlSession.builder().build()) {
            insertionTimes = populateDatabaseWithBackup(session, arguments);
            assertEquals(insertionTimes.size(), NUMBER_OF_INSERTED_ROWS);
        }
        logger.info("Executing backup of commit logs {}", asList(arguments[3]));
        Esop.mainWithoutExit(arguments[3]);
        cassandra.stop();
        // RESTORE VERIFICATION
        cassandra = getCassandra(cassandraRestoredDir, CASSANDRA_VERSION, (workingDirectory, version) -> {
            try {
                FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data"));
                FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data2"));
                FileUtils.createDirectory(workingDirectory.resolve("data").resolve("data3"));
            } catch (final Exception ex) {
            // ignore
            }
            restoreOnStoppedNode(insertionTimes, arguments);
        });
        cassandra.start();
        waitForCql();
        try (CqlSession session = CqlSession.builder().build()) {
            dumpTableAndAssertRowCount(session, KEYSPACE, TABLE, NUMBER_OF_ROWS_AFTER_RESTORATION);
        }
    } finally {
        if (cassandra != null) {
            cassandra.stop();
        }
        deleteDirectory(Paths.get(target("commitlog_download_dir")));
        FileUtils.deleteDirectory(cassandraDir);
        FileUtils.deleteDirectory(cassandraRestoredDir);
    }
}
Also used : QueryBuilder.insertInto(com.datastax.oss.driver.api.querybuilder.QueryBuilder.insertInto) CassandraBuilder(com.github.nosan.embedded.cassandra.CassandraBuilder) OperationsModule(com.instaclustr.operations.OperationsModule) TIMEUUID(com.datastax.oss.driver.api.core.type.DataTypes.TIMEUUID) KEYSPACE_2(com.instaclustr.esop.backup.embedded.TestEntity2.KEYSPACE_2) IntStream.range(java.util.stream.IntStream.range) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) Date(java.util.Date) HashModule(com.instaclustr.esop.impl.hash.HashModule) LoggerFactory(org.slf4j.LoggerFactory) KEYSPACE(com.instaclustr.esop.backup.embedded.TestEntity.KEYSPACE) Arrays.asList(java.util.Arrays.asList) DATE(com.instaclustr.esop.backup.embedded.TestEntity.DATE) Path(java.nio.file.Path) CassandraModule(com.instaclustr.cassandra.CassandraModule) Awaitility.await(org.awaitility.Awaitility.await) Collection(java.util.Collection) ExecutorsModule(com.instaclustr.threading.ExecutorsModule) CassandraJMXServiceImpl(jmx.org.apache.cassandra.service.CassandraJMXServiceImpl) QueryBuilder.selectFrom(com.datastax.oss.driver.api.querybuilder.QueryBuilder.selectFrom) UUID(java.util.UUID) ImmutableMap.of(com.google.common.collect.ImmutableMap.of) String.format(java.lang.String.format) SchemaBuilder(com.datastax.oss.driver.api.querybuilder.SchemaBuilder) RestorationStrategyType(com.instaclustr.esop.impl.restore.RestorationStrategy.RestorationStrategyType) List(java.util.List) QueryBuilder.literal(com.datastax.oss.driver.api.querybuilder.QueryBuilder.literal) TABLE_3(com.instaclustr.esop.backup.embedded.TestEntity3.TABLE_3) TEXT(com.datastax.oss.driver.api.core.type.DataTypes.TEXT) CassandraJMXConnectionInfo(jmx.org.apache.cassandra.CassandraJMXConnectionInfo) TABLE(com.instaclustr.esop.backup.embedded.TestEntity.TABLE) ApiException(io.kubernetes.client.ApiException) Assert.assertEquals(org.testng.Assert.assertEquals) MINUTES(java.util.concurrent.TimeUnit.MINUTES) HashMap(java.util.HashMap) TABLE_2(com.instaclustr.esop.backup.embedded.TestEntity2.TABLE_2) ListModule(com.instaclustr.esop.impl.list.ListModule) Version(com.github.nosan.embedded.cassandra.Version) WorkingDirectoryCustomizer(com.github.nosan.embedded.cassandra.WorkingDirectoryCustomizer) ArrayList(java.util.ArrayList) BackupModule(com.instaclustr.esop.impl.backup.BackupModules.BackupModule) Cassandra(com.github.nosan.embedded.cassandra.Cassandra) KEYSPACE_3(com.instaclustr.esop.backup.embedded.TestEntity3.KEYSPACE_3) CqlSession(com.datastax.oss.driver.api.core.CqlSession) Objects.requireNonNull(java.util.Objects.requireNonNull) Row(com.datastax.oss.driver.api.core.cql.Row) UploadingModule(com.instaclustr.esop.impl.backup.BackupModules.UploadingModule) FileUtils(com.instaclustr.io.FileUtils) ID(com.instaclustr.esop.backup.embedded.TestEntity.ID) Uninterruptibles(com.google.common.util.concurrent.Uninterruptibles) CassandraSchemaVersion(com.instaclustr.esop.impl.interaction.CassandraSchemaVersion) RestorationStrategyModule(com.instaclustr.esop.impl.restore.RestoreModules.RestorationStrategyModule) Logger(org.slf4j.Logger) Esop(com.instaclustr.esop.cli.Esop) FileUtils.deleteDirectory(com.instaclustr.io.FileUtils.deleteDirectory) DataType(com.datastax.oss.driver.api.core.type.DataType) DownloadingModule(com.instaclustr.esop.impl.restore.RestoreModules.DownloadingModule) IOException(java.io.IOException) Uuids.timeBased(com.datastax.oss.driver.api.core.uuid.Uuids.timeBased) File(java.io.File) RemoveBackupModule(com.instaclustr.esop.impl.remove.RemoveBackupModule) Collectors.toList(java.util.stream.Collectors.toList) NAME(com.instaclustr.esop.backup.embedded.TestEntity.NAME) Paths(java.nio.file.Paths) RestoreModule(com.instaclustr.esop.impl.restore.RestoreModules.RestoreModule) SECONDS(java.util.concurrent.TimeUnit.SECONDS) AbstractModule(com.google.inject.AbstractModule) Cassandra(com.github.nosan.embedded.cassandra.Cassandra) CqlSession(com.datastax.oss.driver.api.core.CqlSession) ApiException(io.kubernetes.client.ApiException) IOException(java.io.IOException)

Aggregations

CqlSession (com.datastax.oss.driver.api.core.CqlSession)1 Row (com.datastax.oss.driver.api.core.cql.Row)1 DataType (com.datastax.oss.driver.api.core.type.DataType)1 TEXT (com.datastax.oss.driver.api.core.type.DataTypes.TEXT)1 TIMEUUID (com.datastax.oss.driver.api.core.type.DataTypes.TIMEUUID)1 Uuids.timeBased (com.datastax.oss.driver.api.core.uuid.Uuids.timeBased)1 QueryBuilder.insertInto (com.datastax.oss.driver.api.querybuilder.QueryBuilder.insertInto)1 QueryBuilder.literal (com.datastax.oss.driver.api.querybuilder.QueryBuilder.literal)1 QueryBuilder.selectFrom (com.datastax.oss.driver.api.querybuilder.QueryBuilder.selectFrom)1 SchemaBuilder (com.datastax.oss.driver.api.querybuilder.SchemaBuilder)1 Cassandra (com.github.nosan.embedded.cassandra.Cassandra)1 CassandraBuilder (com.github.nosan.embedded.cassandra.CassandraBuilder)1 Version (com.github.nosan.embedded.cassandra.Version)1 WorkingDirectoryCustomizer (com.github.nosan.embedded.cassandra.WorkingDirectoryCustomizer)1 ImmutableMap.of (com.google.common.collect.ImmutableMap.of)1 Uninterruptibles (com.google.common.util.concurrent.Uninterruptibles)1 AbstractModule (com.google.inject.AbstractModule)1 CassandraModule (com.instaclustr.cassandra.CassandraModule)1 DATE (com.instaclustr.esop.backup.embedded.TestEntity.DATE)1 ID (com.instaclustr.esop.backup.embedded.TestEntity.ID)1