Search in sources :

Example 6 with StorageLocation

use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.

the class S3ListingAndBackupRemovalTest method destroy.

@Override
public void destroy() throws Exception {
    try {
        FileUtils.deleteDirectory(cassandraDir);
    } catch (final Exception ex) {
        logger.error("Unable to remove Cassandra dir " + cassandraDir);
    }
    try {
        ListOperationRequest request = new ListOperationRequest();
        request.storageLocation = new StorageLocation(getStorageLocation());
        new S3BucketService(transferManagerFactory, request).delete(BUCKET_NAME);
    } catch (final Exception ex) {
        logger.error("Unable to remove bucket " + BUCKET_NAME);
    }
}
Also used : ListOperationRequest(com.instaclustr.esop.impl.list.ListOperationRequest) S3BucketService(com.instaclustr.esop.s3.aws.S3BucketService) StorageLocation(com.instaclustr.esop.impl.StorageLocation)

Example 7 with StorageLocation

use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.

the class CephS3BackupRestoreTest method testDownload.

@Test
public void testDownload() throws Exception {
    CephS3TransferManagerFactory factory = getTransferManagerFactory();
    CephBucketService s3BucketService = new CephBucketService(factory, getBackupOperationRequest());
    Path tmp = Files.createTempDirectory("tmp");
    tmp.toFile().deleteOnExit();
    try {
        s3BucketService.create(BUCKET_NAME);
        AmazonS3 amazonS3Client = factory.build(getBackupOperationRequest()).getAmazonS3Client();
        amazonS3Client.putObject(BUCKET_NAME, "cluster/dc/node/manifests/snapshot-name-" + BUCKET_NAME, "hello");
        amazonS3Client.putObject(BUCKET_NAME, "snapshot/in/dir/my-name-" + BUCKET_NAME, "hello world");
        amazonS3Client.listObjects(BUCKET_NAME).getObjectSummaries().forEach(summary -> logger.info(summary.getKey()));
        final RestoreOperationRequest restoreOperationRequest = new RestoreOperationRequest();
        restoreOperationRequest.storageLocation = new StorageLocation("ceph://" + BUCKET_NAME + "/cluster/dc/node");
        final BackupOperationRequest backupOperationRequest = new BackupOperationRequest();
        backupOperationRequest.storageLocation = new StorageLocation("ceph://" + BUCKET_NAME + "/cluster/dc/node");
        final CephRestorer s3Restorer = new CephRestorer(factory, restoreOperationRequest);
        final CephBackuper s3Backuper = new CephBackuper(factory, backupOperationRequest);
        // 1
        final Path downloadedFile = s3Restorer.downloadNodeFileToDir(tmp, Paths.get("manifests"), s -> s.contains("manifests/snapshot-name"));
        assertTrue(Files.exists(downloadedFile));
        // 2
        final String content = s3Restorer.downloadNodeFileToString(Paths.get("manifests"), s -> s.contains("manifests/snapshot-name"));
        Assert.assertEquals("hello", content);
        // 3
        final String content2 = s3Restorer.downloadFileToString(Paths.get("snapshot/in/dir"), s -> s.endsWith("my-name-" + BUCKET_NAME));
        Assert.assertEquals("hello world", content2);
        // 4
        s3Restorer.downloadFile(tmp.resolve("some-file"), s3Restorer.objectKeyToRemoteReference(Paths.get("snapshot/in/dir/my-name-" + BUCKET_NAME)));
        Assert.assertTrue(Files.exists(tmp.resolve("some-file")));
        Assert.assertEquals("hello world", new String(Files.readAllBytes(tmp.resolve("some-file"))));
        // backup
        s3Backuper.uploadText("hello world", s3Backuper.objectKeyToRemoteReference(Paths.get("topology/some-file-in-here.txt")));
        String text = s3Restorer.downloadFileToString(s3Restorer.objectKeyToRemoteReference(Paths.get("topology/some-file-in-here.txt")));
        Assert.assertEquals("hello world", text);
    } finally {
        s3BucketService.delete(BUCKET_NAME);
        deleteDirectory(Paths.get(target("commitlog_download_dir")));
        Files.deleteIfExists(tmp.resolve("some-file"));
    }
}
Also used : Path(java.nio.file.Path) AmazonS3(com.amazonaws.services.s3.AmazonS3) CephBackuper(com.instaclustr.esop.s3.ceph.CephBackuper) BackupOperationRequest(com.instaclustr.esop.impl.backup.BackupOperationRequest) CephS3TransferManagerFactory(com.instaclustr.esop.s3.ceph.CephModule.CephS3TransferManagerFactory) CephBucketService(com.instaclustr.esop.s3.ceph.CephBucketService) RestoreOperationRequest(com.instaclustr.esop.impl.restore.RestoreOperationRequest) StorageLocation(com.instaclustr.esop.impl.StorageLocation) CephRestorer(com.instaclustr.esop.s3.ceph.CephRestorer) Test(org.testng.annotations.Test)

