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);
}
}
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"));
}
}
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);
}
}
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);
}
}
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);
}
Aggregations