object stores typically sort the list of containers

This commit is contained in:
Ka-Hing Cheung 2015-06-22 16:18:28 -07:00 committed by Andrew Gaul
parent 7480d6e363
commit 8b325d585e
4 changed files with 10 additions and 4 deletions

View File

@ -38,6 +38,7 @@ import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.UserDefinedFileAttributeView;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.Set;
@ -134,7 +135,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
}
@Override
public Iterable<String> getAllContainerNames() {
public Collection<String> getAllContainerNames() {
File[] files = new File(buildPathStartingFromBaseDir()).listFiles();
if (files == null) {
return ImmutableList.of();

View File

@ -17,6 +17,7 @@
package org.jclouds.blobstore;
import java.io.IOException;
import java.util.Collection;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobAccess;
@ -42,7 +43,7 @@ public interface LocalStorageStrategy {
* Return an iterator that reports all the containers under base path
* @return
*/
Iterable<String> getAllContainerNames();
Collection<String> getAllContainerNames();
/**
* Creates a new container

View File

@ -20,6 +20,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.BaseEncoding.base16;
import java.io.IOException;
import java.util.Collection;
import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -82,7 +83,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
}
@Override
public Iterable<String> getAllContainerNames() {
public Collection<String> getAllContainerNames() {
return containerToBlobs.keySet();
}

View File

@ -32,6 +32,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -393,7 +395,8 @@ public final class LocalBlobStore implements BlobStore {
@Override
public PageSet<? extends StorageMetadata> list() {
Iterable<String> containers = storageStrategy.getAllContainerNames();
ArrayList<String> containers = new ArrayList<String>(storageStrategy.getAllContainerNames());
Collections.sort(containers);
return new PageSetImpl<StorageMetadata>(transform(
containers, new Function<String, StorageMetadata>() {