use of com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport in project esop by instaclustr.
the class ListOperation method printSimpleTable.
private void printSimpleTable(final AllManifestsReport report, final PrintStream ps) {
final TableBuilder builder = new TableBuilder();
for (final ManifestReport mr : report.reports) {
builder.add(mr.name);
}
builder.printTo(ps);
}
use of com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport in project esop by instaclustr.
the class ListOperation method printComplexTable.
private void printComplexTable(final AllManifestsReport report, final PrintStream ps) {
final TableBuilder builder = new TableBuilder();
builder.add("Timestamp", "Name", "Files", "Occupied space", "Reclaimable space");
for (final ManifestReport mr : report.reports) {
final String size = request.humanUnits ? humanReadableByteCountSI(mr.size) : Long.toString(mr.size);
final String reclaimable = request.humanUnits ? humanReadableByteCountSI(mr.reclaimableSpace) : Long.toString(mr.reclaimableSpace);
builder.add(mr.timestamp, mr.name, Integer.toString(mr.files), size, reclaimable);
}
final String totalSize = request.humanUnits ? humanReadableByteCountSI(report.totalSize) : Long.toString(report.totalSize);
builder.add("", "", Integer.toString(report.totalFiles), totalSize, "");
builder.printTo(ps);
}
use of com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport 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