use of com.instaclustr.esop.impl.restore.RestoreOperationRequest in project esop by instaclustr.
the class LocalBackupTest method testDownload.
@Test
public void testDownload() throws Exception {
try {
RestoreOperationRequest restoreOperationRequest = new RestoreOperationRequest();
FileUtils.createDirectory(Paths.get(target("backup1") + "/cluster/test-dc/1/manifests").toAbsolutePath());
restoreOperationRequest.storageLocation = new StorageLocation("file://" + target("backup1") + "/cluster/test-dc/1");
Files.write(Paths.get("target/backup1/cluster/test-dc/1/manifests/snapshot-name-" + UUID.randomUUID().toString()).toAbsolutePath(), "hello".getBytes(), StandardOpenOption.CREATE_NEW);
LocalFileRestorer localFileRestorer = new LocalFileRestorer(restoreOperationRequest);
final Path downloadedFile = localFileRestorer.downloadNodeFileToDir(Paths.get("/tmp"), Paths.get("manifests"), s -> s.contains("snapshot-name-"));
assertTrue(Files.exists(downloadedFile));
} finally {
deleteDirectory(Paths.get(target("backup1")));
deleteDirectory(Paths.get(target("commitlog_download_dir")));
}
}
use of com.instaclustr.esop.impl.restore.RestoreOperationRequest in project esop by instaclustr.
the class BaseRestoreOperationCoordinator method coordinate.
@Override
public void coordinate(final Operation<RestoreOperationRequest> operation) throws OperationCoordinatorException {
final RestoreOperationRequest request = operation.request;
if (request.restorationStrategyType == RestorationStrategyType.IMPORT || request.restorationStrategyType == RestorationStrategyType.HARDLINKS) {
if (request.importing == null) {
throw new IllegalStateException(format("you can not run %s strategy and have 'import' empty!", request.restorationStrategyType));
}
if (request.restorationPhase == null) {
throw new IllegalStateException(format("you can not run %s strategy and have 'restorationPhase' empty!", request.restorationStrategyType));
}
}
if (request.restoreSystemKeyspace && (request.restorationStrategyType != RestorationStrategyType.IN_PLACE)) {
throw new IllegalStateException("you can not set 'restoreSystemKeyspace' to true when your restoration strategy is not IN_PLACE, " + "it is not possible to restore system keyspace on a running node");
}
try (final Restorer restorer = restorerFactoryMap.get(request.storageLocation.storageProvider).createRestorer(request)) {
final RestorationStrategy restorationStrategy = restorationStrategyResolver.resolve(request);
restorationStrategy.restore(restorer, operation);
} catch (final Exception ex) {
logger.error("Unable to perform restore! - " + ex.getMessage(), ex);
operation.addError(Error.from(ex));
}
}
Aggregations