Search in sources :

Example 6 with RestoreOperationRequest

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")));
    }
}
Also used : Path(java.nio.file.Path) LocalFileRestorer(com.instaclustr.esop.local.LocalFileRestorer) RestoreOperationRequest(com.instaclustr.esop.impl.restore.RestoreOperationRequest) StorageLocation(com.instaclustr.esop.impl.StorageLocation) Test(org.testng.annotations.Test) AbstractBackupTest(com.instaclustr.esop.backup.embedded.AbstractBackupTest)

Example 7 with RestoreOperationRequest

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));
    }
}
Also used : RestorationStrategy(com.instaclustr.esop.impl.restore.RestorationStrategy) RestoreOperationRequest(com.instaclustr.esop.impl.restore.RestoreOperationRequest) Restorer(com.instaclustr.esop.impl.restore.Restorer)

Aggregations

RestoreOperationRequest (com.instaclustr.esop.impl.restore.RestoreOperationRequest)7 Path (java.nio.file.Path)6 StorageLocation (com.instaclustr.esop.impl.StorageLocation)5 Test (org.testng.annotations.Test)5 BackupOperationRequest (com.instaclustr.esop.impl.backup.BackupOperationRequest)4 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 Bucket (com.google.cloud.storage.Bucket)1 Storage (com.google.cloud.storage.Storage)1 AzureBackuper (com.instaclustr.esop.azure.AzureBackuper)1 AzureBucketService (com.instaclustr.esop.azure.AzureBucketService)1 AzureRestorer (com.instaclustr.esop.azure.AzureRestorer)1 AbstractBackupTest (com.instaclustr.esop.backup.embedded.AbstractBackupTest)1 GCPBackuper (com.instaclustr.esop.gcp.GCPBackuper)1 GCPBucketService (com.instaclustr.esop.gcp.GCPBucketService)1 GCPRestorer (com.instaclustr.esop.gcp.GCPRestorer)1 BucketService (com.instaclustr.esop.impl.BucketService)1 Manifest (com.instaclustr.esop.impl.Manifest)1 DownloadUnit (com.instaclustr.esop.impl.restore.DownloadTracker.DownloadUnit)1 RestorationStrategy (com.instaclustr.esop.impl.restore.RestorationStrategy)1 Restorer (com.instaclustr.esop.impl.restore.Restorer)1