Search in sources :

Example 1 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class BaseBackupOperationCoordinator method coordinate.

@Override
public void coordinate(final Operation<BackupOperationRequest> operation) {
    final BackupOperationRequest request = operation.request;
    logger.info(request.toString());
    try {
        assert cassandraJMXService != null;
        assert backuperFactoryMap != null;
        assert bucketServiceFactoryMap != null;
        assert objectMapper != null;
        if (!request.skipBucketVerification) {
            try (final BucketService bucketService = bucketServiceFactoryMap.get(request.storageLocation.storageProvider).createBucketService(request)) {
                bucketService.checkBucket(request.storageLocation.bucket, request.createMissingBucket);
            }
        }
        final CassandraData cassandraData = CassandraData.parse(request.dataDirs.get(0));
        cassandraData.setDatabaseEntitiesFromRequest(request.entities);
        final List<String> tokens = new CassandraTokens(cassandraJMXService).act();
        logger.info("Tokens {}", tokens);
        if (!Snapshots.snapshotContainsTimestamp(operation.request.snapshotTag)) {
            if (operation.request.schemaVersion == null) {
                operation.request.schemaVersion = new CassandraSchemaVersion(cassandraJMXService).act();
            }
            operation.request.snapshotTag = resolveSnapshotTag(operation.request, System.currentTimeMillis());
        }
        logger.info("Taking snapshot with name {}", request.snapshotTag);
        new TakeSnapshotOperation(cassandraJMXService, new TakeSnapshotOperationRequest(request.entities, request.snapshotTag), cassandraVersionProvider).run0();
        Snapshots.hashSpec = hashSpec;
        final Snapshots snapshots = Snapshots.parse(request.dataDirs, request.snapshotTag);
        final Optional<Snapshot> snapshot = snapshots.get(request.snapshotTag);
        if (!snapshot.isPresent()) {
            throw new IllegalStateException(format("There is not any snapshot of tag %s", request.snapshotTag));
        }
        final Manifest manifest = Manifest.from(snapshot.get());
        manifest.setSchemaVersion(request.schemaVersion);
        manifest.setTokens(tokens);
        // manifest
        final Path localManifestPath = getLocalManifestPath(request.snapshotTag);
        Manifest.write(manifest, localManifestPath, objectMapper);
        manifest.setManifest(getManifestAsManifestEntry(localManifestPath));
        try (final Backuper backuper = backuperFactoryMap.get(request.storageLocation.storageProvider).createBackuper(request)) {
            final List<ManifestEntry> manifestEntries = manifest.getManifestEntries();
            Session<UploadUnit> uploadSession = null;
            try {
                uploadSession = uploadTracker.submit(backuper, operation, manifestEntries, request.snapshotTag, operation.request.concurrentConnections);
                uploadSession.waitUntilConsideredFinished();
                uploadTracker.cancelIfNecessary(uploadSession);
                final List<UploadUnit> failedUnits = uploadSession.getFailedUnits();
                if (!failedUnits.isEmpty()) {
                    final String message = failedUnits.stream().map(unit -> unit.getManifestEntry().objectKey.toString()).collect(Collectors.joining(","));
                    logger.error(message);
                    throw new IOException(format("Unable to upload some files successfully: %s", message));
                }
            } finally {
                uploadTracker.removeSession(uploadSession);
                uploadSession = null;
            }
            if (operation.request.uploadClusterTopology) {
                // here we will upload all topology because we do not know what restore might look like (what dc a restorer will restore against if any)
                final ClusterTopology topology = new CassandraClusterTopology(cassandraJMXService, null).act();
                ClusterTopology.upload(backuper, topology, objectMapper, operation.request.snapshotTag);
            }
        } finally {
            manifest.cleanup();
        }
    } catch (final Exception ex) {
        operation.addError(Error.from(ex));
    } finally {
        final ClearSnapshotOperation cso = new ClearSnapshotOperation(cassandraJMXService, new ClearSnapshotOperationRequest(request.snapshotTag));
        try {
            cso.run0();
        } catch (final Exception ex) {
            operation.addErrors(cso.errors);
        }
    }
}
Also used : CassandraData(com.instaclustr.esop.impl.CassandraData) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) Error(com.instaclustr.operations.Operation.Error) Manifest.getManifestAsManifestEntry(com.instaclustr.esop.impl.Manifest.getManifestAsManifestEntry) Provider(javax.inject.Provider) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) OperationCoordinator(com.instaclustr.operations.OperationCoordinator) LoggerFactory(org.slf4j.LoggerFactory) Manifest.getLocalManifestPath(com.instaclustr.esop.impl.Manifest.getLocalManifestPath) BackuperFactory(com.instaclustr.esop.guice.BackuperFactory) Map(java.util.Map) Session(com.instaclustr.esop.impl.AbstractTracker.Session) CassandraClusterTopology(com.instaclustr.esop.topology.CassandraClusterTopology) Path(java.nio.file.Path) CassandraData(com.instaclustr.esop.impl.CassandraData) BucketServiceFactory(com.instaclustr.esop.guice.BucketServiceFactory) BucketService(com.instaclustr.esop.impl.BucketService) Backuper(com.instaclustr.esop.impl.backup.Backuper) CassandraSchemaVersion(com.instaclustr.esop.impl.interaction.CassandraSchemaVersion) Logger(org.slf4j.Logger) UploadTracker(com.instaclustr.esop.impl.backup.UploadTracker) Operation(com.instaclustr.operations.Operation) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Manifest(com.instaclustr.esop.impl.Manifest) Snapshot(com.instaclustr.esop.impl.Snapshots.Snapshot) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ClearSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation.ClearSnapshotOperationRequest) List(java.util.List) Snapshots(com.instaclustr.esop.impl.Snapshots) UploadUnit(com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit) TakeSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation.TakeSnapshotOperationRequest) CassandraVersion(com.instaclustr.cassandra.CassandraVersion) Optional(java.util.Optional) BackupOperationRequest(com.instaclustr.esop.impl.backup.BackupOperationRequest) CassandraTokens(com.instaclustr.esop.impl.interaction.CassandraTokens) ClusterTopology(com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology) CassandraJMXService(jmx.org.apache.cassandra.service.CassandraJMXService) ClearSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation.ClearSnapshotOperationRequest) TakeSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation.TakeSnapshotOperationRequest) CassandraClusterTopology(com.instaclustr.esop.topology.CassandraClusterTopology) ClusterTopology(com.instaclustr.esop.topology.CassandraClusterTopology.ClusterTopology) CassandraSchemaVersion(com.instaclustr.esop.impl.interaction.CassandraSchemaVersion) UploadUnit(com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit) CassandraClusterTopology(com.instaclustr.esop.topology.CassandraClusterTopology) CassandraTokens(com.instaclustr.esop.impl.interaction.CassandraTokens) Backuper(com.instaclustr.esop.impl.backup.Backuper) Snapshots(com.instaclustr.esop.impl.Snapshots) Manifest.getLocalManifestPath(com.instaclustr.esop.impl.Manifest.getLocalManifestPath) Path(java.nio.file.Path) BucketService(com.instaclustr.esop.impl.BucketService) IOException(java.io.IOException) Manifest(com.instaclustr.esop.impl.Manifest) IOException(java.io.IOException) Snapshot(com.instaclustr.esop.impl.Snapshots.Snapshot) BackupOperationRequest(com.instaclustr.esop.impl.backup.BackupOperationRequest) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) Manifest.getManifestAsManifestEntry(com.instaclustr.esop.impl.Manifest.getManifestAsManifestEntry)

