use of com.instaclustr.esop.impl.RemoteObjectReference in project esop by instaclustr.
the class LocalFileRestorer method delete.
@Override
public void delete(Path objectKey, boolean nodeAware) throws Exception {
Path fileToDelete;
if (nodeAware) {
RemoteObjectReference remoteObjectReference = objectKeyToNodeAwareRemoteReference(objectKey);
fileToDelete = request.storageLocation.fileBackupDirectory.resolve(request.storageLocation.bucket).resolve(remoteObjectReference.canonicalPath);
} else {
fileToDelete = request.storageLocation.fileBackupDirectory.resolve(request.storageLocation.bucket).resolve(objectKey);
}
Files.deleteIfExists(fileToDelete);
}
use of com.instaclustr.esop.impl.RemoteObjectReference in project esop by instaclustr.
the class BaseS3Restorer method delete.
@Override
public void delete(final Path objectKey, boolean nodeAware) throws Exception {
RemoteObjectReference remoteObjectReference;
if (nodeAware) {
remoteObjectReference = objectKeyToNodeAwareRemoteReference(objectKey);
} else {
remoteObjectReference = objectKeyToRemoteReference(objectKey);
}
final Path fileToDelete = Paths.get(request.storageLocation.bucket, remoteObjectReference.canonicalPath);
logger.info("Non dry: " + fileToDelete);
amazonS3.deleteObject(new DeleteObjectRequest(request.storageLocation.bucket, remoteObjectReference.canonicalPath));
}
use of com.instaclustr.esop.impl.RemoteObjectReference in project esop by instaclustr.
the class RestoreCommitLogsOperation method downloadCommitLogs.
private void downloadCommitLogs(final Restorer restorer) throws Exception {
final RemoteObjectReference remoteObjectReference = restorer.objectKeyToNodeAwareRemoteReference(Paths.get("commitlog"));
final Pattern commitlogPattern = Pattern.compile(".*(CommitLog-\\d+-\\d+\\.log)\\.(\\d+)");
final Set<ManifestEntry> parsedCommitlogList = new HashSet<>();
logger.info("Commencing processing of commit log listing");
final AtomicReference<ManifestEntry> overhangingManifestEntry = new AtomicReference<>();
final AtomicLong overhangingTimestamp = new AtomicLong(Long.MAX_VALUE);
restorer.consumeFiles(remoteObjectReference, commitlogFile -> {
final Matcher matcherCommitlog = commitlogPattern.matcher(commitlogFile.getObjectKey().toString());
if (matcherCommitlog.matches()) {
final long commitlogTimestamp = Long.parseLong(matcherCommitlog.group(2));
if (commitlogTimestamp >= request.timestampStart && commitlogTimestamp <= request.timestampEnd) {
parsedCommitlogList.add(new ManifestEntry(commitlogFile.getObjectKey(), request.commitlogDownloadDir.resolve(matcherCommitlog.group(1)), COMMIT_LOG, 0, null, null));
} else if (commitlogTimestamp > request.timestampEnd && commitlogTimestamp < overhangingTimestamp.get()) {
// Make sure we also catch the first commitlog that goes past the end of the timestamp
overhangingTimestamp.set(commitlogTimestamp);
overhangingManifestEntry.set(new ManifestEntry(commitlogFile.getObjectKey(), request.commitlogDownloadDir.resolve(matcherCommitlog.group(1)), COMMIT_LOG, 0, null, null));
}
}
});
if (overhangingManifestEntry.get() != null) {
parsedCommitlogList.add(overhangingManifestEntry.get());
}
logger.info("Found {} commit logs to download", parsedCommitlogList.size());
if (parsedCommitlogList.size() == 0) {
return;
}
Session<DownloadUnit> downloadSession = null;
try {
downloadSession = downloadTracker.submit(restorer, this, parsedCommitlogList, null, this.request.concurrentConnections);
downloadSession.waitUntilConsideredFinished();
downloadTracker.cancelIfNecessary(downloadSession);
} finally {
downloadTracker.removeSession(downloadSession);
}
}
use of com.instaclustr.esop.impl.RemoteObjectReference in project esop by instaclustr.
the class GCPRestorer method delete.
@Override
public void delete(Path objectKey, boolean nodeAware) throws Exception {
RemoteObjectReference remoteObjectReference;
if (nodeAware) {
remoteObjectReference = objectKeyToNodeAwareRemoteReference(objectKey);
} else {
remoteObjectReference = objectKeyToRemoteReference(objectKey);
}
logger.info("Non dry: " + Paths.get(request.storageLocation.bucket, remoteObjectReference.canonicalPath));
storage.delete(((GCPRemoteObjectReference) remoteObjectReference).blobId);
}
use of com.instaclustr.esop.impl.RemoteObjectReference in project esop by instaclustr.
the class BaseS3Restorer method consumeFiles.
@Override
public void consumeFiles(final RemoteObjectReference prefix, final Consumer<RemoteObjectReference> consumer) {
final Path bucketPath = Paths.get(request.storageLocation.clusterId).resolve(request.storageLocation.datacenterId).resolve(request.storageLocation.nodeId);
ObjectListing objectListing = amazonS3.listObjects(request.storageLocation.bucket, prefix.canonicalPath);
boolean hasMoreContent = true;
while (hasMoreContent) {
objectListing.getObjectSummaries().stream().filter(objectSummary -> !objectSummary.getKey().endsWith("/")).forEach(objectSummary -> consumer.accept(objectKeyToNodeAwareRemoteReference(bucketPath.relativize(Paths.get(objectSummary.getKey())))));
if (objectListing.isTruncated()) {
objectListing = amazonS3.listNextBatchOfObjects(objectListing);
} else {
hasMoreContent = false;
}
}
}
Aggregations