use of com.instaclustr.esop.impl.remove.RemoveBackupRequest in project esop by instaclustr.
the class BaseS3Restorer method delete.
@Override
public void delete(final Manifest.ManifestReporter.ManifestReport backupToDelete, final RemoveBackupRequest request) throws Exception {
logger.info("Deleting backup {}", backupToDelete.name);
if (backupToDelete.reclaimableSpace > 0 && !backupToDelete.getRemovableEntries().isEmpty()) {
// convert removable entries into S3 object keys
String[] toRemove = backupToDelete.getRemovableEntries().stream().map(entry -> objectKeyToNodeAwareRemoteReference(Paths.get(entry)).canonicalPath).toArray(String[]::new);
for (String remove : toRemove) {
if (request.dry) {
logger.info("Deletion of {} was executed in dry mode.", remove);
} else {
logger.info("Deleting file {}", remove);
}
}
if (!request.dry) {
amazonS3.deleteObjects(new DeleteObjectsRequest(request.storageLocation.bucket).withKeys(toRemove));
logger.info("Deletion of files complete");
}
}
Path key = backupToDelete.manifest.objectKey;
// manifest and topology as the last
if (!request.dry) {
logger.info("Deleting file {} from S3", key);
// delete in S3
deleteNodeAwareKey(key);
// delete in local cache
logger.info("Deleting file {} from local cache", key);
localFileRestorer.deleteNodeAwareKey(key);
} else {
logger.info("Deletion of {} was executed in dry mode.", key);
}
}
use of com.instaclustr.esop.impl.remove.RemoveBackupRequest in project esop by instaclustr.
the class RemoveBackupApplication method run.
@Override
public void run() {
Esop.logCommandVersionInformation(spec);
final List<Module> modules = Collections.singletonList(new RemoveBackupModule());
Esop.init(this, jmxSpec, new HashSpec(), request, logger, modules);
if (rate.value == 0) {
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));
}
} else {
final Supplier<RemoveBackupOperation> supplier = () -> new RemoveBackupOperation(request, cassandraJMXService, restorerFactoryMap, objectMapper);
final DaemonScheduler<RemoveBackupRequest, RemoveBackupOperation> scheduler = new DaemonScheduler<>(rate, supplier);
scheduler.setup();
scheduler.execute();
}
}
Aggregations