Search in sources :

Example 6 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class HashServiceTest method testHashing.

@Test
public void testHashing() throws Exception {
    final File f = File.createTempFile("hashingTest", ".tmp");
    Files.write(f.toPath(), "".getBytes());
    final HashService hashService = new HashServiceImpl(new HashSpec());
    hashService.verify(f.toPath(), hashService.hash(f.toPath()));
}
Also used : HashSpec(com.instaclustr.esop.impl.hash.HashSpec) File(java.io.File) HashService(com.instaclustr.esop.impl.hash.HashService) HashServiceImpl(com.instaclustr.esop.impl.hash.HashServiceImpl) Test(org.testng.annotations.Test)

Example 7 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec in project esop by instaclustr.

the class Snapshots method parse.

public static synchronized Snapshots parse(final Path cassandraDir, final String snapshot) throws Exception {
    if (Snapshots.hashSpec == null) {
        Snapshots.hashSpec = new HashSpec();
    }
    final Snapshots snapshots = new Snapshots();
    final SnapshotLister lister = new SnapshotLister();
    Files.walkFileTree(cassandraDir, lister);
    final Map<String, List<Path>> snapshotPaths = lister.getSnapshotPaths().entrySet().stream().filter(entry -> snapshot == null || (entry.getKey().equals(snapshot))).collect(Collectors.toMap(Entry::getKey, Entry::getValue));
    for (final Entry<String, List<Path>> paths : snapshotPaths.entrySet()) {
        snapshots.snapshots.put(paths.getKey(), Snapshot.parse(paths.getKey(), paths.getValue()));
    }
    return snapshots;
}
Also used : ArrayListMultimap(com.google.common.collect.ArrayListMultimap) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) Arrays(java.util.Arrays) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) Multimap(com.google.common.collect.Multimap) Function(java.util.function.Function) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) HashMultimap(com.google.common.collect.HashMultimap) Matcher(java.util.regex.Matcher) Pair(org.apache.commons.lang3.tuple.Pair) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Table(com.instaclustr.esop.impl.Snapshots.Snapshot.Keyspace.Table) Path(java.nio.file.Path) Collectors.toSet(java.util.stream.Collectors.toSet) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) Files(java.nio.file.Files) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) Collectors(java.util.stream.Collectors) FileNotFoundException(java.io.FileNotFoundException) String.format(java.lang.String.format) Objects(java.util.Objects) Consumer(java.util.function.Consumer) FileVisitResult(java.nio.file.FileVisitResult) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Stream(java.util.stream.Stream) Paths(java.nio.file.Paths) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) Entry(java.util.Map.Entry) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Collections(java.util.Collections) DataSynchronizator(com.instaclustr.esop.impl.restore.strategy.DataSynchronizator) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) ArrayList(java.util.ArrayList) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList)

Example 8 with HashSpec

use of com.instaclustr.esop.impl.hash.HashSpec 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();
    }
}
Also used : RemoveBackupModule(com.instaclustr.esop.impl.remove.RemoveBackupModule) HashSpec(com.instaclustr.esop.impl.hash.HashSpec) RemoveBackupOperation(com.instaclustr.esop.impl.remove.RemoveBackupOperation) DaemonScheduler(com.instaclustr.scheduling.DaemonScheduler) Module(com.google.inject.Module) RemoveBackupModule(com.instaclustr.esop.impl.remove.RemoveBackupModule) RemoveBackupRequest(com.instaclustr.esop.impl.remove.RemoveBackupRequest)

Aggregations

HashSpec (com.instaclustr.esop.impl.hash.HashSpec)8 Path (java.nio.file.Path)4 List (java.util.List)4 ManifestEntry (com.instaclustr.esop.impl.ManifestEntry)3 String.format (java.lang.String.format)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Optional (java.util.Optional)3 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)2 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)2 Module (com.google.inject.Module)2 Session (com.instaclustr.esop.impl.AbstractTracker.Session)2 Snapshots (com.instaclustr.esop.impl.Snapshots)2 Snapshot (com.instaclustr.esop.impl.Snapshots.Snapshot)2 BackupOperationRequest (com.instaclustr.esop.impl.backup.BackupOperationRequest)2 Backuper (com.instaclustr.esop.impl.backup.Backuper)2 UploadTracker (com.instaclustr.esop.impl.backup.UploadTracker)2 UploadUnit (com.instaclustr.esop.impl.backup.UploadTracker.UploadUnit)2 ClearSnapshotOperationRequest (com.instaclustr.esop.impl.backup.coordination.ClearSnapshotOperation.ClearSnapshotOperationRequest)2 TakeSnapshotOperationRequest (com.instaclustr.esop.impl.backup.coordination.TakeSnapshotOperation.TakeSnapshotOperationRequest)2