You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by jd...@apache.org on 2014/07/24 21:56:02 UTC

git commit: Deprecated RegionScopedBlobStore methods in favor of common naming conventions

Repository: jclouds-labs-openstack
Updated Branches:
  refs/heads/master a05f207d5 -> c90efaacb


Deprecated RegionScopedBlobStore methods in favor of common naming conventions


Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/commit/c90efaac
Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/tree/c90efaac
Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/diff/c90efaac

Branch: refs/heads/master
Commit: c90efaacb42207f0bcf40a9e31ca14f385692657
Parents: a05f207
Author: Jeremy Daggett <je...@rackspace.com>
Authored: Wed Jul 23 11:41:04 2014 -0700
Committer: Jeremy Daggett <je...@rackspace.com>
Committed: Thu Jul 24 12:55:43 2014 -0700

----------------------------------------------------------------------
 .../blobstore/RegionScopedBlobStoreContext.java | 70 +++++++++++++++++---
 .../RegionScopedBlobStoreContextLiveTest.java   | 16 ++---
 2 files changed, 68 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/c90efaac/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java
index 6848b7f..e00350a 100644
--- a/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java
+++ b/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java
@@ -43,14 +43,14 @@ import com.google.common.util.concurrent.ListeningExecutorService;
 /**
  * Implementation of {@link BlobStoreContext} which allows you to employ
  * multiple regions.
- * 
+ *
  * Example.
- * 
+ *
  * <pre>
  * ctx = contextBuilder.buildView(RegionScopedBlobStoreContext.class);
- * 
+ *
  * Set&lt;String&gt; regionIds = ctx.configuredRegions();
- * 
+ *
  * // isolated to a specific region
  * BlobStore texasBlobStore = ctx.blobStoreInRegion(&quot;US-TX&quot;);
  * BlobStore virginiaBlobStore = ctx.blobStoreInRegion(&quot;US-VA&quot;);
@@ -60,8 +60,19 @@ public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreC
 
    /**
     * @return regions supported in this context.
+    *
+    * @deprecated Please use {{@link #getConfiguredRegions()} as this method will be
+    *             removed in jclouds 2.0.
     */
+   @Deprecated
    public Set<String> configuredRegions() {
+      return getConfiguredRegions();
+   }
+
+   /**
+    * @return regions supported in this context.
+    */
+   public Set<String> getConfiguredRegions() {
       return regionIds.get();
    }
 
