You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by Timur Alperovich <no...@github.com> on 2015/06/26 00:24:13 UTC
[jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Plumbs the prefix option to the S3, Azure, OpenStack Swift, Local, and Transient providers. The option allows listing all blobs that start with a given prefix.
You can view, comment on, or merge this pull request online at:
https://github.com/jclouds/jclouds/pull/788
-- Commit Summary --
* JCLOUDS-930: Add the prefix option.
* Use a _char_ for delimiter in Transient and Local.
* Factor out the common prefixes method.
* JCLOUDS-930: Add prefix support to Local store.
* JCLOUDS-930: Plumb prefix support down to Azure.
* JCLOUDS-930: Plumb prefix support down to S3.
* JCLOUDS-930: Add prefix option to OpenStack Swift.
-- File Changes --
M apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java (6)
M apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java (6)
M apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java (4)
M apis/openstack-swift/src/main/java/org/jclouds/openstack/swift/v1/blobstore/functions/ToListContainerOptions.java (13)
M apis/s3/src/main/java/org/jclouds/s3/blobstore/functions/ContainerToBucketListOptions.java (7)
M apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java (6)
M blobstore/src/main/java/org/jclouds/blobstore/LocalStorageStrategy.java (2)
M blobstore/src/main/java/org/jclouds/blobstore/TransientStorageStrategy.java (4)
M blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java (102)
M blobstore/src/main/java/org/jclouds/blobstore/options/ListContainerOptions.java (36)
M blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java (31)
A blobstore/src/test/java/org/jclouds/blobstore/strategy/internal/PrefixTest.java (116)
M providers/azureblob/src/main/java/org/jclouds/azureblob/blobstore/functions/ListOptionsToListBlobsOptions.java (6)
-- Patch Links --
https://github.com/jclouds/jclouds/pull/788.patch
https://github.com/jclouds/jclouds/pull/788.diff
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
Will look into the failures this weekend.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-115917820
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Andrew Gaul <no...@github.com>.
Sorry I missed that `FilesystemBlobStoreTest.testListDirectoryBlobsS3FS` fails. I believe the test is incorrect based on the commit message in 8677ffcb213f4182eee03039431a9562c2eee16a. I temporarily disabled this test in 1dcd4500ea3c499260b7e42bb520132c0ed6bba2. @timuralp Can you confirm and correct it?
Also can you send a pull request disabling prefix tests on GCS?
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-116923675
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
Submitted a GCS PR: https://github.com/jclouds/jclouds-labs-google/pull/161
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-116956105
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Andrew Gaul <no...@github.com>.
> + Iterable<? extends StorageMetadata> results = concatter.execute(containerName,
> + ListContainerOptions.Builder.prefix(prefix));
> + assertEquals(Iterables.size(results), 3);
> + assertEquals(Iterables.get(results, 0).getName(), prefix);
> + assertEquals(Iterables.get(results, 0).getType(), StorageType.BLOB);
> + assertEquals(Iterables.get(results, 1).getName(), prefix + "bar");
> + assertEquals(Iterables.get(results, 1).getType(), StorageType.BLOB);
> + assertEquals(Iterables.get(results, 2).getName(), prefix + "baz");
> + assertEquals(Iterables.get(results, 2).getType(), StorageType.BLOB);
> + }
> +
> + public void testListWithPrefixAndSeparator() {
> + String containerName = "prefixWithSeparator";
> + String prefix = "foo";
> + blobStore.createContainerInLocation(null, containerName);
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + File.separator + "object").payload("").build());
Do you really want to use `File.separator` since this will differ when running on Linux vs. Windows.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788/files#r33405076
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
Yes, I believe the test is incorrect -- pull request submitted. Will figure out how to set the test to pending on GCS next.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-116955055
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
> @@ -112,6 +117,32 @@ public void testPublicAccessInNonDefaultLocationWithBigBlob() throws Interrupted
> runCreateContainerInLocation(payload, nonDefault);
> }
>
> + @Test(groups = "live", dependsOnMethods = "testPublicAccess")
> + public void testContainerListWithPrefix() throws InterruptedException {
> + final String containerName = getContainerName();
> + BlobStore blobStore = view.getBlobStore();
> + String prefix = "blob";
> + try {
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix).payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "foo").payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "bar").payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder("foo").payload("").build());
> + checkEqualNames(ImmutableSet.of(prefix, prefix + "foo", prefix + "bar"),
Done
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788/files#r33405027
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Andrew Gaul <no...@github.com>.
This pull request has several test failures:
org.jclouds.blobstore.strategy.internal.PrefixTest.testListRecursivePrefix
org.jclouds.blobstore.strategy.internal.PrefixTest.testListWithPrefix
org.jclouds.blobstore.strategy.internal.PrefixTest.testListWithPrefixAndSeparator
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-115917553
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
This set of patches conflicts with the delimiter pull request (#764) and additional work would need to be required after one of them is merged to rebase the other one.
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788#issuecomment-115418164
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Timur Alperovich <no...@github.com>.
> + Iterable<? extends StorageMetadata> results = concatter.execute(containerName,
> + ListContainerOptions.Builder.prefix(prefix));
> + assertEquals(Iterables.size(results), 3);
> + assertEquals(Iterables.get(results, 0).getName(), prefix);
> + assertEquals(Iterables.get(results, 0).getType(), StorageType.BLOB);
> + assertEquals(Iterables.get(results, 1).getName(), prefix + "bar");
> + assertEquals(Iterables.get(results, 1).getType(), StorageType.BLOB);
> + assertEquals(Iterables.get(results, 2).getName(), prefix + "baz");
> + assertEquals(Iterables.get(results, 2).getType(), StorageType.BLOB);
> + }
> +
> + public void testListWithPrefixAndSeparator() {
> + String containerName = "prefixWithSeparator";
> + String prefix = "foo";
> + blobStore.createContainerInLocation(null, containerName);
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + File.separator + "object").payload("").build());
Done
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788/files#r33529570
Re: [jclouds] JCLOUDS-930: Plumb through the prefix option (#788)
Posted by Andrew Gaul <no...@github.com>.
> @@ -112,6 +117,32 @@ public void testPublicAccessInNonDefaultLocationWithBigBlob() throws Interrupted
> runCreateContainerInLocation(payload, nonDefault);
> }
>
> + @Test(groups = "live", dependsOnMethods = "testPublicAccess")
> + public void testContainerListWithPrefix() throws InterruptedException {
> + final String containerName = getContainerName();
> + BlobStore blobStore = view.getBlobStore();
> + String prefix = "blob";
> + try {
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix).payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "foo").payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder(prefix + "bar").payload("").build());
> + blobStore.putBlob(containerName, blobStore.blobBuilder("foo").payload("").build());
> + checkEqualNames(ImmutableSet.of(prefix, prefix + "foo", prefix + "bar"),
Would this be more obvious with a function which extracted the blob names and an assertThat call:
```java
assertThat(extractBlobNames(blobStore.list(...)).hasSameElementsAs(ImmutableSet.of(...));
```
---
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/788/files#r33404915