You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Andrew Gaul <no...@github.com> on 2016/06/17 20:27:51 UTC

[jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds-labs/pull/288

-- Commit Summary --

  * JCLOUDS-1005: Backblaze B2 portable abstraction

-- File Changes --

    M b2/pom.xml (1)
    M b2/src/main/java/org/jclouds/b2/B2ApiMetadata.java (5)
    A b2/src/main/java/org/jclouds/b2/blobstore/B2BlobStore.java (481)
    A b2/src/main/java/org/jclouds/b2/blobstore/config/B2BlobStoreContextModule.java (32)
    M b2/src/main/java/org/jclouds/b2/domain/B2Object.java (7)
    M b2/src/main/java/org/jclouds/b2/functions/ParseB2ObjectFromResponse.java (4)
    A b2/src/test/java/org/jclouds/b2/blobstore/integration/B2BlobIntegrationLiveTest.java (264)
    A b2/src/test/java/org/jclouds/b2/blobstore/integration/B2BlobLiveTest.java (42)
    A b2/src/test/java/org/jclouds/b2/blobstore/integration/B2BlobSignerLiveTest.java (102)
    A b2/src/test/java/org/jclouds/b2/blobstore/integration/B2ContainerIntegrationLiveTest.java (74)
    A b2/src/test/java/org/jclouds/b2/blobstore/integration/B2ContainerLiveTest.java (27)

-- Patch Links --

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

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Zack Shoylev <no...@github.com>.
Looks pretty good.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288#issuecomment-227459905

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Zack Shoylev <no...@github.com>.
> +      String delimiter = null;
> +      if (!options.isRecursive()) {
> +         delimiter = "/";
> +      }
> +      if (options.getDelimiter() != null) {
> +         delimiter = options.getDelimiter();
> +      }
> +
> +      Bucket bucket = getBucket(container);
> +
> +      ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder();
> +      B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), options.getMarker(), options.getMaxResults());
> +      Set<String> commonPrefixes = Sets.newHashSet();
> +      for (B2ObjectList.Entry entry : list.files()) {
> +         // B2 does not support server-side filtering via prefix and delimiter so we emulate it on the client.
> +         // TODO: cooperate with maxResults

What about the TODO?

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288/files/80e8fd4b2040ca8ea637d1efc1ab83000dcbe293#r67733789

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Andrew Gaul <no...@github.com>.
@nacx @zack-shoylev Please review.  This is the last big commit!

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288#issuecomment-226873432

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Andrew Gaul <no...@github.com>.
> +      String delimiter = null;
> +      if (!options.isRecursive()) {
> +         delimiter = "/";
> +      }
> +      if (options.getDelimiter() != null) {
> +         delimiter = options.getDelimiter();
> +      }
> +
> +      Bucket bucket = getBucket(container);
> +
> +      ImmutableList.Builder<StorageMetadata> builder = ImmutableList.builder();
> +      B2ObjectList list = api.getObjectApi().listFileNames(bucket.bucketId(), options.getMarker(), options.getMaxResults());
> +      Set<String> commonPrefixes = Sets.newHashSet();
> +      for (B2ObjectList.Entry entry : list.files()) {
> +         // B2 does not support server-side filtering via prefix and delimiter so we emulate it on the client.
> +         // TODO: cooperate with maxResults

Done.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288/files/80e8fd4b2040ca8ea637d1efc1ab83000dcbe293#r67791647

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Zack Shoylev <no...@github.com>.
> +         throw new UnsupportedOperationException("B2 only supports private access blobs");
> +      }
> +
> +      if (options.isMultipart()) {
> +         return putMultipartBlob(container, blob, options);
> +      } else {
> +         String contentSha1;
> +         try {
> +            contentSha1 = ByteStreams2.hashAndClose(blob.getPayload().openStream(), Hashing.sha1()).toString();
> +         } catch (IOException ioe) {
> +            throw Throwables.propagate(ioe);
> +         }
> +
> +         String name = blob.getMetadata().getName();
> +
> +         // B2 versions all files so we store the original fileId to delete it after the upload succeeds

I see. Should we be doing this, though? I am not sure, from a user perspective, what the expected behavior would be.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288/files/80e8fd4b2040ca8ea637d1efc1ab83000dcbe293#r67730777

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Andrew Gaul <no...@github.com>.
> +         throw new UnsupportedOperationException("B2 only supports private access blobs");
> +      }
> +
> +      if (options.isMultipart()) {
> +         return putMultipartBlob(container, blob, options);
> +      } else {
> +         String contentSha1;
> +         try {
> +            contentSha1 = ByteStreams2.hashAndClose(blob.getPayload().openStream(), Hashing.sha1()).toString();
> +         } catch (IOException ioe) {
> +            throw Throwables.propagate(ioe);
> +         }
> +
> +         String name = blob.getMetadata().getName();
> +
> +         // B2 versions all files so we store the original fileId to delete it after the upload succeeds

The implemented behavior matches other blobstores.  Otherwise if a user issues an overwrite followed by a delete, the original file reappears.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288/files/80e8fd4b2040ca8ea637d1efc1ab83000dcbe293#r67775394

Re: [jclouds/jclouds-labs] JCLOUDS-1005: Backblaze B2 portable abstraction (#288)

Posted by Zack Shoylev <no...@github.com>.
> +         throw new UnsupportedOperationException("B2 only supports private access blobs");
> +      }
> +
> +      if (options.isMultipart()) {
> +         return putMultipartBlob(container, blob, options);
> +      } else {
> +         String contentSha1;
> +         try {
> +            contentSha1 = ByteStreams2.hashAndClose(blob.getPayload().openStream(), Hashing.sha1()).toString();
> +         } catch (IOException ioe) {
> +            throw Throwables.propagate(ioe);
> +         }
> +
> +         String name = blob.getMetadata().getName();
> +
> +         // B2 versions all files so we store the original fileId to delete it after the upload succeeds

I see, makes sense.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/288/files/80e8fd4b2040ca8ea637d1efc1ab83000dcbe293#r67879958