@@ -70,8 +81,22 @@ public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreC
     *           valid region id from {@link #configuredRegions()}
     * @throws IllegalArgumentException
     *            if {@code regionId} was invalid.
+    *
+    * @deprecated Please use {{@link #getConfiguredRegions()} as this method will be
+    *             removed in jclouds 2.0.
     */
+   @Deprecated
    public BlobStore blobStoreInRegion(String regionId) {
+      return getBlobStoreForRegion(regionId);
+   }
+
+   /**
+    * @param regionId
+    *           valid region id from {@link #getConfiguredRegions()}
+    * @throws IllegalArgumentException
+    *            if {@code regionId} was invalid.
+    */
+   public BlobStore getBlobStoreForRegion(String regionId) {
       checkRegionId(regionId);
       return blobStore.apply(regionId);
    }
@@ -81,8 +106,22 @@ public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreC
     *           valid region id from {@link #configuredRegions()}
     * @throws IllegalArgumentException
     *            if {@code regionId} was invalid.
+    *
+    * @deprecated Please use {{@link #getSignerInRegion(String)} as this method will be
+    *             removed in jclouds 2.0.
     */
+   @Deprecated
    public BlobRequestSigner signerInRegion(String regionId) {
+      return getSignerForRegion(regionId);
+   }
+
+   /**
+    * @param regionId
+    *           valid region id from {@link #getConfiguredRegions()}
+    * @throws IllegalArgumentException
+    *            if {@code regionId} was invalid.
+    */
+   public BlobRequestSigner getSignerForRegion(String regionId) {
       checkRegionId(regionId);
       return blobRequestSigner.apply(regionId);
    }
@@ -95,15 +134,26 @@ public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreC
     *            {@link org.jclouds.blobstore.BlobStore}
     */
    @Deprecated
-   public org.jclouds.blobstore.AsyncBlobStore asyncBlobStoreInRegion(String regionId) {
+   public org.jclouds.blobstore.AsyncBlobStore getAsyncBlobStoreForRegion(String regionId) {
       checkRegionId(regionId);
       return new org.jclouds.openstack.swift.v1.blobstore.internal.SubmissionAsyncBlobStore(
             blobStoreInRegion(regionId), executor);
    }
+   /**
+    * @param regionId
+    *           valid region id from {@link #configuredRegions()}
+    * @throws IllegalArgumentException
+    *            if {@code regionId} was invalid. longer supported. Please use
+    *            {@link org.jclouds.blobstore.BlobStore}
+    */
+   @Deprecated
+   public org.jclouds.blobstore.AsyncBlobStore asyncBlobStoreInRegion(String regionId) {
+      return getAsyncBlobStoreForRegion(regionId);
+   }
 
    protected void checkRegionId(String regionId) {
-      checkArgument(configuredRegions().contains(checkNotNull(regionId, "regionId was null")), "region %s not in %s",
-            regionId, configuredRegions());
+      checkArgument(getConfiguredRegions().contains(checkNotNull(regionId, "regionId was null")), "region %s not in %s",
+            regionId, getConfiguredRegions());
    }
 
    private final Supplier<Set<String>> regionIds;
@@ -136,18 +186,18 @@ public class RegionScopedBlobStoreContext extends BaseView implements BlobStoreC
 
    @Override
    public BlobStore getBlobStore() {
-      return blobStoreInRegion(implicitRegionId.get());
+      return getBlobStoreForRegion(implicitRegionId.get());
    }
 
    @Override
    public BlobRequestSigner getSigner() {
-      return signerInRegion(implicitRegionId.get());
+      return getSignerForRegion(implicitRegionId.get());
    }
 
    @Override
    @Deprecated
    public org.jclouds.blobstore.AsyncBlobStore getAsyncBlobStore() {
-      return asyncBlobStoreInRegion(implicitRegionId.get());
+      return getAsyncBlobStoreForRegion(implicitRegionId.get());
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/jclouds-labs-openstack/blob/c90efaac/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java
----------------------------------------------------------------------
diff --git a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java
index 75f273e..17d309d 100644
--- a/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java
+++ b/openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java
@@ -51,14 +51,14 @@ public class RegionScopedBlobStoreContextLiveTest extends BaseBlobStoreIntegrati
 
    @Test
    public void regionsAreNotEmpty() {
-      assertFalse(RegionScopedBlobStoreContext.class.cast(view).configuredRegions().isEmpty());
+      assertFalse(RegionScopedBlobStoreContext.class.cast(view).getConfiguredRegions().isEmpty());
    }
 
    @Test
    public void locationsMatch() {
       RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view);
-      for (String regionId : ctx.configuredRegions()) {
-         Set<? extends Location> locations = ctx.blobStoreInRegion(regionId).listAssignableLocations();
+      for (String regionId : ctx.getConfiguredRegions()) {
+         Set<? extends Location> locations = ctx.getBlobStoreForRegion(regionId).listAssignableLocations();
          assertEquals(locations.size(), 1, "expected one region " + regionId + " " + locations);
          Location location = locations.iterator().next();
          assertEquals(location.getId(), regionId, "region id " + regionId + " didn't match getId(): " + location);
@@ -68,16 +68,16 @@ public class RegionScopedBlobStoreContextLiveTest extends BaseBlobStoreIntegrati
    @Test
    public void tryList() throws InterruptedException, ExecutionException {
       RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view);
-      for (String regionId : ctx.configuredRegions()) {
-         assertEquals(ctx.asyncBlobStoreInRegion(regionId).list().get(), ctx.blobStoreInRegion(regionId).list());
+      for (String regionId : ctx.getConfiguredRegions()) {
+         assertEquals(ctx.getAsyncBlobStoreForRegion(regionId).list().get(), ctx.getBlobStoreForRegion(regionId).list());
       }
    }
 
    @Test
    public void trySign() throws InterruptedException, ExecutionException {
       RegionScopedBlobStoreContext ctx = RegionScopedBlobStoreContext.class.cast(view);
-      for (String regionId : ctx.configuredRegions()) {
-         BlobStore region = ctx.blobStoreInRegion(regionId);
+      for (String regionId : ctx.getConfiguredRegions()) {
+         BlobStore region = ctx.getBlobStoreForRegion(regionId);
          PageSet<? extends StorageMetadata> containers = region.list();
          if (containers.isEmpty()) {
             continue;
@@ -88,7 +88,7 @@ public class RegionScopedBlobStoreContextLiveTest extends BaseBlobStoreIntegrati
             continue;
          }
          String blobName = Iterables.getLast(blobs).getName();
-         HttpRequest request = ctx.signerInRegion(regionId).signGetBlob(containerName, blobName);
+         HttpRequest request = ctx.getSignerForRegion(regionId).signGetBlob(containerName, blobName);
          assertNotNull(request, "regionId=" + regionId + ", container=" + containerName + ", blob=" + blobName);
       }
    }