use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.
the class BaseS3Restorer method listManifests.
@Override
public List<Manifest> listManifests() throws Exception {
// If skipDownload flag is not set, download manifests
if (this.request instanceof ListOperationRequest) {
if (!((ListOperationRequest) this.request).skipDownload) {
StorageLocation location = this.localFileRestorer.getStorageLocation();
Path downloadDirectory = location.fileBackupDirectory.resolve(this.localFileRestorer.getStorageLocation().bucket);
downloadManifestsToDirectory(downloadDirectory);
}
}
return localFileRestorer.listManifests();
}
use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.
the class ListOperationRequest method getForLocalListing.
public static ListOperationRequest getForLocalListing(final BaseRestoreOperationRequest request, final Path cacheDir, final StorageLocation original) {
final Path localPathToNode = cacheDir.resolve(original.bucket).resolve(original.clusterId).resolve(original.datacenterId).resolve(original.nodeId);
final StorageLocation cacheLocation = new StorageLocation("file://" + localPathToNode);
return new ListOperationRequest("list", cacheLocation, request.k8sNamespace, request.k8sSecretName, request.insecure, request.skipBucketVerification, request.proxySettings, request.retry, false, false, false, null, false, null, null, true, cacheDir, false, null, null);
}
use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.
the class GCPRestorer method listManifests.
@Override
public List<Manifest> listManifests() throws Exception {
// If skipDownload flag is not set, download manifests
if (this.request instanceof ListOperationRequest) {
if (!((ListOperationRequest) this.request).skipDownload) {
StorageLocation location = this.localFileRestorer.getStorageLocation();
Path downloadDirectory = location.fileBackupDirectory.resolve(this.localFileRestorer.getStorageLocation().bucket);
downloadManifestsToDirectory(downloadDirectory);
}
}
return localFileRestorer.listManifests();
}
use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.
the class AzureRestorer method listManifests.
@Override
public List<Manifest> listManifests() throws Exception {
// If skipDownload flag is not set, download manifests
if (this.request instanceof ListOperationRequest) {
if (!((ListOperationRequest) this.request).skipDownload) {
StorageLocation location = this.localFileRestorer.getStorageLocation();
Path downloadDirectory = location.fileBackupDirectory.resolve(this.localFileRestorer.getStorageLocation().bucket);
downloadManifestsToDirectory(downloadDirectory);
}
}
return localFileRestorer.listManifests();
}
use of com.instaclustr.esop.impl.StorageLocation in project esop by instaclustr.
the class AWSS3BackupRestoreTest method testDownload.
@Test
public void testDownload() throws Exception {
S3TransferManagerFactory factory = getTransferManagerFactory();
S3BucketService s3BucketService = new S3BucketService(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("s3://" + BUCKET_NAME + "/cluster/dc/node");
final BackupOperationRequest backupOperationRequest = new BackupOperationRequest();
backupOperationRequest.storageLocation = new StorageLocation("s3://" + BUCKET_NAME + "/cluster/dc/node");
final S3Restorer s3Restorer = new S3Restorer(factory, restoreOperationRequest);
final S3Backuper s3Backuper = new S3Backuper(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"));
}
}
Aggregations