Search in sources :

Example 1 with DaemonScheduler

use of com.instaclustr.scheduling.DaemonScheduler 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

Module (com.google.inject.Module)1 HashSpec (com.instaclustr.esop.impl.hash.HashSpec)1 RemoveBackupModule (com.instaclustr.esop.impl.remove.RemoveBackupModule)1 RemoveBackupOperation (com.instaclustr.esop.impl.remove.RemoveBackupOperation)1 RemoveBackupRequest (com.instaclustr.esop.impl.remove.RemoveBackupRequest)1 DaemonScheduler (com.instaclustr.scheduling.DaemonScheduler)1