Example 2 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class AbstractTracker method submit.

public synchronized Session<UNIT> submit(final INTERACTOR interactor, final Operation<? extends REQUEST> operation, final Collection<ManifestEntry> entries, final String snapshotTag, final int concurrentConnections) {
    final Session<UNIT> currentSession = constructSession();
    currentSession.setSnapshotTag(snapshotTag);
    currentSession.setId(operation.id);
    if (entries.isEmpty()) {
        logger.info("0 files to process.");
        return currentSession;
    }
    // we have executor service per request in order to specify maximal
    // concurrent uploads, if we had one global executor, we could not "cap it".
    final ListeningExecutorService executorService = new FixedTasksExecutorSupplier().get(concurrentConnections);
    final Map<ListenableFuture<Void>, Unit> futures = new HashMap<>();
    for (final ManifestEntry entry : entries) {
        UNIT alreadySubmitted = null;
        final Iterator<UNIT> it = Collections.unmodifiableList(new ArrayList<>(units)).iterator();
        while (it.hasNext()) {
            UNIT unit = it.next();
            if (unit.getManifestEntry().objectKey.equals(entry.objectKey)) {
                alreadySubmitted = unit;
                break;
            }
        }
        if (alreadySubmitted == null) {
            final UNIT unit = constructUnitToSubmit(interactor, entry, operation.getShouldCancel(), snapshotTag, hashSpec);
            units.add(unit);
            futures.put(executorService.submit(unit), unit);
            submittedUnits.incrementAndGet();
            currentSession.addUnit(unit);
        } else {
            logger.info(String.format("Session %s skips as already submitted: %s", currentSession.getId(), alreadySubmitted.getManifestEntry().objectKey));
            currentSession.addUnit(alreadySubmitted);
        }
    }
    sessions.add(currentSession);
    submittedSessions.incrementAndGet();
    futures.forEach((key, value) -> key.addListener(() -> {
        synchronized (sessions) {
            // increment finished units across all sessions
            sessions.stream().filter(s -> s.getUnits().contains(value)).forEach(s -> {
                operationsService.operation(s.getId()).ifPresent(op -> {
                    s.finishedUnits.incrementAndGet();
                    logger.debug(String.format("Progress of operation %s: %s", op.id, s.getProgress()));
                    op.progress = s.getProgress();
                });
            });
            units.remove(value);
        }
    }, finisherExecutorService));
    currentSession.setExecutorService(executorService);
    return currentSession;
}
Also used : ListenableFuture(com.google.common.util.concurrent.ListenableFuture) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) OperationRequest(com.instaclustr.operations.OperationRequest) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) MINUTES(java.util.concurrent.TimeUnit.MINUTES) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FINISHED(com.instaclustr.esop.impl.AbstractTracker.Unit.State.FINISHED) HashSet(java.util.HashSet) Map(java.util.Map) AbstractIdleService(com.google.common.util.concurrent.AbstractIdleService) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Session(com.instaclustr.esop.impl.AbstractTracker.Session) FixedTasksExecutorSupplier(com.instaclustr.threading.Executors.FixedTasksExecutorSupplier) OperationsService(com.instaclustr.operations.OperationsService) Objects(com.google.common.base.Objects) Awaitility.await(org.awaitility.Awaitility.await) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) Operation(com.instaclustr.operations.Operation) Collection(java.util.Collection) CANCELLED(com.instaclustr.esop.impl.AbstractTracker.Unit.State.CANCELLED) Set(java.util.Set) UUID(java.util.UUID) FAILED(com.instaclustr.esop.impl.AbstractTracker.Unit.State.FAILED) String.format(java.lang.String.format) AtomicLong(java.util.concurrent.atomic.AtomicLong) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) IGNORED(com.instaclustr.esop.impl.AbstractTracker.Unit.State.IGNORED) Optional(java.util.Optional) NOT_STARTED(com.instaclustr.esop.impl.AbstractTracker.Unit.State.NOT_STARTED) Unit(com.instaclustr.esop.impl.AbstractTracker.Unit) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) FixedTasksExecutorSupplier(com.instaclustr.threading.Executors.FixedTasksExecutorSupplier) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Unit(com.instaclustr.esop.impl.AbstractTracker.Unit)

