You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ga...@apache.org on 2014/07/28 03:23:01 UTC
git commit: JCLOUDS-457: Add Clear vault strategy
Repository: jclouds-labs-aws
Updated Branches:
refs/heads/master 5c63245f9 -> 377c58fba
JCLOUDS-457: Add Clear vault strategy
Added a proper implementation to the Clear vault strategy
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/commit/377c58fb
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/tree/377c58fb
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/diff/377c58fb
Branch: refs/heads/master
Commit: 377c58fbaa5758b1bd4e17f9096b0cbe21e0b5f0
Parents: 5c63245
Author: Roman Coedo <ro...@gmail.com>
Authored: Sat Jul 26 12:12:29 2014 +0200
Committer: Andrew Gaul <ga...@apache.org>
Committed: Sun Jul 27 16:42:51 2014 -0700
----------------------------------------------------------------------
.../blobstore/strategy/ClearVaultStrategy.java | 30 ++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds-labs-aws/blob/377c58fb/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java
----------------------------------------------------------------------
diff --git a/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java b/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java
index f378ec2..276ed01 100644
--- a/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java
+++ b/glacier/src/main/java/org/jclouds/glacier/blobstore/strategy/ClearVaultStrategy.java
@@ -16,15 +16,41 @@
*/
package org.jclouds.glacier.blobstore.strategy;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import org.jclouds.blobstore.options.ListContainerOptions;
import org.jclouds.blobstore.strategy.ClearListStrategy;
+import org.jclouds.glacier.GlacierClient;
+import org.jclouds.glacier.domain.ArchiveMetadata;
+import org.jclouds.glacier.domain.ArchiveMetadataCollection;
+import org.jclouds.glacier.domain.InventoryRetrievalJobRequest;
+import com.google.inject.Inject;
import com.google.inject.Singleton;
@Singleton
public class ClearVaultStrategy implements ClearListStrategy {
+ private final GlacierClient sync;
+ private final PollingStrategy pollingStrategy;
+
+ @Inject
+ public ClearVaultStrategy(GlacierClient sync, PollingStrategy pollingStrategy) {
+ this.pollingStrategy = checkNotNull(pollingStrategy, "pollingStrategy");
+ this.sync = checkNotNull(sync, "sync");
+ }
+
@Override
- public void execute(String s, ListContainerOptions listContainerOptions) {
- return;
+ public void execute(String container, ListContainerOptions listContainerOptions) {
+ String jobId = sync.initiateJob(container, InventoryRetrievalJobRequest.builder().build());
+ try {
+ if (pollingStrategy.waitForSuccess(container, jobId)) {
+ ArchiveMetadataCollection archives = sync.getInventoryRetrievalOutput(container, jobId);
+ for(ArchiveMetadata archive : archives) {
+ sync.deleteArchive(container, archive.getArchiveId());
+ }
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
}
}