mirror of https://github.com/apache/jclouds.git
workaround to walrus not having NextMarker in bucket listing
This commit is contained in:
parent
672db20eb1
commit
b62a6309be
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.jclouds.s3.domain.internal;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.s3.domain.ListBucketResponse;
|
||||
|
@ -32,8 +32,7 @@ import com.google.common.collect.Iterables;
|
|||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class ListBucketResponseImpl extends HashSet<ObjectMetadata> implements
|
||||
ListBucketResponse {
|
||||
public class ListBucketResponseImpl extends LinkedHashSet<ObjectMetadata> implements ListBucketResponse {
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -4475709781001190244L;
|
||||
protected final String name;
|
||||
|
@ -45,9 +44,8 @@ public class ListBucketResponseImpl extends HashSet<ObjectMetadata> implements
|
|||
protected final Set<String> commonPrefixes;
|
||||
protected final boolean truncated;
|
||||
|
||||
public ListBucketResponseImpl(String name, Iterable<ObjectMetadata> contents, String prefix,
|
||||
String marker, String nextMarker, int maxKeys, String delimiter, boolean isTruncated,
|
||||
Set<String> commonPrefixes) {
|
||||
public ListBucketResponseImpl(String name, Iterable<ObjectMetadata> contents, String prefix, String marker,
|
||||
String nextMarker, int maxKeys, String delimiter, boolean isTruncated, Set<String> commonPrefixes) {
|
||||
Iterables.addAll(this, contents);
|
||||
this.name = name;
|
||||
this.prefix = prefix;
|
||||
|
|
|
@ -71,8 +71,9 @@ public class ListBucketHandler extends ParseSax.HandlerWithResult<ListBucketResp
|
|||
}
|
||||
|
||||
public ListBucketResponse getResult() {
|
||||
return new ListBucketResponseImpl(bucketName, contents, prefix, marker, nextMarker, maxResults, delimiter,
|
||||
isTruncated, commonPrefixes);
|
||||
return new ListBucketResponseImpl(bucketName, contents, prefix, marker,
|
||||
(isTruncated && nextMarker == null) ? currentKey : nextMarker, maxResults, delimiter, isTruncated,
|
||||
commonPrefixes);
|
||||
}
|
||||
|
||||
private boolean inCommonPrefixes;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ParseObjectInfoListFromJsonResponseTest {
|
|||
|
||||
public void testApplyInputStream() {
|
||||
InputStream is = getClass().getResourceAsStream("/test_list_container.json");
|
||||
Set<ObjectInfo> expects = Sets.newHashSet();
|
||||
Set<ObjectInfo> expects = Sets.newLinkedHashSet();
|
||||
ObjectInfoImpl one = i.getInstance(ObjectInfoImpl.class);
|
||||
one.name = "test_obj_1";
|
||||
one.hash = CryptoStreams.hex("4281c348eaf83e70ddce0e07221c3d28");
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
package org.jclouds.blobstore.domain.internal;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.jclouds.blobstore.domain.PageSet;
|
|||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
public class PageSetImpl<T> extends HashSet<T> implements PageSet<T> {
|
||||
public class PageSetImpl<T> extends LinkedHashSet<T> implements PageSet<T> {
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -7133632087734650835L;
|
||||
|
|
|
@ -93,7 +93,8 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
|||
|
||||
BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0));
|
||||
|
||||
assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata().getContentType();
|
||||
assert metadata.getContentMetadata().getContentType().startsWith("text/plain") : metadata.getContentMetadata()
|
||||
.getContentType();
|
||||
assertEquals(metadata.getContentMetadata().getContentLength(), new Long(TEST_STRING.length()));
|
||||
assertEquals(metadata.getUserMetadata().get("adrian"), "powderpuff");
|
||||
checkMD5(metadata);
|
||||
|
@ -123,6 +124,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
|||
String containerName = getContainerName();
|
||||
try {
|
||||
addAlphabetUnderRoot(containerName);
|
||||
|
||||
PageSet<? extends StorageMetadata> container = context.getBlobStore().list(containerName, maxResults(1));
|
||||
|
||||
assert container.getNextMarker() != null;
|
||||
|
@ -255,6 +257,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
|||
String containerName = getContainerName();
|
||||
try {
|
||||
addAlphabetUnderRoot(containerName);
|
||||
|
||||
PageSet<? extends StorageMetadata> container = context.getBlobStore().list(containerName, maxResults(5));
|
||||
assertEquals(container.size(), 5);
|
||||
assert container.getNextMarker() != null;
|
||||
|
@ -330,6 +333,20 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
|||
blob.setPayload(letter + "content");
|
||||
context.getBlobStore().putBlob(containerName, blob);
|
||||
}
|
||||
assertContainerSize(containerName, 26);
|
||||
|
||||
}
|
||||
|
||||
protected void assertContainerSize(final String containerName, final int size) throws InterruptedException {
|
||||
assertConsistencyAware(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
assertEquals(context.getBlobStore().countBlobs(containerName), size);
|
||||
} catch (Exception e) {
|
||||
propagateIfPossible(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void add15UnderRoot(String containerName) throws InterruptedException {
|
||||
|
|
Loading…
Reference in New Issue