You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Bhathiya <no...@github.com> on 2014/09/03 02:25:24 UTC
[jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction (#48)
JCLOUDS-458:Added Blobstore Abstraction
Minor Changes testCopyUrl
You can merge this Pull Request by running:
git pull https://github.com/hsbhathiya/jclouds-labs-google BlobAbStream
Or you can view, comment on it, or merge it online at:
https://github.com/jclouds/jclouds-labs-google/pull/48
-- Commit Summary --
* JCLOUDS-458:Added Blobstore Abstraction
-- File Changes --
M google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/GoogleCloudStorageApiMetadata.java (4)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSAsyncBlobStore.java (289)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/GCSBlobStore.java (282)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/config/GCSBlobStoreContextModule.java (35)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobMetadataToObjectTemplate.java (59)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BlobStoreListContainerOptionsToListObjectOptions.java (51)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/BucketToStorageMetadata.java (47)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectListToStorageMetadata.java (65)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/functions/ObjectToBlobMetadata.java (79)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/MultipartNamingStrategy.java (30)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/MultipartUpload.java (33)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/MultipartUploadSlicingAlgorithm.java (139)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/MultipartUploadStrategy.java (26)
A google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java (106)
M google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/GCSObject.java (17)
M google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/domain/templates/ObjectTemplate.java (14)
M google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/BucketApi.java (26)
M google-cloud-storage/src/main/java/org/jclouds/googlecloudstorage/features/ObjectApi.java (4)
A google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobIntegrationLiveTest.java (246)
A google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSBlobLiveTest.java (113)
A google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerIntegrationTest.java (100)
A google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/blobstore/integration/GCSContainerLiveTest.java (28)
M google-cloud-storage/src/test/java/org/jclouds/googlecloudstorage/features/BucketApiLiveTest.java (9)
-- Patch Links --
https://github.com/jclouds/jclouds-labs-google/pull/48.patch
https://github.com/jclouds/jclouds-labs-google/pull/48.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
I have addresses issues other than using "test.google-cloud-storage.project-number" dependency
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54711622
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + .contentType(type);
> + addContentMetadata(blobBuilder);
> + Blob blob = blobBuilder.build();
> + blob.getPayload().setContentMetadata(blob.getMetadata().getContentMetadata());
> + String container = getContainerName();
> +
> + try {
> + assertNotNull(view.getBlobStore().putBlob(container, blob));
> + blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
> + validateMetadata(blob.getMetadata(), container, name);
> + checkContentMetadata(blob);
> +
> + String returnedString = getContentAsStringOrNullAndClose(blob);
> + assertEquals(returnedString, realObject);
> + PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
> + assert set.size() >= 1 : set;
`assertThat(set).isNotEmpty()`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17027050
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import com.google.inject.Inject;
> +import org.jclouds.blobstore.reference.BlobStoreConstants;
> +import org.jclouds.logging.Logger;
> +
> +import javax.annotation.Resource;
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + // 2MB for testing purposes. Change to a reasonable value
> + static final long DEFAULT_PART_SIZE = 2 * 1024 * 1024; // 2MB //33554432; // 32MB
What should the value be here? We can override this with a property which will set 2 MB for tests only.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216131
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-google-pull-requests #142](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/142/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-55045013
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata), null);
> + }
> + }.apply(api.getBucketApi().listBucket(projectId.get()));
> + }
> +
> + @Override
> + public boolean containerExists(String container) {
> + return api.getBucketApi().bucketExist(container);
> + }
> +
> + @Override
> + public boolean createContainerInLocation(Location location, String container) {
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.Location
Import `DomainResourceRefferences`? Also it has a misspelling, should be References.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216078
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.inject.Inject;
> +import com.google.inject.Singleton;
> +
> +@Singleton
> +public class BucketToStorageMetadata implements Function<Bucket, StorageMetadata> {
> + private Supplier<Location> defaultLocation;
> +
> + @Inject
> + BucketToStorageMetadata(Supplier<Location> defaultLocation) {
> + this.defaultLocation = defaultLocation;
> + }
> +
> + public StorageMetadata apply(Bucket from) {
Here we don't check for `from == null`, but we do above...any reason?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817567
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + BlobStore blobStore = view.getBlobStore();
> + blobStore.createContainerInLocation(null, containerName);
> + Blob blob = blobStore.blobBuilder(key).payload(sourceToUpload).contentLength(sourceToUpload.size())
> + .contentType(MediaType.TEXT_PLAIN).build();
> + blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
> + }
> +
> + private ByteSource createFileBiggerThan(long partSize) throws IOException {
> + long copiesNeeded = (partSize / getOneHundredOneConstitutionsLength()) + 1;
> + ByteSource temp = ByteSource.concat(oneHundredOneConstitutions);
> +
> + for (int i = 0; i < copiesNeeded; i++) {
> + temp = ByteSource.concat(temp, oneHundredOneConstitutions);
> + }
> + return temp;
Can you use `TestUtils.randomByteSource` instead? This is more efficient and succinct.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210240
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.googlecloudstorage.options.ListObjectOptions;
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");
Should the main code rely on a test property?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17153105
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
1- Let's address locations in a subsequent PR as you suggest.
2- BuildHive shouldn't run the integration tests, it should just run the unit tests?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54755998
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
> - @Nullable
> - void deleteBucket(@PathParam("bucket") String bucketName);
> + boolean deleteBucket(@PathParam("bucket") String bucketName);
>
> /**
> * Permanently deletes an empty Bucket.If bucket is not empty 409 error to indicate the conflict.
How will you as a user see the 409 error?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817671
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata), null);
> + }
> + }.apply(api.getBucketApi().listBucket(projectId.get()));
> + }
> +
> + @Override
> + public boolean containerExists(String container) {
> + return api.getBucketApi().bucketExist(container);
> + }
> +
> + @Override
> + public boolean createContainerInLocation(Location location, String container) {
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location
[minor] Wrapping?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817461
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.blobstore.strategy.IfDirectoryReturnNameStrategy;
> +import org.jclouds.googlecloudstorage.domain.GCSObject;
> +import com.google.common.base.Function;
> +import com.google.common.collect.ImmutableMap;
> +
> +@Singleton
> +public class ObjectToBlobMetadata implements Function<GCSObject, MutableBlobMetadata> {
> + private final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
> +
> + @Inject
> + public ObjectToBlobMetadata(IfDirectoryReturnNameStrategy ifDirectoryReturnName) {
> + this.ifDirectoryReturnName = ifDirectoryReturnName;
> + }
> +
> + public MutableBlobMetadata apply(GCSObject from) {
> + if (from == null)
I'd ask for `{...}` here but I see other places where we don't use them in situations like this.
Thoughts on that, @andrewgaul!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817580
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Inject
> + public ObjectListToStorageMetadata(ObjectToBlobMetadata object2blobMd) {
> + this.object2blobMd = object2blobMd;
> + }
> +
> + public PageSet<? extends StorageMetadata> apply(ListPage<GCSObject> from) {
> + if (from == null) {
> + from = ListPage.<GCSObject> builder().kind(Kind.OBJECTS).build();
> + }
> +
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(Iterables.transform(from, object2blobMd),
> + new Function<BlobMetadata, StorageMetadata>() {
> + public StorageMetadata apply(BlobMetadata input) {
> + Map<String, String> userMetaData = (input != null && input.getUserMetadata() != null) ? input
> + .getUserMetadata() : ImmutableMap.<String, String> of();
> + if (input.getContentMetadata().getContentType().equals("application/directory")) {
Is there a constant we can use instead of `application/directory`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817577
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + @Override
> + @Test(enabled = false)
> + public void testGetRange() {
> + // not supported in GCS
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testCreateBlobWithExpiry() throws InterruptedException {
> + // not supported in object level.
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testFileGetParallel() throws Exception {
> + // Implement Parallel uploads
Can you `throw SkipException` for this and the subsequent tests so that surefire flags them?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17027006
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
> + maxResults(1).withDetails());
> +
> + BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0));
> +
> + assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata()
> + .getContentType();
> + assertEquals(metadata.getContentMetadata().getContentLength(), Long.valueOf(TEST_STRING.length()));
> + assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff");
> + checkMD5(metadata);
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + /** Google Cloud Storage lists prefixes and objects in two different lists */
[minor] No need for Javadoc in tests? `// ...` instead?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817728
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public class MultipartUpload {
> +
> + protected MultipartUpload() {
You don't need to extend this in `MultipartUploadStrategy`; it does not provide any methods or non-static fields to inherit. Once jclouds/jclouds#512 goes in, Checkstyle will complain about this anti-pattern.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17274625
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + blob.getMetadata().getUserMetadata().put("adrian", "wonderpuff");
> + blob.getMetadata().getUserMetadata().put("adrian", "powderpuff");
> +
> + addBlobToContainer(container, blob);
> + validateMetadata(view.getBlobStore().blobMetadata(container, name));
> +
> + } finally {
> + returnContainer(container);
> + }
> + }
> +
> + @Override
> + protected void checkMD5(BlobMetadata metadata) throws IOException {
> + HashFunction hf = Hashing.md5();
> + HashCode md5 = hf.newHasher().putString(TEST_STRING, Charsets.UTF_8).hash();
Simplify to:
```
HashCode md5 = Hashing.md5().hashString(TEST_STRING, Charsets.UTF_8);
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210232
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
Yep ,I understand it is not nice. But removing it gives 503 errors.What could be the alternative to introduce a time gap between 2 requests?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17214076
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
@hsbhathiya I reproduced your problem locally running `mvn verify -pl google-cloud-storage` but do not yet understand it. I will continue investigating.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54765960
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public class MultipartUpload {
> +
> + protected MultipartUpload() {
Extended in MultipartUploadStrategy.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17225174
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Override
> + public boolean blobExists(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + return api.getObjectApi().objectExist(container, urlName);
> + } catch (UnsupportedEncodingException e) {
> + throw Throwables.propagate(e);
> + }
> + }
> +
> + /**
> + * This supports multipart/related upload which has exactly 2 parts, media-part and metadata-part
> + */
> + @Override
> + public String putBlob(String container, Blob blob) {
> + checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
Add an error message
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817489
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> @@ -36,7 +36,7 @@
>
> /**
> * This class represent an object in a Google Cloud Storage Bucket.
> - *
> + *
Spurious change.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17026977
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + private long PART_SIZE = MultipartUpload.MIN_PART_SIZE;
> +
> + @Override
> + protected Properties setupProperties() {
> + Properties properties = super.setupProperties();
> + properties.put("jclouds.mpu.parts.size", 2 * 1024 * 1024);
> + return properties;
> + }
> +
> + public GCSBlobIntegrationLiveTest() throws IOException {
> + provider = "google-cloud-storage";
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testGetTwoRanges() throws SkipException {
Do we need the `throws SkipException`. And do we do `@Test(enabled = false` or `throws SkipException(...)`?
/cc @andrewgaul
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817688
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.testng.SkipException;
> +import org.testng.annotations.DataProvider;
> +import org.testng.annotations.Test;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.collect.ImmutableMap;
> +import com.google.common.hash.HashCode;
> +import com.google.common.hash.HashFunction;
> +import com.google.common.hash.Hashing;
> +import com.google.common.io.ByteSource;
> +import com.google.common.io.Files;
> +
> +@Test(groups = { "live", "blobstorelive" })
> +public class GCSBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
> +
> + private long PART_SIZE = MultipartUpload.MIN_PART_SIZE;
Do we need this? Inline?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817680
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + ListPage<GCSObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
> + PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
> + return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
> + } else {
> + return list(container);
> + }
> + }
> +
> + /**
> + * Checks whether an accessible object is available. Google cloud storage does not support directly support
> + * BucketExist or ObjectExist operations
> + */
> + @Override
> + public boolean blobExists(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
Is `/` the only character that we need to encode?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817487
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + @Override
> + public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
> +
> + if (options != null && options != ListContainerOptions.NONE) {
> + ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
> + ListPage<GCSObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
> + PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
> + return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
> + } else {
> + return list(container);
> + }
> + }
> +
> + /**
> + * Checks whether an accessible object is available.Google cloud storage does not support directly support
Add whitespace after period.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17025616
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + @Override
> + public String execute(String container, Blob blob) {
> +
> + ObjectTemplate destination = blob2ObjectTemplate.apply(blob.getMetadata());
> + ComposeObjectTemplate template = new ComposeObjectTemplate().destination(destination);
> +
> + Set<GCSObject> sourceList = Sets.newHashSet();
> +
> + String key = blob.getMetadata().getName();
> + Payload payload = blob.getPayload();
> + Long length = payload.getContentMetadata().getContentLength();
> + if (length == null) {
> + length = blob.getMetadata().getContentMetadata().getContentLength();
> + payload.getContentMetadata().setContentLength(length);
> + }
> + checkNotNull(length,
I'm trying to get the length from the blobMetadata if it is not set on the payload . Moving checkNotNull to top would lead to fail some cases which can be handle?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17214064
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + return new Function<ListPage<Bucket>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
> + public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata), null);
> + }
> + }.apply(api.getBucketApi().listBucket(PROJECT_ID));
> + }
> +
> + @Override
> + public boolean containerExists(String container) {
> + return api.getBucketApi().bucketExist(container);
> + }
> +
> + @Override
> + public boolean createContainerInLocation(Location location, String container) {
> +
> + if (containerExists(container)) {
Do we need this call? Does `createBucket` return an error code for a bucket already exists like S3 does? The current code follows the "time of check to time of use" (TOCTOU) anti-pattern which can introduce bugs.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210375
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
I encountered an integration test failure:
```
org.jclouds.http.HttpResponseException: too many bytes written connecting to POST https://www.googleapis.com/upload/storage/v1/b/gaul-blobstore12/o?uploadType=multipart HTTP/1.1
Caused by: java.io.IOException: too many bytes written
at sun.net.www.protocol.http.HttpURLConnection$StreamingOutputStream.write(HttpURLConnection.java:3452)
at com.google.common.io.CountingOutputStream.write(CountingOutputStream.java:53)
at com.google.common.io.ByteStreams.copy(ByteStreams.java:74)
at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.writePayloadToConnection(JavaUrlHttpCommandExecutorService.java:302)
at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.convert(JavaUrlHttpCommandExecutorService.java:186)
at org.jclouds.http.internal.JavaUrlHttpCommandExecutorService.convert(JavaUrlHttpCommandExecutorService.java:71)
at org.jclouds.http.internal.BaseHttpCommandExecutorService.invoke(BaseHttpCommandExecutorService.java:95)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:91)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
at com.sun.proxy.$Proxy70.multipartUpload(Unknown Source)
at org.jclouds.googlecloudstorage.blobstore.GCSBlobStore.putBlob(GCSBlobStore.java:209)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at com.google.inject.internal.DelegatingInvocationHandler.invoke(DelegatingInvocationHandler.java:37)
at com.sun.proxy.$Proxy52.putBlob(Unknown Source)
at org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest.addBlobToContainer(BaseBlobStoreIntegrationTest.java:281)
```
The blob name "unic₪de" seems to cause this.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54241328
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public class MultipartUpload {
> +
> + protected MultipartUpload() {
private constructor?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216120
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + BlobStore blobStore = view.getBlobStore();
> + long countBefore = blobStore.countBlobs(containerName);
> +
> + addMultipartBlobToContainer(containerName, "const.txt");
> +
> + long countAfter = blobStore.countBlobs(containerName);
> + assertNotEquals(countBefore, countAfter, "No blob was created");
> + assertTrue(countAfter - countBefore > 1, "A multipart blob wasn't actually created - "
> + + "there was only 1 extra blob but there should be one manifest blob and multiple chunk blobs");
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
> + ByteSource sourceToUpload = createFileBiggerThan(PART_SIZE);
Use TestUtils.randomByteSource instead?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216149
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.base.Throwables;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> +
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");//System.getProperty("google-cloud-storage.identity").split("-")[0];
Did similar to GCE but provided project number(extracted from identity) to supplier, but not identity.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17214049
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
Issues remaining
1 - 503 error issue
2- Change DefaultPartSize to 2Mb in LiveTests (It is 32Mb now)
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54810483
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + .userMetadata(gcsObject.getAllMetadata()).build();
> + blob.getMetadata().setContainer(container);
> + blob.getMetadata().setLastModified(gcsObject.getUpdated());
> + blob.getMetadata().setETag(gcsObject.getEtag());
> + blob.getMetadata().setPublicUri(gcsObject.getMediaLink());
> + blob.getMetadata().setUserMetadata(gcsObject.getAllMetadata());
> + blob.getMetadata().setUri(gcsObject.getSelfLink());
> + blob.getMetadata().setId(gcsObject.getId());
> + return blob;
> + }
> +
> + @Override
> + public void removeBlob(String container, String name) {
> + String urlName;
> + try {
> + urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
See above comment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817517
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-google-pull-requests #141](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/141/) SUCCESS
This pull request looks good
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54810033
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-google-pull-requests #138](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/138/) UNSTABLE
Looks like there's a problem with this pull request
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54237584
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + BlobStore blobStore = view.getBlobStore();
> + long countBefore = blobStore.countBlobs(containerName);
> +
> + addMultipartBlobToContainer(containerName, "const.txt");
> +
> + long countAfter = blobStore.countBlobs(containerName);
> + assertNotEquals(countBefore, countAfter, "No blob was created");
> + assertTrue(countAfter - countBefore > 1, "A multipart blob wasn't actually created - "
> + + "there was only 1 extra blob but there should be one manifest blob and multiple chunk blobs");
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
> + ByteSource sourceToUpload = createFileBiggerThan(PART_SIZE);
createFileBiggerThan method uses TestUtils.randomByteSource
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216208
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + @Override
> + @Parameters({ "jclouds.blobstore.httpstream.url", "jclouds.blobstore.httpstream.md5" })
> + public void testCopyUrl(String httpStreamUrl, String httpStreamMD5) throws Exception {
> + httpStreamUrl = checkNotNull(httpStreamUrl != null ? httpStreamUrl : sysHttpStreamUrl, "httpStreamUrl");
> + httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5");
> +
> + HttpResponse response = view.utils().http()
> + .invoke(HttpRequest.builder().method("GET").endpoint(httpStreamUrl).build());
> + long length = response.getPayload().getContentMetadata().getContentLength();
> +
> + checkNotNull(response.getPayload().getContentMetadata().getContentType());
> + assertEquals(response.getPayload().getContentMetadata().getContentType(), "application/x-gzip");
> +
> + String name = "hello";
> + byte[] md5 = BaseEncoding.base16().decode(httpStreamMD5.toUpperCase());
Better to use `BaseEncoding.lowerCase` and store this directly as a `HashCode`:
```
HashCode md5 = HashCode.fromBytes(BaseEncoding.base16().lowerCase().decode(httpStreamMD5));
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210253
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -173,8 +176,12 @@ private String getCrc32c() {
> }
>
> public HashCode getCrc32cHashcode() {
> - HashCode hc = HashCode.fromBytes(DomainUtils.reverse(BaseEncoding.base64().decode(crc32c)));
> - return hc;
> + if (crc32c != null) {
> + HashCode hc = HashCode.fromBytes(DomainUtils.reverse(BaseEncoding.base64().decode(crc32c)));
> + return hc;
> + }
> + return null;
See above comment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817634
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Override
> + public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location
> + .fromValue(location.getId());
> + template = template.location(gcsLocation);
> + }
> + Bucket bucket = api.getBucketApi().createBucket(projectId.get(), template);
> + if (options.isPublicRead()) {
> + try {
> + DefaultObjectAccessControlsTemplate doAclTemplate = new DefaultObjectAccessControlsTemplate().entity(
> + "allUsers").role(ObjectRole.READER);
> + api.getDefaultObjectAccessControlsApi().createDefaultObjectAccessControls(container, doAclTemplate);
> + } catch (HttpResponseException e) {
> + // If DefaultObjectAccessControls operation fail, Reverse create operation the operation.
[minor] "...reverse the create operation"?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817466
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -173,8 +176,12 @@ private String getCrc32c() {
> }
>
> public HashCode getCrc32cHashcode() {
[minor] "HashCode" in alignment with the others?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817640
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + private Logger logger = Logger.NULL;
> +
> + private final GoogleCloudStorageApi api;
> + private final Provider<BlobBuilder> blobBuilders;
> + private final BlobMetadataToObjectTemplate blob2ObjectTemplate;
> + private final MultipartUploadSlicingAlgorithm algorithm;
> + private final PayloadSlicer slicer;
> + private final MultipartNamingStrategy namingStrategy;
> +
> + @Inject
> + public SequentialMultipartUploadStrategy(GoogleCloudStorageApi api, Provider<BlobBuilder> blobBuilders,
> + BlobMetadataToObjectTemplate blob2ObjectTemplate, MultipartUploadSlicingAlgorithm algorithm,
> + PayloadSlicer slicer, MultipartNamingStrategy namingStrategy) {
> + this.api = checkNotNull(api, "api");
> + this.blobBuilders = checkNotNull(blobBuilders, "blobBuilders");
> + this.blob2ObjectTemplate = checkNotNull(blob2ObjectTemplate, "blob2Object");
[minor] "blob2ObjectTemplate"?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817606
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-google-pull-requests #139](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/139/) UNSTABLE
Looks like there's a problem with this pull request
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54706452
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +@Singleton
> +public class ObjectListToStorageMetadata implements Function<ListPage<GCSObject>, PageSet<? extends StorageMetadata>> {
> + private final ObjectToBlobMetadata object2blobMd;
> +
> + @Inject
> + public ObjectListToStorageMetadata(ObjectToBlobMetadata object2blobMd) {
> + this.object2blobMd = object2blobMd;
> + }
> +
> + public PageSet<? extends StorageMetadata> apply(ListPage<GCSObject> from) {
> + if (from == null) {
> + from = ListPage.<GCSObject> builder().kind(Kind.OBJECTS).build();
> + }
> +
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(Iterables.transform(from, object2blobMd),
> + new Function<BlobMetadata, StorageMetadata>() {
Do we need the double transform here, or can we just have a function `ListPage<GCSObject>, StorageMetadata`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817573
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + static final long DEFAULT_PART_SIZE = 32 * 1024 * 1024;
> +
> + @VisibleForTesting
> + static final int DEFAULT_MAGNITUDE_BASE = 100;
> +
> + @Inject(optional = true)
> + @Named("jclouds.mpu.parts.size")
Are there constants we can use here instead of the strings?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817588
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + long defaultPartSize = DEFAULT_PART_SIZE;
> +
> + @Inject(optional = true)
> + @Named("jclouds.mpu.parts.magnitude")
> + @VisibleForTesting
> + int magnitudeBase = DEFAULT_MAGNITUDE_BASE;
> +
> + // calculated only once, but not from the constructor
> + private volatile int parts; // required number of parts with chunkSize
> + private volatile long chunkSize;
> + private volatile long remaining; // number of bytes remained for the last part
> +
> + // sequentially updated values
> + private volatile int part;
> + private volatile long chunkOffset;
> + private volatile long copied;
Is this going to be used concurrently?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817599
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public class MultipartUpload {
Since we're only storing constants here, name the class `MultipartUploadConstants`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817584
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + ContentMetadata metadata = from.getContentMetadata();
> + String contentDisposition = metadata.getContentDisposition();
> + String contentEncoding = metadata.getContentEncoding();
> + String contentLanguage = metadata.getContentLanguage();
> + String contentType = metadata.getContentType();
> + Long contentLength = metadata.getContentLength();
> +
> + HashCode md5 = metadata.getContentMD5AsHashCode();
> +
> + if (md5 != null) {
> + return new ObjectTemplate().contentType(contentType).size(contentLength).contentEncoding(contentEncoding)
> + .contentLanguage(contentLanguage).contentDisposition(contentDisposition).name(name).md5Hash(md5)
> + .customMetadata(userMeta);
> + }
> + return new ObjectTemplate().contentType(contentType).size(contentLength).contentEncoding(contentEncoding)
Can you avoid duplicated code with:
```
ObjectTemplate template = new ObjectTemplate().contentType(...)...;
if (md5 != null) {
template.md5Hash(md5);
}
return template;
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210180
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + assertEquals(container.size(), 15);
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testDirectory() throws InterruptedException {
> + /**
> + * By using slashes in an object name, you can make objects appear as though they're stored in a hierarchical
> + * structure. For example, you could name one object /europe/france/paris.jpg and another object
> + * /europe/france/cannes.jpg. When you list these objects they appear to be in a hierarchical directory structure
> + * based on location; however, Google Cloud Storage sees the objects as independent objects with no hierarchical
> + * relationship whatsoever.
> + */
In GCS prefixes are listed separately from objects and there is nothing like directory either. I think this test is irrevalent to GCS. BTW I removed the comments
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17214041
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +
> + @Override
> + public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
> +
> + if (options != null && options != ListContainerOptions.NONE) {
> + ListObjectOptions listOptions = listContainerOptionsToListObjectOptions.apply(options);
> + ListPage<GCSObject> gcsList = api.getObjectApi().listObjects(container, listOptions);
> + PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
> + return options.isDetailed() ? fetchBlobMetadataProvider.get().setContainerName(container).apply(list) : list;
> + } else {
> + return list(container);
> + }
> + }
> +
> + /**
> + * Checks whether an accessible object is available. Google cloud storage does not support directly support
"does not directly support"...?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817485
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
Pushed to master as 8281d1c7f0fd267f1c7d2e2446a19f670b28287b.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-55051124
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> +import com.google.inject.Inject;
> +import org.jclouds.blobstore.reference.BlobStoreConstants;
> +import org.jclouds.logging.Logger;
> +
> +import javax.annotation.Resource;
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + // 2MB for testing purposes. Change to a reasonable value
> + static final long DEFAULT_PART_SIZE = 2 * 1024 * 1024; // 2MB //33554432; // 32MB
Not sure what could be a resonable value. Swift uses 32MB. Shall I go with with the same?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17225531
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Override
> + public String putBlob(String container, Blob blob, PutOptions options) {
> + if (options.multipart().isMultipart()) {
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
Do we have a different `GetOptions` class?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817498
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
@hsbhathiya [GoogleComputeEngineHttpApiModule.supplyProject](https://github.com/jclouds/jclouds-labs-google/blob/master/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/config/GoogleComputeEngineHttpApiModule.java#L94) seems to store this in a conjoined project_id-extended_uid@developer.gserviceaccount.com.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54719818
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> +import org.jclouds.googlecloudstorage.options.ListObjectOptions;
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");
@andrewgaul As we discussed we would use similar approach to GCE. But I couldn't find how to assign the identity value( i.e "google-cloud-storage.identity") to the supplier<String> projectId.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17208404
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + return false;
> + }
> +
> + /**
> + * This supports multipart/related upload which has exactly 2 parts, media-part and metadata-part
> + */
> + @Override
> + public String putBlob(String container, Blob blob) {
> + checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
> + HashCode md5 = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
> + if (md5 != null) {
> + ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata()).md5Hash(md5);
> + return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).getEtag();
> + }
> + ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata());
> + return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).getEtag();
Remove duplicated code?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210379
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + String urlName;
> + try {
> + urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + } catch (UnsupportedEncodingException uee) {
> + throw Throwables.propagate(uee);
> + }
> + api.getObjectApi().deleteObject(container, urlName);
> + }
> +
> + @Override
> + protected boolean deleteAndVerifyContainerGone(String container) {
> + ListPage<GCSObject> list = api.getObjectApi().listObjects(container);
> + if (list == null) {
> + return api.getBucketApi().deleteBucket(container);
> + }
> + if (!list.iterator().hasNext() && ((list.getPrefixes() == null) || list.getPrefixes().isEmpty()))
`getPrefixes` never returns null since you protect against this in its constructor.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216098
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> jclouds-labs-google-pull-requests #138 UNSTABLE
This looks like a [real test failure](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/org.apache.jclouds.labs$google-cloud-storage/138/testReport/junit/org.jclouds.googlecloudstorage.blobstore.integration/GCSContainerIntegrationTest/setUpResourcesForAllThreads/)?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54244153
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + */
> + @Override
> + public String putBlob(String container, Blob blob) {
> + checkNotNull(blob.getPayload().getContentMetadata().getContentLength());
> + HashCode md5 = blob.getMetadata().getContentMetadata().getContentMD5AsHashCode();
> +
> + ObjectTemplate template = blobMetadataToObjectTemplate.apply(blob.getMetadata());
> +
> + if (md5 != null) {
> + template.md5Hash(md5);
> + }
> + return api.getObjectApi().multipartUpload(container, template, blob.getPayload()).getEtag();
> + }
> +
> + @Override
> + public String putBlob(String container, Blob blob, PutOptions options) {
Do we support any other options? If not, document that?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817496
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public interface MultipartUpload {
> +
> + /* Maximum number of parts per upload */
> + int MAX_NUMBER_OF_PARTS = 10000;
> + /* Maximum number of parts returned for a list parts request */
> + int MAX_LIST_PARTS_RETURNED = 1000;
> + /* Maximum number of multipart uploads returned in a list multipart uploads request */
> + int MAX_LIST_MPU_RETURNED = 1000;
> +
> + /**
> + * part size 5 MB to 5 GB, last part can be < 5 MB
> + */
> + long MIN_PART_SIZE = 5242880L;
> + long MAX_PART_SIZE = 5368709120L;
Can you expand this to: `5L * 1024L * 1024L * 1024L`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17026961
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
Almost ready to go! I will also look at the 503 issue.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54904060
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import static com.google.common.base.Preconditions.checkNotNull;
> +
> +@Singleton
> +public class BlobStoreListContainerOptionsToListObjectOptions implements
> + Function<ListContainerOptions, ListObjectOptions> {
> + public ListObjectOptions apply(ListContainerOptions from) {
> + checkNotNull(from, "set options to instance NONE instead of passing null");
> + ListObjectOptions httpOptions = new ListObjectOptions();
> +
> + if (!from.isRecursive()) {
> + httpOptions = httpOptions.delimiter("/");
> + }
> + if (from.getDir() != null) {
> + String path = from.getDir();
> + if (!path.endsWith("/"))
> + path = path + "/";
`path += "/"`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216111
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +
> + Blob blob = blobBuilder.build();
> + String container = getContainerName();
> +
> + try {
> + assertNotNull(view.getBlobStore().putBlob(container, blob));
> +
> + blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
> + String returnedString = getContentAsStringOrNullAndClose(blob);
> + assertEquals(returnedString, "foo");
> + validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName());
> + checkContentMetadata(blob);
> + PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
> + assertThat(set).isNotEmpty();
> + } finally {
> + recycleContainerAndAddToPool(container);
Do you actually need `recycleContainer` here or does `returnContainer` suffice? The former removes and creates a new container while the latter just empties and reuses the existing container.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210215
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + } else {
> + return list(container);
> + }
> + }
> +
> + /**
> + * Checks whether an accessible object is available. Google cloud storage does not support directly support
> + * BucketExist or ObjectExist operations
> + */
> + @Override
> + public boolean blobExists(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + return api.getObjectApi().objectExist(container, urlName);
> + } catch (UnsupportedEncodingException e) {
> + Throwables.propagate(e);
Use `throw Throwables.propagate(e)`, which will allow you to remove `return false` below.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210167
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-google #1319](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/1319/) UNSTABLE
Looks like there's a problem with this pull request
[(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-google/pull/48#issuecomment-54237507
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + assertEquals(container.size(), 15);
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testDirectory() throws InterruptedException {
> + /**
> + * By using slashes in an object name, you can make objects appear as though they're stored in a hierarchical
> + * structure. For example, you could name one object /europe/france/paris.jpg and another object
> + * /europe/france/cannes.jpg. When you list these objects they appear to be in a hierarchical directory structure
> + * based on location; however, Google Cloud Storage sees the objects as independent objects with no hierarchical
> + * relationship whatsoever.
> + */
Add a TODO if this is not complete?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210260
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + parts = (int) (length / unitPartSize);
> + }
> + if (parts > MultipartUpload.MAX_NUMBER_OF_PARTS) { // if still splits in too many parts
> + parts = MultipartUpload.MAX_NUMBER_OF_PARTS - 1; // limit them. do not care about not
> + // covering
> + }
> + long remainder = length % unitPartSize;
> + if (remainder == 0 && parts > 0) {
> + parts -= 1;
> + }
> + this.chunkSize = partSize;
> + this.parts = parts;
> + this.remaining = length - partSize * parts;
> + logger.debug(" %d bytes partitioned in %d parts of part size: %d, remaining: %d%s", length, parts, chunkSize,
> + remaining, remaining > MultipartUpload.MAX_PART_SIZE ? " overflow!" : "");
> + return this.chunkSize;
Sorry...being lazy here...haven't reviewed the algo - is it copied from somewhere?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817603
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import com.google.inject.Singleton;
> +import static com.google.common.base.Preconditions.checkNotNull;
> +
> +@Singleton
> +public class BlobStoreListContainerOptionsToListObjectOptions implements
> + Function<ListContainerOptions, ListObjectOptions> {
> + public ListObjectOptions apply(ListContainerOptions from) {
> + checkNotNull(from, "set options to instance NONE instead of passing null");
> + ListObjectOptions httpOptions = new ListObjectOptions();
> +
> + if (!from.isRecursive()) {
> + httpOptions = httpOptions.delimiter("/");
> + }
> + if (from.getDir() != null) {
> + String path = from.getDir();
> + if (!path.endsWith("/"))
[minor] Add `{...}`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817557
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + public String putBlob(String container, Blob blob, PutOptions options) {
> + if (options.multipart().isMultipart()) {
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
Rename variable? `object` or so..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817502
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + @Override
> + public String execute(String container, Blob blob) {
> +
> + ObjectTemplate destination = blob2ObjectTemplate.apply(blob.getMetadata());
> + ComposeObjectTemplate template = new ComposeObjectTemplate().destination(destination);
> +
> + Set<GCSObject> sourceList = Sets.newHashSet();
> +
> + String key = blob.getMetadata().getName();
> + Payload payload = blob.getPayload();
> + Long length = payload.getContentMetadata().getContentLength();
> + if (length == null) {
> + length = blob.getMetadata().getContentMetadata().getContentLength();
> + payload.getContentMetadata().setContentLength(length);
> + }
> + checkNotNull(length,
Hoist the precondition closer to the method beginning? This will allow you to simplify the logic:
```
long length = checkNotNull(length, "please invoke payload.getContentMetadata().setContentLength(length) prior to multipart upload");
payload.getContentMetadata().setContentLength(length);
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210197
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + public boolean createContainerInLocation(Location location, String container) {
> +
> + if (containerExists(container)) {
> + return false;
> + }
> +
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceRefferences.Location
> + .fromValue(location.getId());
> + template = template.location(gcsLocation);
> + }
> + return api.getBucketApi().createBucket(PROJECT_ID, template) != null;
> + }
> +
> + /** Should be changed to changed */
What does this comment mean?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17025595
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.logging.Logger;
> +
> +import javax.annotation.Resource;
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + static final long DEFAULT_PART_SIZE = 32 * 1024 * 1024;
> +
> + @VisibleForTesting
> + static final int DEFAULT_MAGNITUDE_BASE = 100;
What does that constant mean?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817587
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> }
>
> public HashCode getMd5HashCode() {
> - HashCode hc = HashCode.fromBytes(BaseEncoding.base64().decode(md5Hash));
> - return hc;
> + if (md5Hash != null) {
> + HashCode hc = HashCode.fromBytes(BaseEncoding.base64().decode(md5Hash));
> + return hc;
> + }
> + return null;
See above comment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817650
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.blobstore.domain.BlobMetadata;
> +import org.jclouds.blobstore.domain.PageSet;
> +import org.jclouds.blobstore.domain.StorageMetadata;
> +import org.jclouds.blobstore.options.CreateContainerOptions;
> +import org.jclouds.blobstore.options.GetOptions;
> +import org.jclouds.blobstore.options.ListContainerOptions;
> +import org.jclouds.blobstore.options.PutOptions;
> +import org.jclouds.domain.Location;
> +
> +import com.google.common.collect.ForwardingObject;
> +import com.google.common.util.concurrent.ListenableFuture;
> +import com.google.common.util.concurrent.ListeningExecutorService;
> +import com.google.inject.Inject;
> +import com.google.inject.name.Named;
> +
> +@SuppressWarnings("deprecation")
Why?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817448
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -64,6 +68,22 @@
> public interface BucketApi {
>
> /**
> + * Check the existence of a bucket
[minor] "Checks"
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817663
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.googlecloudstorage.options.ListObjectOptions;
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");
Also how would this work if a user had multiple GCS BlobStore with different project numbers?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17153263
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -132,8 +132,11 @@ private String getMd5Hash() {
> }
>
> public HashCode getMd5HashCode() {
> - HashCode hc = HashCode.fromBytes(BaseEncoding.base64().decode(md5Hash));
> - return hc;
> + if (md5Hash != null) {
> + HashCode hc = HashCode.fromBytes(BaseEncoding.base64().decode(md5Hash));
> + return hc;
> + }
> + return null;
Just a personal preference...handle the "exceptional case" in the if? I.e.
```
if (md5Hash == null) {
return null;
}
HashCode hc = HashCode.fromBytes(BaseEncoding.base64().decode(md5Hash));
return hc;
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817632
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + if (options.isPublicRead()) {
> + try {
> + DefaultObjectAccessControlsTemplate doAclTemplate = new DefaultObjectAccessControlsTemplate().entity(
> + "allUsers").role(ObjectRole.READER);
> + api.getDefaultObjectAccessControlsApi().createDefaultObjectAccessControls(container, doAclTemplate);
> + } catch (HttpResponseException e) {
> + // If DefaultObjectAccessControls operation fail, Reverse create operation the operation.
> + api.getBucketApi().deleteBucket(container);
> + return false;
> + }
> + }
> +
> + return bucket != null;
> + }
> +
> + /** Returns list of of all the objects */
Remove this Javadoc? Doesn't really add much?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817470
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
> + } catch (InterruptedException e) {
> + e.printStackTrace();
> + }
> + GCSObject gcsObject = api.getObjectApi().getObject(container, name);
Does this return null when the blob does not exist? If so you should also return null to avoid a `NullPointerException`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17190326
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> @@ -76,7 +78,7 @@ protected Builder() {
> .defaultModules(
> ImmutableSet.<Class<? extends Module>> builder().add(GoogleCloudStorageParserModule.class)
> .add(OAuthAuthenticationModule.class).add(OAuthModuleWithoutTypeAdapters.class)
> - .add(GoogleCloudStorageHttpApiModule.class).build());
> + .add(GoogleCloudStorageHttpApiModule.class).add(GCSBlobStoreContextModule.class).build());
You can simplify this with `ImmutableSet.of`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216070
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -138,6 +159,7 @@
> @Path("/b")
> @OAuthScopes(STORAGE_FULLCONTROL_SCOPE)
> @MapBinder(BucketBinder.class)
> + @Fallback(NullOnKeyAlreadyExists.class)
We're being pretty lenient in failing quite "silently" here and above...is that intentional?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817665
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
@hsbhathiya This looks good and is almost ready to commit! We need to find a solution to the 503 errors and please address the other nits.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54755226
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + assertEquals(container.size(), 15);
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testDirectory() throws InterruptedException {
> + /**
> + * By using slashes in an object name, you can make objects appear as though they're stored in a hierarchical
> + * structure. For example, you could name one object /europe/france/paris.jpg and another object
> + * /europe/france/cannes.jpg. When you list these objects they appear to be in a hierarchical directory structure
> + * based on location; however, Google Cloud Storage sees the objects as independent objects with no hierarchical
> + * relationship whatsoever.
> + */
Is this the same as S3?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17027068
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
Real problem here is download operation only provide Media part while getObject provide only the metadata part(Both get requests). Will it be good idea to add request that would surely fail in its first attempt? Isn't there any other way to introduce a time gap?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216113
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + try {
> + String prefix = "rootdelimiter";
> + addTenObjectsUnderPrefix(containerName, prefix);
> + add15UnderRoot(containerName);
> + PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
> + new ListContainerOptions());
> + assert container.getNextMarker() == null;
> + assertEquals(container.size(), 15);
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + @Override
> + @Test(enabled = false)
> + public void testDirectory() throws SkipException {
Can you `throw SkipException` as `S3ContainerIntegrationLiveTest.testDirectory` does? This makes it easier to find in the surefire output.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216044
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + }
> +
> + private void addContentMetadata(PayloadBlobBuilder blobBuilder) {
> + blobBuilder.contentType("text/csv");
> + blobBuilder.contentDisposition("attachment; filename=photo.jpg");
> + blobBuilder.contentLanguage("en");
> + }
> +
> + protected void checkContentMetadata(Blob blob) {
> + checkContentType(blob, "text/csv");
> + checkContentDisposition(blob, "attachment; filename=photo.jpg");
> + checkContentLanguage(blob, "en");
> + }
> +
> + @DataProvider(name = "gcsPutTest")
> + public Object[][] createData1() throws IOException {
[minor] Rename to `createPutData()`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817722
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
Renaming `GCSContainerIntegrationTest` to `GCSContainerIntegrationLiveTest` will work around your symptoms. `mvn verify` runs integration tests but the default profile ignores tests named *LiveTest. Note that you will need to run future integration tests with -Plive.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54767529
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + blob.getMetadata().setLastModified(gcsObject.getUpdated());
> + blob.getMetadata().setETag(gcsObject.getEtag());
> + blob.getMetadata().setPublicUri(gcsObject.getMediaLink());
> + blob.getMetadata().setUserMetadata(gcsObject.getAllMetadata());
> + blob.getMetadata().setUri(gcsObject.getSelfLink());
> + blob.getMetadata().setId(gcsObject.getId());
> + return blob;
> + }
> +
> + @Override
> + public void removeBlob(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + api.getObjectApi().deleteObject(container, urlName);
> + } catch (UnsupportedEncodingException e) {
> + e.printStackTrace();
Also narrow the scope of this catch block, e.g.,
```
String urlName;
try {
urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
} catch (UnsupportedEncodingException uee) {
throw Throwables.propagate(uee);
}
api.getObjectApi().deleteObject(container, urlName);
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17190843
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +
> + @Inject
> + protected GCSBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier<Location> defaultLocation,
> + @Memoized Supplier<Set<? extends Location>> locations, GoogleCloudStorageApi api,
> + BucketToStorageMetadata bucketToStorageMetadata, ObjectToBlobMetadata objectToBlobMetadata,
> + ObjectListToStorageMetadata objectListToStorageMetadata,
> + Provider<FetchBlobMetadata> fetchBlobMetadataProvider,
> + BlobMetadataToObjectTemplate blobMetadataToObjectTemplate,
> + BlobStoreListContainerOptionsToListObjectOptions listContainerOptionsToListObjectOptions,
> + MultipartUploadStrategy multipartUploadStrategy, @UserProject Supplier<String> projectId) {
> + super(context, blobUtils, defaultLocation, locations);
> + this.api = api;
> + this.bucketToStorageMetadata = bucketToStorageMetadata;
> + this.objectToBlobMetadata = objectToBlobMetadata;
> + this.objectListToStorageMetadata = objectListToStorageMetadata;
> + this.fetchBlobMetadataProvider = checkNotNull(fetchBlobMetadataProvider, "fetchBlobMetadataProvider");
Only checking for null here? Can the others all really be null?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817458
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Override
> + public boolean createContainerInLocation(Location location, String container) {
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location
> + .fromValue(location.getId());
> + template = template.location(gcsLocation);
> + }
> + return api.getBucketApi().createBucket(projectId.get(), template) != null;
> + }
> +
> + @Override
> + public boolean createContainerInLocation(Location location, String container, CreateContainerOptions options) {
> + BucketTemplate template = new BucketTemplate().name(container);
> + if (location != null) {
> + org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location gcsLocation = org.jclouds.googlecloudstorage.domain.DomainResourceReferences.Location
[minor] Wrapping?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817462
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + } else {
> + return list(container);
> + }
> + }
> +
> + /**
> + * Checks whether an accessible object is available.Google cloud storage does not support directly support
> + * BucketExist or ObjectExist operations
> + */
> + @Override
> + public boolean blobExists(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + return api.getObjectApi().objectExist(container, urlName);
> + } catch (UnsupportedEncodingException e) {
> + e.printStackTrace();
Call `Throwables.propagate` instead.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17025627
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
@demobox Thanks for reviewing. I would address the suggestions (with some other issues I found) as soon as I find some time. Bit busy with uni exams these days.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-56260373
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import com.google.common.annotations.VisibleForTesting;
> +import com.google.inject.Inject;
> +import org.jclouds.blobstore.reference.BlobStoreConstants;
> +import org.jclouds.logging.Logger;
> +
> +import javax.annotation.Resource;
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + static final long DEFAULT_PART_SIZE = 32 * 1024 * 1024;
32 MB seems reasonable to match Swift, although please override property to 2 MB for for tests so they complete faster.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17274677
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
Why do we sleep here?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17026910
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-google #1334](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/1334/) UNSTABLE
Looks like there's a problem with this pull request
[(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-google/pull/48#issuecomment-54706407
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
> + ByteSource sourceToUpload = TestUtils.randomByteSource().slice(0, (long) (PART_SIZE * 1.1));
> +
> + BlobStore blobStore = view.getBlobStore();
> + blobStore.createContainerInLocation(null, containerName);
> + Blob blob = blobStore.blobBuilder(key).payload(sourceToUpload).contentLength(sourceToUpload.size())
> + .contentType(MediaType.TEXT_PLAIN).build();
> + blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
> + }
> +
> + @DataProvider(name = "delete")
What are the two different dataproviders in this test for? We're trying to delete objects that don't exist and are checking for names? Or..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817716
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.base.Throwables;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> +
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");//System.getProperty("google-cloud-storage.identity").split("-")[0];
I think it is sufficient to parse the identity, in the format `project-identity@google`, as GCE does. We don't need to do the `Supplier<String>`.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210356
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + GCSObject gcsObject = api.getObjectApi().getObject(container, name);
> + if (gcsObject == null) {
> + return null;
> + }
> + Blob blob = new BlobBuilderImpl().payload(impl.getPayload()).payload(impl.getPayload())
> + .contentType(gcsObject.getContentType()).contentDisposition(gcsObject.getContentDisposition())
> + .contentEncoding(gcsObject.getContentEncoding()).contentLanguage(gcsObject.getContentLanguage())
> + .contentLength(gcsObject.getSize()).contentMD5(gcsObject.getMd5HashCode()).name(gcsObject.getName())
> + .userMetadata(gcsObject.getAllMetadata()).build();
> + blob.getMetadata().setContainer(container);
> + blob.getMetadata().setLastModified(gcsObject.getUpdated());
> + blob.getMetadata().setETag(gcsObject.getEtag());
> + blob.getMetadata().setPublicUri(gcsObject.getMediaLink());
> + blob.getMetadata().setUserMetadata(gcsObject.getAllMetadata());
> + blob.getMetadata().setUri(gcsObject.getSelfLink());
> + blob.getMetadata().setId(gcsObject.getId());
This conversion code looks like it might be good to have in an injected function..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817515
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
@andrewgaul I got few issues
1 - I think GCS Locations should be supported from the first release (most probably 1.8.1.) and I will add that feature in next PR
2- mvn integration-test -pl google-cloud-storage runs GCSContainerIntegrationTest offline (not as live test). That is why PRs fail
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54755811
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + try {
> + urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + } catch (UnsupportedEncodingException uee) {
> + throw Throwables.propagate(uee);
> + }
> + api.getObjectApi().deleteObject(container, urlName);
> + }
> +
> + @Override
> + protected boolean deleteAndVerifyContainerGone(String container) {
> + ListPage<GCSObject> list = api.getObjectApi().listObjects(container);
> + if (list == null) {
> + return api.getBucketApi().deleteBucket(container);
> + }
> + if (!list.iterator().hasNext() && list.getPrefixes().isEmpty())
> + return api.getBucketApi().deleteBucket(container);
[minor] Add `{...}`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817522
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-google #1340](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/1340/) 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-google/pull/48#issuecomment-54809829
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
@abayer Any thoughts on how to best express the project id?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54719409
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
We cannot have random sleeps in the code.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17210172
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + returnContainer(containerName);
> + }
> + }
> +
> + protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
> + ByteSource sourceToUpload = TestUtils.randomByteSource().slice(0, (long) (PART_SIZE * 1.1));
> +
> + BlobStore blobStore = view.getBlobStore();
> + blobStore.createContainerInLocation(null, containerName);
> + Blob blob = blobStore.blobBuilder(key).payload(sourceToUpload).contentLength(sourceToUpload.size())
> + .contentType(MediaType.TEXT_PLAIN).build();
> + blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart());
> + }
> +
> + @DataProvider(name = "delete")
> + public Object[][] createData() {
[minor] Rename to `createDeleteData()`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817720
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Override
> + public String execute(String container, Blob blob) {
> +
> + ObjectTemplate destination = blob2ObjectTemplate.apply(blob.getMetadata());
> + ComposeObjectTemplate template = new ComposeObjectTemplate().destination(destination);
> +
> + Set<GCSObject> sourceList = Sets.newHashSet();
> +
> + String key = blob.getMetadata().getName();
> + Payload payload = blob.getPayload();
> + Long length = payload.getContentMetadata().getContentLength();
> + if (length == null) {
> + length = blob.getMetadata().getContentMetadata().getContentLength();
> + payload.getContentMetadata().setContentLength(length);
> + }
> + checkNotNull(length,
We can, though, move the entire `length` bit to the beginning, before we call all the other methods?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817610
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
Closed #48.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#event-163372965
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-google #1344](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/1344/) 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-google/pull/48#issuecomment-55044818
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + /** Google Cloud Storage lists prefixes and objects in two different lists */
> + @Override
> + public void testListRootUsesDelimiter() throws InterruptedException {
> + String containerName = getContainerName();
> + try {
> + String prefix = "rootdelimiter";
> + addTenObjectsUnderPrefix(containerName, prefix);
> + add15UnderRoot(containerName);
> + PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
> + new ListContainerOptions());
> + assert container.getNextMarker() == null;
`assertNull(container.getNextMarker())`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216046
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + @Override
> + public String execute(String container, Blob blob) {
> +
> + ObjectTemplate destination = blob2ObjectTemplate.apply(blob.getMetadata());
> + ComposeObjectTemplate template = new ComposeObjectTemplate().destination(destination);
> +
> + Set<GCSObject> sourceList = Sets.newHashSet();
> +
> + String key = blob.getMetadata().getName();
> + Payload payload = blob.getPayload();
> + Long length = payload.getContentMetadata().getContentLength();
> + if (length == null) {
> + length = blob.getMetadata().getContentMetadata().getContentLength();
> + payload.getContentMetadata().setContentLength(length);
> + }
> + checkNotNull(length,
Sorry I see what you are doing now -- this is correct as-is.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216031
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by BuildHive <no...@github.com>.
[jclouds » jclouds-labs-google #1338](https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/1338/) UNSTABLE
Looks like there's a problem with this pull request
[(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-google/pull/48#issuecomment-54743073
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by CloudBees pull request builder plugin <no...@github.com>.
[jclouds-labs-google-pull-requests #140](https://jclouds.ci.cloudbees.com/job/jclouds-labs-google-pull-requests/140/) UNSTABLE
Looks like there's a problem with this pull request
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54743103
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public class MultipartUpload {
final class?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216121
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
I cannot reproduce the 503 symptoms on a slower Internet connection:
```
mvn integration-test -pl google-cloud-storage -Plive \
-Dtest.google-cloud-storage.identity="${JCLOUDS_IDENTITY}" \
-Dtest.google-cloud-storage.credential="${JCLOUDS_CREDENTIAL}" \
-Dtest.google-cloud-storage.project-number="${JCLOUDS_PROJECT_NUMBER}" \
-Dtest=GCSBlobIntegrationLiveTest#testPutObject \
-Dtest.blobstore.container-count=1
...
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
```
I will try again later with a faster one. In the mean-time can you post the symptoms?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54909897
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + BlobStore blobStore = view.getBlobStore();
> + long countBefore = blobStore.countBlobs(containerName);
> +
> + addMultipartBlobToContainer(containerName, "const.txt");
> +
> + long countAfter = blobStore.countBlobs(containerName);
> + assertNotEquals(countBefore, countAfter, "No blob was created");
> + assertTrue(countAfter - countBefore > 1, "A multipart blob wasn't actually created - "
> + + "there was only 1 extra blob but there should be one manifest blob and multiple chunk blobs");
> + } finally {
> + returnContainer(containerName);
> + }
> + }
> +
> + protected void addMultipartBlobToContainer(String containerName, String key) throws IOException {
> + ByteSource sourceToUpload = createFileBiggerThan(PART_SIZE);
Right, but calling `TestUtils.randomByteSource(0, PART_SIZE + 1)` is more succinct than looping.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216272
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + @Override
> + protected boolean deleteAndVerifyContainerGone(String container) {
> + ListPage<GCSObject> list = api.getObjectApi().listObjects(container);
> + if (list == null) {
> + return api.getBucketApi().deleteBucket(container);
> + }
> + if (!list.iterator().hasNext() && ((list.getPrefixes() == null) || list.getPrefixes().isEmpty()))
> + return api.getBucketApi().deleteBucket(container);
> +
> + return false;
> + }
> +
> + public Set<String> listPrefixes(String container, ListContainerOptions options) {
> + ListObjectOptions gcsOptions = listContainerOptionsToListObjectOptions.apply(options);
> + Set<String> prefixes = api.getObjectApi().listObjects(container, gcsOptions).getPrefixes();
> + return prefixes != null ? prefixes : ImmutableSet.<String> of();
Never null as above.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216101
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + static final long DEFAULT_PART_SIZE = 32 * 1024 * 1024;
> +
> + @VisibleForTesting
> + static final int DEFAULT_MAGNITUDE_BASE = 100;
> +
> + @Inject(optional = true)
> + @Named("jclouds.mpu.parts.size")
> + @VisibleForTesting
> + long defaultPartSize = DEFAULT_PART_SIZE;
> +
> + @Inject(optional = true)
> + @Named("jclouds.mpu.parts.magnitude")
See comment above
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817593
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.blobstore.domain.BlobMetadata;
> +import org.jclouds.blobstore.domain.PageSet;
> +import org.jclouds.blobstore.domain.StorageMetadata;
> +import org.jclouds.blobstore.options.CreateContainerOptions;
> +import org.jclouds.blobstore.options.GetOptions;
> +import org.jclouds.blobstore.options.ListContainerOptions;
> +import org.jclouds.blobstore.options.PutOptions;
> +import org.jclouds.domain.Location;
> +
> +import com.google.common.collect.ForwardingObject;
> +import com.google.common.util.concurrent.ListenableFuture;
> +import com.google.common.util.concurrent.ListeningExecutorService;
> +import com.google.inject.Inject;
> +import com.google.inject.name.Named;
> +
> +@SuppressWarnings("deprecation")
Why? Don't we want to make users know usage of this is deprecated..?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817449
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
I also continue to experience issues with `testDelete` and the "unic₪de" input on Linux. @hsbhathiya do you use Windows? Unfortunately the troublesome input is disabled for *all* integration tests run on Windows, not just the filesystem provider. I do not know how to fix the dataprovider to enable this for Windows users.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54910852
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
> + return new Function<ListPage<Bucket>, org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata>>() {
> + public org.jclouds.blobstore.domain.PageSet<? extends StorageMetadata> apply(ListPage<Bucket> from) {
> + return new PageSetImpl<StorageMetadata>(Iterables.transform(from, bucketToStorageMetadata), null);
> + }
> + }.apply(api.getBucketApi().listBucket(PROJECT_ID));
> + }
> +
> + @Override
> + public boolean containerExists(String container) {
> + return api.getBucketApi().bucketExist(container);
> + }
> +
> + @Override
> + public boolean createContainerInLocation(Location location, String container) {
> +
> + if (containerExists(container)) {
Fixed with a new Fallback NullIfBucketExists
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17214046
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import java.util.Map;
> +
> +import javax.inject.Singleton;
> +
> +import org.jclouds.blobstore.domain.BlobMetadata;
> +import org.jclouds.googlecloudstorage.domain.templates.ObjectTemplate;
> +import org.jclouds.io.ContentMetadata;
> +
> +import com.google.common.base.Function;
> +import com.google.common.hash.HashCode;
> +
> +@Singleton
> +public class BlobMetadataToObjectTemplate implements Function<BlobMetadata, ObjectTemplate> {
> +
> + public ObjectTemplate apply(BlobMetadata from) {
> + if (from == null)
[minor] Add `{...}`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817552
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +
> + return bucket != null;
> + }
> +
> + /** Returns list of of all the objects */
> + @Override
> + public PageSet<? extends StorageMetadata> list(String container) {
> + ListPage<GCSObject> gcsList = api.getObjectApi().listObjects(container);
> + PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
> + return list;
> + }
> +
> + @Override
> + public PageSet<? extends StorageMetadata> list(String container, ListContainerOptions options) {
> +
> + if (options != null && options != ListContainerOptions.NONE) {
Do we support `null` options?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817474
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + return multipartUploadStrategy.execute(container, blob);
> + } else {
> + return putBlob(container, blob);
> + }
> + }
> +
> + @Override
> + public BlobMetadata blobMetadata(String container, String name) {
> + return objectToBlobMetadata.apply(api.getObjectApi().getObject(container, name));
> + }
> +
> + @Override
> + public Blob getBlob(String container, String name, org.jclouds.blobstore.options.GetOptions options) {
> + PayloadEnclosingImpl impl = api.getObjectApi().download(container, name);
> + try {
> + Thread.sleep(1000);
What specifically yields a 503 error, a put followed by a get of the same object? I found this reference:
https://developers.google.com/storage/docs/concepts-techniques#object-updates
Perhaps we need to add a GCS specific fallback and change its retry time to 1 second?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17216011
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> Bit busy with uni exams these days.
Good luck!!
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-56268962
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import org.jclouds.googlecloudstorage.options.ListObjectOptions;
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");
In addition to @andrewgaul's comments: any such property that will be tied to a particular context should be set in the appropriate context builder and injected into instances such as this by Guice.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17201995
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + blob.getMetadata().setLastModified(gcsObject.getUpdated());
> + blob.getMetadata().setETag(gcsObject.getEtag());
> + blob.getMetadata().setPublicUri(gcsObject.getMediaLink());
> + blob.getMetadata().setUserMetadata(gcsObject.getAllMetadata());
> + blob.getMetadata().setUri(gcsObject.getSelfLink());
> + blob.getMetadata().setId(gcsObject.getId());
> + return blob;
> + }
> +
> + @Override
> + public void removeBlob(String container, String name) {
> + try {
> + String urlName = name.contains("/") ? URLEncoder.encode(name, Charsets.UTF_8.toString()) : name;
> + api.getObjectApi().deleteObject(container, urlName);
> + } catch (UnsupportedEncodingException e) {
> + e.printStackTrace();
`Throwables.propagate`
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17026921
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.jclouds.googlecloudstorage.blobstore.strategy.internal;
> +
> +public interface MultipartUpload {
Please make this a final class with a private constructor.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17026965
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import com.google.common.collect.ImmutableMap;
> +import com.google.common.hash.HashCode;
> +import com.google.common.hash.HashFunction;
> +import com.google.common.hash.Hashing;
> +import com.google.common.io.ByteSource;
> +import com.google.common.io.Files;
> +
> +@Test(groups = { "live", "blobstorelive" })
> +public class GCSBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
> +
> + private long PART_SIZE = MultipartUpload.MIN_PART_SIZE;
> +
> + @Override
> + protected Properties setupProperties() {
> + Properties properties = super.setupProperties();
> + properties.put("jclouds.mpu.parts.size", 2 * 1024 * 1024);
Do we have a constant for this?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817685
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> + } catch (HttpResponseException e) {
> + // If DefaultObjectAccessControls operation fail, Reverse create operation the operation.
> + api.getBucketApi().deleteBucket(container);
> + return false;
> + }
> + }
> +
> + return bucket != null;
> + }
> +
> + /** Returns list of of all the objects */
> + @Override
> + public PageSet<? extends StorageMetadata> list(String container) {
> + ListPage<GCSObject> gcsList = api.getObjectApi().listObjects(container);
> + PageSet<? extends StorageMetadata> list = objectListToStorageMetadata.apply(gcsList);
> + return list;
Do we need the duplication here? Can't we just call `return list(container, ListContainerOptions.NONE);`?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817482
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -134,13 +134,19 @@ public String getContentType() {
> }
>
> public HashCode getCrc32cHashcode() {
> - HashCode hc = HashCode.fromBytes(DomainUtils.reverse(BaseEncoding.base64().decode(crc32c)));
> - return hc;
> + if (crc32c != null) {
> + HashCode hc = HashCode.fromBytes(DomainUtils.reverse(BaseEncoding.base64().decode(crc32c)));
> + return hc;
> + }
> + return null;
See above comment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817643
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Gaul <no...@github.com>.
> +import org.jclouds.googlecloudstorage.options.ListObjectOptions;
> +import org.jclouds.http.HttpResponseException;
> +import org.jclouds.http.internal.PayloadEnclosingImpl;
> +
> +import com.google.common.base.Charsets;
> +import com.google.common.base.Function;
> +import com.google.common.base.Supplier;
> +import com.google.common.collect.ImmutableSet;
> +import com.google.common.collect.Iterables;
> +import com.google.common.hash.HashCode;
> +import com.google.inject.Inject;
> +import com.google.inject.Provider;
> +
> +@Singleton
> +public class GCSBlobStore extends BaseBlobStore {
> + private final String PROJECT_ID = System.getProperty("test.google-cloud-storage.project-number");
We need to decide what a project number really means -- it seems to be a subresource of the identity. While we wire this property through the overrides in `ContextBuilder`, perhaps it makes more sense as part of the identity, similar to what OpenStack does with the its user_id:tenant_id:
http://docs.openstack.org/grizzly/openstack-compute/admin/content/users-and-projects.html
/cc @everett-toews @jdaggett
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17206960
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> @@ -134,13 +134,19 @@ public String getContentType() {
> }
>
> public HashCode getCrc32cHashcode() {
See above comment
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817646
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Bhathiya <no...@github.com>.
https://buildhive.cloudbees.com/job/jclouds/job/jclouds-labs-google/org.apache.jclouds.labs$google-cloud-storage/1338/testReport/junit/
Anything wrong with mvn settings?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48#issuecomment-54756922
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +import com.google.common.annotations.VisibleForTesting;
> +import com.google.inject.Inject;
> +import org.jclouds.blobstore.reference.BlobStoreConstants;
> +import org.jclouds.logging.Logger;
> +
> +import javax.annotation.Resource;
> +import javax.inject.Named;
> +
> +public class MultipartUploadSlicingAlgorithm {
> +
> + @Resource
> + @Named(BlobStoreConstants.BLOBSTORE_LOGGER)
> + protected Logger logger = Logger.NULL;
> +
> + @VisibleForTesting
> + static final long DEFAULT_PART_SIZE = 32 * 1024 * 1024;
[minor] Indent?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817586
Re: [jclouds-labs-google] JCLOUDS-458:Added Blobstore Abstraction
(#48)
Posted by Andrew Phillips <no...@github.com>.
> +
> +import static com.google.common.base.Preconditions.checkNotNull;
> +import static com.google.common.base.Throwables.propagate;
> +import static com.google.common.util.concurrent.Futures.immediateFuture;
> +import org.jclouds.Fallback;
> +import com.google.common.util.concurrent.ListenableFuture;
> +
> +public final class GCSFallbacks {
> +
> + public static final class NullOnBucketAlreadyExists implements Fallback<Object> {
> + public ListenableFuture<Object> create(Throwable t) throws Exception {
> + return immediateFuture(createOrPropagate(t));
> + }
> +
> + public Object createOrPropagate(Throwable t) throws Exception {
> + if (checkNotNull(t, "throwable") instanceof IllegalStateException) {
Don't need to check for `null` here, since if this **is** `null`, the `instanceof` will fail
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs-google/pull/48/files#r17817658