Search in sources :

Example 1 with ManifestReport

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);
}
Also used : ManifestReport(com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport) TableBuilder(com.instaclustr.esop.impl.TableBuilder)

Example 2 with ManifestReport

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);
}
Also used : ManifestReport(com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport) TableBuilder(com.instaclustr.esop.impl.TableBuilder)

Example 3 with ManifestReport

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));
    }
}
Also used : CassandraSimpleTopology(com.instaclustr.esop.topology.CassandraSimpleTopology) CassandraSimpleTopologyResult(com.instaclustr.esop.topology.CassandraSimpleTopology.CassandraSimpleTopologyResult) StorageInteractor(com.instaclustr.esop.impl.StorageInteractor) LocalFileRestorer(com.instaclustr.esop.local.LocalFileRestorer) ManifestReport(com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport) AllManifestsReport(com.instaclustr.esop.impl.Manifest.AllManifestsReport) StorageLocation(com.instaclustr.esop.impl.StorageLocation)

Aggregations

ManifestReport (com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport)3 TableBuilder (com.instaclustr.esop.impl.TableBuilder)2 AllManifestsReport (com.instaclustr.esop.impl.Manifest.AllManifestsReport)1 StorageInteractor (com.instaclustr.esop.impl.StorageInteractor)1 StorageLocation (com.instaclustr.esop.impl.StorageLocation)1 LocalFileRestorer (com.instaclustr.esop.local.LocalFileRestorer)1 CassandraSimpleTopology (com.instaclustr.esop.topology.CassandraSimpleTopology)1 CassandraSimpleTopologyResult (com.instaclustr.esop.topology.CassandraSimpleTopology.CassandraSimpleTopologyResult)1