use of com.instaclustr.esop.impl.Manifest.AllManifestsReport in project esop by instaclustr.
the class ListOperation method run0.
@Override
protected void run0() throws Exception {
assert restorerFactoryMap != null;
assert objectMapper != null;
request.storageLocation.validate();
Path localPath = request.cacheDir;
if (!request.skipDownload && !Files.exists(localPath)) {
FileUtils.createDirectory(localPath);
}
if (request.resolveNodes) {
assert cassandraJMXService != null;
CassandraSimpleTopologyResult simpleTopology = new CassandraSimpleTopology(cassandraJMXService).act();
request.storageLocation = StorageLocation.update(request.storageLocation, simpleTopology.getClusterName(), simpleTopology.getDc(), simpleTopology.getHostId());
}
try (final StorageInteractor interactor = restorerFactoryMap.get(request.storageLocation.storageProvider).createListingInteractor(request)) {
interactor.update(request.storageLocation, new LocalFileRestorer(getForLocalListing(request, request.cacheDir, request.storageLocation), objectMapper));
final AllManifestsReport report = AllManifestsReport.report(interactor.listManifests());
filterFromTimestamp(report, request.fromTimestamp);
filterLastN(report, request.lastN);
if (request.toRequest) {
request.response = report;
} else {
try (final PrintStream ps = getOutputStream(request)) {
print(report, request, ps);
}
}
} catch (final Exception ex) {
logger.error("Unable to perform listing! - " + ex.getMessage(), ex);
this.addError(Error.from(ex));
}
}
use of com.instaclustr.esop.impl.Manifest.AllManifestsReport in project esop by instaclustr.
the class RemoveBackupOperation method run0.
@Override
protected void run0() throws Exception {
assert restorerFactoryMap != null;
assert objectMapper != null;
request.validate(null);
if (request.resolveNodes) {
assert cassandraJMXService != null;
CassandraSimpleTopologyResult simpleTopology = new CassandraSimpleTopology(cassandraJMXService).act();
request.storageLocation = StorageLocation.update(request.storageLocation, simpleTopology.getClusterName(), simpleTopology.getDc(), simpleTopology.getHostId());
}
try (final StorageInteractor interactor = restorerFactoryMap.get(request.storageLocation.storageProvider).createDeletingInteractor(request)) {
interactor.update(request.storageLocation, new LocalFileRestorer(getForLocalListing(request, request.cacheDir, request.storageLocation), objectMapper));
for (final StorageLocation nodeLocation : getStorageLocations(interactor)) {
logger.info("Looking for backups to delete for node {}", nodeLocation.nodePath());
request.storageLocation = nodeLocation;
interactor.update(nodeLocation, new LocalFileRestorer(getForLocalListing(request, request.cacheDir, request.storageLocation), objectMapper));
final Optional<AllManifestsReport> reportOptional = getReport(interactor);
if (!reportOptional.isPresent()) {
logger.info("No backups found for {}", nodeLocation.nodePath());
continue;
}
final AllManifestsReport report = reportOptional.get();
logger.debug(report.toString());
final List<ManifestReport> allBackupsToDelete = getBackupsToDelete(report);
if (allBackupsToDelete.isEmpty()) {
if (request.backupName != null) {
logger.info("There is not any {} backup to remove for node {}", request.backupName, nodeLocation);
} else {
logger.info("There is not any backup to remove for node {}", nodeLocation);
}
continue;
}
logger.info("Removing backups for node {}: {}", nodeLocation.nodePath(), allBackupsToDelete.stream().map(mr -> mr.name).collect(Collectors.joining(",")));
for (final ManifestReport mr : allBackupsToDelete) {
interactor.delete(mr, request);
}
}
if (!request.dry) {
interactor.deleteTopology(request.backupName);
} else {
logger.info("Deletion of topology for {} was executed in dry mode", request.backupName);
}
} catch (final Exception ex) {
logger.error("Unable to perform backup deletion! - " + ex.getMessage(), ex);
this.addError(Error.from(ex));
}
}
Aggregations