Example 8 with StorageLocation

use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.

the class AzureListingAndBackupRemovalTest method destroy.

@Override
public void destroy() throws Exception {
    try {
        FileUtils.deleteDirectory(cassandraDir);
    } catch (final Exception ex) {
        logger.error("Unable to remove Cassandra dir " + cassandraDir);
    }
    try {
        ListOperationRequest request = new ListOperationRequest();
        request.storageLocation = new StorageLocation(getStorageLocation());
        new AzureBucketService(cloudStorageAccountFactory, request).delete(BUCKET_NAME);
    } catch (final Exception ex) {
        logger.error("Unable to remove bucket " + BUCKET_NAME);
    }
}
Also used : AzureBucketService(com.instaclustr.esop.azure.AzureBucketService) ListOperationRequest(com.instaclustr.esop.impl.list.ListOperationRequest) StorageLocation(com.instaclustr.esop.impl.StorageLocation)

Example 9 with StorageLocation

use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.

the class GoogleListingAndBackupRemovalTest method destroy.

@Override
public void destroy() throws Exception {
    try {
        FileUtils.deleteDirectory(cassandraDir);
    } catch (final Exception ex) {
        logger.error("Unable to remove Cassandra dir " + cassandraDir);
    }
    try {
        ListOperationRequest request = new ListOperationRequest();
        request.storageLocation = new StorageLocation(getStorageLocation());
        new GCPBucketService(storageFactory, request).delete(BUCKET_NAME);
    } catch (final Exception ex) {
        logger.error("Unable to remove bucket " + BUCKET_NAME);
    }
}
Also used : GCPBucketService(com.instaclustr.esop.gcp.GCPBucketService) ListOperationRequest(com.instaclustr.esop.impl.list.ListOperationRequest) StorageLocation(com.instaclustr.esop.impl.StorageLocation)

Example 10 with StorageLocation

use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.

the class StorageLocationTest method updateNodeIdLocationTest.

@Test
public void updateNodeIdLocationTest() {
    StorageLocation location = new StorageLocation("oracle://my-bucket/clusterName/datacenterId/nodeId");
    StorageLocation updated = StorageLocation.updateNodeId(location, "nodeId2");
    assertEquals(updated.storageProvider, "oracle");
    assertEquals(updated.bucket, "my-bucket");
    assertEquals(updated.clusterId, "clusterName");
    assertEquals(updated.datacenterId, "datacenterId");
    assertEquals(updated.nodeId, "nodeId2");
    assertTrue(updated.cloudLocation);
    assertFalse(updated.globalRequest);
}
Also used : StorageLocation(com.instaclustr.esop.impl.StorageLocation) Test(org.testng.annotations.Test)

Aggregations

StorageLocation (com.instaclustr.esop.impl.StorageLocation)24 Test (org.testng.annotations.Test)16 Path (java.nio.file.Path)9 ListOperationRequest (com.instaclustr.esop.impl.list.ListOperationRequest)6 RestoreOperationRequest (com.instaclustr.esop.impl.restore.RestoreOperationRequest)5 BackupOperationRequest (com.instaclustr.esop.impl.backup.BackupOperationRequest)4 AmazonS3 (com.amazonaws.services.s3.AmazonS3)2 AzureBucketService (com.instaclustr.esop.azure.AzureBucketService)2 GCPBucketService (com.instaclustr.esop.gcp.GCPBucketService)2 LocalFileRestorer (com.instaclustr.esop.local.LocalFileRestorer)2 S3BucketService (com.instaclustr.esop.s3.aws.S3BucketService)2 Bucket (com.google.cloud.storage.Bucket)1 Storage (com.google.cloud.storage.Storage)1 AzureBackuper (com.instaclustr.esop.azure.AzureBackuper)1 AzureRestorer (com.instaclustr.esop.azure.AzureRestorer)1 AbstractBackupTest (com.instaclustr.esop.backup.embedded.AbstractBackupTest)1 GCPBackuper (com.instaclustr.esop.gcp.GCPBackuper)1 GCPRestorer (com.instaclustr.esop.gcp.GCPRestorer)1 AllManifestsReport (com.instaclustr.esop.impl.Manifest.AllManifestsReport)1 ManifestReport (com.instaclustr.esop.impl.Manifest.ManifestReporter.ManifestReport)1