Search in sources :

Example 16 with ManifestEntry

use of com.instaclustr.esop.impl.ManifestEntry in project esop by instaclustr.

the class BackupCommitLogsOperation method run0.

@Override
protected void run0() throws Exception {
    updateStorageLocationIfNecessary();
    logger.info(request.toString());
    // generate manifest (set of object keys and source files defining the upload)
    // linked list to maintain order
    final Collection<ManifestEntry> manifestEntries = new LinkedList<>();
    try (final DirectoryStream<Path> commitLogs = getCommitLogs(request);
        final Backuper backuper = backuperFactoryMap.get(request.storageLocation.storageProvider).createCommitLogBackuper(request);
        final BucketService bucketService = bucketServiceMap.get(request.storageLocation.storageProvider).createBucketService(request)) {
        if (!request.skipBucketVerification) {
            bucketService.checkBucket(request.storageLocation.bucket, request.createMissingBucket);
        }
        for (final Path commitLog : commitLogs) {
            // Append file modified date so we have some idea of the time range this commitlog covers
            // millisecond precision, on *nix, it trims milliseconds and returns "000" instead
            // when using File.lastModified
            long commitLogLastModified = Files.getLastModifiedTime(commitLog.toFile().toPath()).toMillis();
            final Path bucketKey = CASSANDRA_COMMITLOG.resolve(commitLog.getFileName().toString() + "." + commitLogLastModified);
            manifestEntries.add(new ManifestEntry(bucketKey, commitLog, COMMIT_LOG, null));
        }
        logger.info("{} files in manifest for commitlog backup.", manifestEntries.size());
        Session<UploadUnit> uploadSession = null;
        try {
            uploadSession = uploadTracker.submit(backuper, this, manifestEntries, null, this.request.concurrentConnections);
            uploadSession.waitUntilConsideredFinished();
            uploadTracker.cancelIfNecessary(uploadSession);
        } finally {
            uploadTracker.removeSession(uploadSession);
        }
    }
}
Also used : Path(java.nio.file.Path) UploadUnit(com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit) ManifestEntry(com.instaclustr.esop.impl.ManifestEntry) BucketService(com.instaclustr.esop.impl.BucketService) LinkedList(java.util.LinkedList)

Aggregations

ManifestEntry (com.instaclustr.esop.impl.ManifestEntry)16 Manifest (com.instaclustr.esop.impl.Manifest)11 Path (java.nio.file.Path)11 Test (org.testng.annotations.Test)11 Snapshot (com.instaclustr.esop.impl.Snapshots.Snapshot)8 DatabaseEntities (com.instaclustr.esop.impl.DatabaseEntities)7 KeyspaceTable (com.instaclustr.esop.impl.KeyspaceTable)7 List (java.util.List)7 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 Keyspace (com.instaclustr.esop.impl.Snapshots.Snapshot.Keyspace)6 ArrayList (java.util.ArrayList)6 Table (com.instaclustr.esop.impl.Snapshots.Snapshot.Keyspace.Table)5 HashMap (java.util.HashMap)5 Guice (com.google.inject.Guice)4 Inject (com.google.inject.Inject)4 Injector (com.google.inject.Injector)4 Module (com.google.inject.Module)4 Type (com.instaclustr.esop.impl.ManifestEntry.Type)4 Snapshots (com.instaclustr.esop.impl.Snapshots)4 JacksonModule (com.instaclustr.jackson.JacksonModule)4