You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jclouds.apache.org by Adrian Cole <no...@github.com> on 2013/09/30 21:08:40 UTC

[jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Implementation of `BlobStoreContext` which allows you to employ multiple regions.

Example.

```java
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;);
```

Note similar methods are also exposed for blob signer and async blobstore.
You can merge this Pull Request by running:

  git pull https://github.com/adriancole/jclouds-labs-openstack openstack-swift-multiregion

Or you can view, comment on it, or merge it online at:

  https://github.com/jclouds/jclouds-labs-openstack/pull/34

-- Commit Summary --

  * JCLOUDS-299. implement multi-region support in openstack-swift

-- File Changes --

    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/SwiftApiMetadata.java (4)
    A openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContext.java (177)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedSwiftBlobStore.java (181)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedTemporaryUrlBlobSigner.java (31)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/config/SignUsingTemporaryUrls.java (63)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/config/SwiftBlobStoreContextModule.java (41)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/functions/ToResourceMetadata.java (7)
    M openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/internal/SubmissionAsyncBlobStore.java (2)
    A openstack-swift/src/test/java/org/jclouds/openstack/swift/v1/blobstore/RegionScopedBlobStoreContextLiveTest.java (89)

-- Patch Links --

https://github.com/jclouds/jclouds-labs-openstack/pull/34.patch
https://github.com/jclouds/jclouds-labs-openstack/pull/34.diff

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Adrian Cole <no...@github.com>.
commit 44021fc9eeaf9cc7886fd849323a2cdfc8bf97c7
Author: Adrian Cole <ad...@gmail.com>
Date:   Mon Sep 30 12:06:42 2013 -0700

    JCLOUDS-299. implement multi-region support in openstack-swift


---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34#issuecomment-25397233

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #65](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/65/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34#issuecomment-25396964

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Andrew Phillips <no...@github.com>.
> +      return new BlobBuilderImpl().name(name);
> +   }
> +
> +   @Override
> +   public boolean directoryExists(String containerName, String directory) {
> +      return api.objectApiInRegionForContainer(region.getId(), containerName) //
> +            .head(directory) != null;
> +   }
> +
> +   @Override
> +   public void createDirectory(String containerName, String directory) {
> +      api.objectApiInRegionForContainer(region.getId(), containerName) //
> +            .replace(directory, directoryPayload, ImmutableMap.<String, String> of());
> +   }
> +
> +   private final Payload directoryPayload = new ByteArrayPayload(new byte[] {}) {

Make static?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34/files#r7235196

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Adrian Cole <no...@github.com>.
passes on both Rackspace and HPCS

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34#issuecomment-25396751

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-openstack-pull-requests #64](https://jclouds.ci.cloudbees.com/job/jclouds-labs-openstack-pull-requests/64/) SUCCESS
This pull request looks good

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34#issuecomment-25394225

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Andrew Phillips <no...@github.com>.
>              }
>           });
>  
>     protected Function<SwiftObject, MutableBlobMetadata> toBlobMetadata(String container) {
>        return new ToBlobMetadata(containerCache.getUnchecked(container).get());
>     }
> +
> +   @Override
> +   public long countBlobs(String containerName, ListContainerOptions options) {
> +      throw new UnsupportedOperationException();

Add message?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34/files#r7235197

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Andrew Phillips <no...@github.com>.
> +   private final Supplier<String> implicitRegionId;
> +   // factory functions are decoupled so that you can exchange how requests are
> +   // signed or decorate without a class hierarchy dependency
> +   private final Function<String, BlobStore> blobStore;
> +   private final Function<String, BlobRequestSigner> blobRequestSigner;
> +   private final Utils utils;
> +   private final ListeningExecutorService executor;
> +
> +   @Inject
> +   public RegionScopedBlobStoreContext(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
> +         @Region Supplier<Set<String>> regionIds, @Region Supplier<String> implicitRegionId,
> +         Function<String, BlobStore> blobStore, Function<String, BlobRequestSigner> blobRequestSigner, Utils utils,
> +         @Named(PROPERTY_USER_THREADS) ListeningExecutorService executor) {
> +      super(backend, backendType);
> +      this.regionIds = checkNotNull(regionIds, "regionIds");
> +      this.implicitRegionId = checkNotNull(implicitRegionId, "implicitRegionId");

Should we also invoke `checkRegionId` here to ensure the implicit region is one of the "regular" regions, or do we take that on trust?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34/files#r7235186

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by Andrew Phillips <no...@github.com>.
> +   @Override
> +   public boolean directoryExists(String containerName, String directory) {
> +      return api.objectApiInRegionForContainer(region.getId(), containerName) //
> +            .head(directory) != null;
> +   }
> +
> +   @Override
> +   public void createDirectory(String containerName, String directory) {
> +      api.objectApiInRegionForContainer(region.getId(), containerName) //
> +            .replace(directory, directoryPayload, ImmutableMap.<String, String> of());
> +   }
> +
> +   private final Payload directoryPayload = new ByteArrayPayload(new byte[] {}) {
> +      {
> +         getContentMetadata().setContentType("application/directory");
> +      }

Am I getting this right...an anonymous subtype of ByteArrayPayload with a static initializer? Does `getContentMetadata().setContentType("application/directory");` work there?

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34/files#r7235192

Re: [jclouds-labs-openstack] JCLOUDS-299. implement multi-region support in openstack-swift (#34)

Posted by BuildHive <no...@github.com>.
[jclouds ยป jclouds-labs-openstack #461](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-openstack/461/) SUCCESS
This pull request looks good
[(what's this?)](https://www.cloudbees.com/what-is-buildhive)

---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-openstack/pull/34#issuecomment-25397426