Example 3 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class ListApplication method run.

@Override
public void run() {
    Esop.logCommandVersionInformation(spec);
    final List<Module> modules = Collections.singletonList(new ListModule());
    Esop.init(this, jmxSpec, new HashSpec(), request, logger, modules);
    final Operation<?> operation = operationsService.submitOperationRequest(request);
    await().forever().until(() -> operation.state.isTerminalState());
    if (operation.state == FAILED) {
        throw new IllegalStateException(format("List operation %s was not successful.", operation.id));
    }
}
Also used : ListModule(com.instaclustr.esop.impl.list.ListModule) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) Module(com.google.inject.Module) ListModule(com.instaclustr.esop.impl.list.ListModule)

Example 4 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class LocalBackupTest method testUploadTracker.

@Test
public void testUploadTracker() throws Exception {
    final String snapshotName = UUID.randomUUID().toString();
    final String snapshotName2 = UUID.randomUUID().toString();
    List<Path> dataDirs = Arrays.asList(cassandraDir.toAbsolutePath().resolve("data").resolve("data"), cassandraDir.toAbsolutePath().resolve("data").resolve("data2"), cassandraDir.toAbsolutePath().resolve("data").resolve("data3"));
    final BackupOperationRequest backupOperationRequest = getBackupOperationRequestForTracker(snapshotName, "test,test2", dataDirs);
    final BackupOperationRequest backupOperationRequest2 = getBackupOperationRequestForTracker(snapshotName2, "test", dataDirs);
    UploadTracker uploadTracker = null;
    Cassandra cassandra = null;
    try {
        cassandra = getCassandra(cassandraDir, CASSANDRA_VERSION);
        cassandra.start();
        try (CqlSession session = CqlSession.builder().build()) {
            assertEquals(populateDatabase(session).size(), NUMBER_OF_INSERTED_ROWS);
        }
        final AtomicBoolean wait = new AtomicBoolean(true);
        final ListeningExecutorService finisher = new Executors.FixedTasksExecutorSupplier().get(10);
        uploadTracker = new UploadTracker(finisher, operationsService, new HashSpec()) {

            // override for testing purposes
            @Override
            public UploadUnit constructUnitToSubmit(final Backuper backuper, final ManifestEntry manifestEntry, final AtomicBoolean shouldCancel, final String snapshotTag, final HashSpec hashSpec) {
                return new TestingUploadUnit(wait, backuper, manifestEntry, shouldCancel, snapshotTag, hashSpec);
            }
        };
        final LocalFileBackuper backuper = new LocalFileBackuper(backupOperationRequest);
        new TakeSnapshotOperation(jmxService, new TakeSnapshotOperationRequest(backupOperationRequest.entities, backupOperationRequest.snapshotTag), cassandraVersionProvider).run();
        new TakeSnapshotOperation(jmxService, new TakeSnapshotOperationRequest(backupOperationRequest2.entities, backupOperationRequest2.snapshotTag), cassandraVersionProvider).run();
        final Snapshots snapshots = Snapshots.parse(dataDirs);
        final Optional<Snapshot> snapshot = snapshots.get(backupOperationRequest.snapshotTag);
        final Optional<Snapshot> snapshot2 = snapshots.get(backupOperationRequest2.snapshotTag);
        assert snapshot.isPresent();
        assert snapshot2.isPresent();
        Set<String> providers = Stream.of("file").collect(Collectors.toSet());
        final BackupOperation backupOperation = new BackupOperation(operationCoordinator, providers, backupOperationRequest);
        final BackupOperation backupOperation2 = new BackupOperation(operationCoordinator, providers, backupOperationRequest2);
        final List<ManifestEntry> manifestEntries = Manifest.from(snapshot.get()).getManifestEntries();
        final List<ManifestEntry> manifestEntries2 = Manifest.from(snapshot2.get()).getManifestEntries();
        Session<UploadUnit> session = uploadTracker.submit(backuper, backupOperation, manifestEntries, backupOperation.request.snapshotTag, backupOperation.request.concurrentConnections);
        final int submittedUnits1 = uploadTracker.submittedUnits.intValue();
        Assert.assertEquals(manifestEntries.size(), submittedUnits1);
        final Session<UploadUnit> session2 = uploadTracker.submit(backuper, backupOperation2, manifestEntries2, backupOperation.request.snapshotTag, backupOperation.request.concurrentConnections);
        final int submittedUnits2 = uploadTracker.submittedUnits.intValue();
        // even we submitted the second session, it does not change the number of units because session2
        // wants to upload "test" but it is already going to be uploaded by session1
        // we have effectively submitted only what should be submitted, no duplicates
        // so it is as if "test" from session2 was not submitted at all
        Assert.assertEquals(submittedUnits1, submittedUnits2);
        Assert.assertEquals(manifestEntries.size(), uploadTracker.submittedUnits.intValue());
        // however we have submitted two sessions in total
        Assert.assertEquals(2, uploadTracker.submittedSessions.intValue());
        // lets upload it now
        wait.set(false);
        session.waitUntilConsideredFinished();
        session2.waitUntilConsideredFinished();
        Assert.assertTrue(session.isConsideredFinished());
        Assert.assertTrue(session.isSuccessful());
        Assert.assertTrue(session.getFailedUnits().isEmpty());
        Assert.assertEquals(uploadTracker.submittedUnits.intValue(), session.getUnits().size());
        Assert.assertTrue(session2.isConsideredFinished());
        Assert.assertTrue(session2.isSuccessful());
        Assert.assertTrue(session2.getFailedUnits().isEmpty());
        Assert.assertTrue(submittedUnits2 > session2.getUnits().size());
        for (final UploadUnit uploadUnit : session2.getUnits()) {
            Assert.assertTrue(session.getUnits().contains(uploadUnit));
        }
        Assert.assertTrue(uploadTracker.getUnits().isEmpty());
        uploadTracker.removeSession(session);
        uploadTracker.removeSession(session2);
        Assert.assertTrue(session.getUnits().isEmpty());
        Assert.assertTrue(session2.getUnits().isEmpty());
    } catch (final Exception ex) {
        ex.printStackTrace();
        throw ex;
    } finally {
        new ClearSnapshotOperation(jmxService, new ClearSnapshotOperationRequest(backupOperationRequest.snapshotTag)).run();
        if (cassandra != null) {
            cassandra.stop();
        }
        uploadTracker.stopAsync();
        uploadTracker.awaitTerminated(1, MINUTES);
        uploadTracker.stopAsync();
        uploadTracker.awaitTerminated(1, MINUTES);
        FileUtils.deleteDirectory(Paths.get(target(backupOperationRequest.storageLocation.bucket)));
    }
}
Also used : ClearSnapshotOperation(com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation) ClearSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation.ClearSnapshotOperationRequest) Cassandra(com.github.nosan.embedded.cassandra.Cassandra) Executors(com.instaclustr.threading.Executors) TakeSnapshotOperationRequest(com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation.TakeSnapshotOperationRequest) UploadUnit(com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit) LocalFileBackuper(com.instaclustr.esop.local.LocalFileBackuper) Backuper(com.instaclustr.esop.impl.backup.Backuper) Snapshots(com.instaclustr.esop.impl.Snapshots) UploadTracker(com.instaclustr.esop.impl.backup.UploadTracker) BackupOperation(com.instaclustr.esop.impl.backup.BackupOperation) Path(java.nio.file.Path) TakeSnapshotOperation(com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) CqlSession(com.datastax.oss.driver.api.core.CqlSession) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LocalFileBackuper(com.instaclustr.esop.local.LocalFileBackuper) Snapshot(com.instaclustr.esop.impl.Snapshots.Snapshot) BackupOperationRequest(com.instaclustr.esop.impl.backup.BackupOperationRequest) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) ListeningExecutorService(com.google.common.util.concurrent.ListeningExecutorService) Test(org.testng.annotations.Test) AbstractBackupTest(com.instaclustr.esop.backup.embedded.AbstractBackupTest)

Example 5 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class BackupRestoreTest method testSSTableLister.

@Test(description = "Test that the manifest is correctly constructed, includes expected files and generates checksum if necessary")
@Ignore
public void testSSTableLister() throws Exception {
    // TODO not sure why this doesn't recreate things fully given its called before each test
    hardResetTestDirs();
    for (TestFileConfig testFileConfig : versionsToTest) {
        Path backupRoot = Paths.get("/backupRoot/keyspace1");
        final String keyspace = "keyspace1";
        final String table1 = "table1";
        final Path table1Path = tempDirs.get(testFileConfig.cassandraVersion.toString()).resolve("data/" + keyspace + "/" + table1);
        Map<String, List<ManifestEntry>> sstables = SSTableUtils.getSSTables(keyspace, table1, table1Path, backupRoot.resolve(table1Path.getFileName()), new HashSpec());
        final String table2 = "table2";
        final Path table2Path = tempDirs.get(testFileConfig.cassandraVersion.toString()).resolve("data/" + keyspace + "/" + table2);
        sstables.putAll(SSTableUtils.getSSTables(keyspace, table2, table2Path, backupRoot.resolve(table2Path.getFileName()), new HashSpec()));
        Map<Path, Path> manifestMap = new HashMap<>();
        for (ManifestEntry e : sstables.values().stream().flatMap(Collection::stream).collect(Collectors.toList())) {
            manifestMap.put(e.localFile, e.objectKey);
        }
        if (CassandraVersion.isTwoZero(testFileConfig.cassandraVersion)) {
            // table1 is un-compressed so should have written out a sha1 digest
            final Path localPath1 = table1Path.resolve(String.format("%s-1-big-Data.db", testFileConfig.getSstablePrefix(keyspace, table1)));
            assertEquals(manifestMap.get(localPath1), backupRoot.resolve(String.format("%s/1-%s/%s-1-big-Data.db", table1, sha1Hash, testFileConfig.getSstablePrefix(keyspace, table1))));
            final Path localPath2 = table1Path.resolve(String.format("%s-3-big-Index.db", testFileConfig.getSstablePrefix(keyspace, table1)));
            final String checksum2 = SSTableUtils.calculateChecksum(localPath2);
            assertEquals(manifestMap.get(localPath2), backupRoot.resolve(String.format("%s/3-%s/%s-3-big-Index.db", table1, checksum2, testFileConfig.getSstablePrefix(keyspace, table1))));
            final Path localPath3 = table2Path.resolve(String.format("%s-1-big-Data.db", testFileConfig.getSstablePrefix(keyspace, table2)));
            final String checksum3 = SSTableUtils.calculateChecksum(localPath3);
            assertEquals(manifestMap.get(localPath3), backupRoot.resolve(String.format("%s/1-%s/%s-1-big-Data.db", table2, checksum3, testFileConfig.getSstablePrefix(keyspace, table2))));
            assertNull(manifestMap.get(table2Path.resolve(String.format("%s-3-big-Index.db", testFileConfig.getSstablePrefix(keyspace, table2)))));
        } else {
            Path resolve = table1Path.resolve(String.format("%s-1-big-Data.db", testFileConfig.getSstablePrefix(keyspace, table1)));
            assertEquals(manifestMap.get(resolve), backupRoot.resolve(String.format("%s/1-1000000000/%s-1-big-Data.db", table1, testFileConfig.getSstablePrefix(keyspace, table1))));
            // Cassandra doesn't create CRC32 file for 2.0.x
            assertEquals(manifestMap.get(table1Path.resolve(String.format("%s-2-big-Digest.crc32", testFileConfig.getSstablePrefix(keyspace, table1)))), backupRoot.resolve(String.format("%s/2-1000000000/%s-2-big-Digest.crc32", table1, testFileConfig.getSstablePrefix(keyspace, table1))));
            assertEquals(manifestMap.get(table1Path.resolve(String.format("%s-3-big-Index.db", testFileConfig.getSstablePrefix(keyspace, table1)))), backupRoot.resolve(String.format("%s/3-1000000000/%s-3-big-Index.db", table1, testFileConfig.getSstablePrefix(keyspace, table1))));
            assertEquals(manifestMap.get(table2Path.resolve(String.format("%s-1-big-Data.db", testFileConfig.getSstablePrefix(keyspace, table2)))), backupRoot.resolve(String.format("%s/1-1000000000/%s-1-big-Data.db", table2, testFileConfig.getSstablePrefix(keyspace, table2))));
            assertEquals(manifestMap.get(table2Path.resolve(String.format("%s-2-big-Digest.crc32", testFileConfig.getSstablePrefix(keyspace, table2)))), backupRoot.resolve(String.format("%s/2-1000000000/%s-2-big-Digest.crc32", table2, testFileConfig.getSstablePrefix(keyspace, table2))));
            assertNull(manifestMap.get(table2Path.resolve(String.format("%s-3-big-Index.db", testFileConfig.getSstablePrefix(keyspace, table2)))));
        }
        assertNull(manifestMap.get(table1Path.resolve("manifest.json")));
        assertNull(manifestMap.get(table1Path.resolve("backups")));
        assertNull(manifestMap.get(table1Path.resolve("snapshots")));
    }
}
Also used : Path(java.nio.file.Path) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Ignore(org.testng.annotations.Ignore) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

HashSpec (com.instaclustr.esop.impl.hash.HashSpec)8 Path (java.nio.file.Path)4 List (java.util.List)4 ManifestEntry (com.instaclustr.esop.impl.ManifestEntry)3 String.format (java.lang.String.format)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Optional (java.util.Optional)3 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 Module (com.google.inject.Module)2 Session (com.instaclustr.esop.impl.AbstractTracker.Session)2 Snapshots (com.instaclustr.esop.impl.Snapshots)2 Snapshot (com.instaclustr.esop.impl.Snapshots.Snapshot)2 BackupOperationRequest (com.instaclustr.esop.impl.backup.BackupOperationRequest)2 Backuper (com.instaclustr.esop.impl.backup.Backuper)2 UploadTracker (com.instaclustr.esop.impl.backup.UploadTracker)2 UploadUnit (com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit)2 ClearSnapshotOperationRequest (com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation.ClearSnapshotOperationRequest)2 TakeSnapshotOperationRequest (com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation.TakeSnapshotOperationRequest)2