mirror of https://github.com/apache/jclouds.git
Merge pull request #728 from andrewgaul/local-storage-strategy-odds-and-ends
Tie up odds and ends from LocalStorageStrategy
This commit is contained in:
commit
6cb318ece8
|
@ -324,6 +324,7 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
MutableStorageMetadata cmd = create();
|
||||
cmd.setName(name);
|
||||
cmd.setType(StorageType.CONTAINER);
|
||||
cmd.setLocation(storageStrategy.getLocation(name));
|
||||
return cmd;
|
||||
}
|
||||
}), null));
|
||||
|
@ -461,9 +462,6 @@ public class FilesystemAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
}
|
||||
|
||||
try {
|
||||
// TODO
|
||||
// must override existing file?
|
||||
|
||||
storageStrategy.putBlob(containerName, blob);
|
||||
} catch (IOException e) {
|
||||
logger.error(e, "An error occurred storing the new blob with name [%s] to container [%s].", blobKey,
|
||||
|
|
|
@ -266,6 +266,11 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
|
|||
return blobNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(final String containerName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean directoryExists(String container, String directory) {
|
||||
return buildPathAndChecksIfDirectoryExists(container, directory);
|
||||
}
|
||||
|
|
|
@ -121,4 +121,9 @@ public interface LocalStorageStrategy {
|
|||
*/
|
||||
void putBlob(String containerName, Blob blob) throws IOException;
|
||||
|
||||
/**
|
||||
* @param containerName name of container
|
||||
* @return Location of container or null
|
||||
*/
|
||||
Location getLocation(String containerName);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
protected final ContentMetadataCodec contentMetadataCodec;
|
||||
protected final IfDirectoryReturnNameStrategy ifDirectoryReturnName;
|
||||
protected final Factory blobFactory;
|
||||
protected final TransientStorageStrategy storageStrategy;
|
||||
protected final LocalStorageStrategy storageStrategy;
|
||||
protected final Provider<UriBuilder> uriBuilders;
|
||||
|
||||
@Inject
|
||||
|
@ -155,7 +155,13 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
return immediateFailedFuture(cnfe(container));
|
||||
|
||||
// Loading blobs from container
|
||||
Iterable<String> blobBelongingToContainer = storageStrategy.getBlobKeysInsideContainer(container);
|
||||
Iterable<String> blobBelongingToContainer = null;
|
||||
try {
|
||||
blobBelongingToContainer = storageStrategy.getBlobKeysInsideContainer(container);
|
||||
} catch (IOException e) {
|
||||
logger.error(e, "An error occurred loading blobs contained into container %s", container);
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
||||
SortedSet<StorageMetadata> contents = newTreeSet(transform(blobBelongingToContainer,
|
||||
new Function<String, StorageMetadata>() {
|
||||
|
@ -303,10 +309,15 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
public ListenableFuture<Boolean> deleteContainerIfEmpty(final String container) {
|
||||
Boolean returnVal = true;
|
||||
if (storageStrategy.containerExists(container)) {
|
||||
if (Iterables.isEmpty(storageStrategy.getBlobKeysInsideContainer(container)))
|
||||
storageStrategy.deleteContainer(container);
|
||||
else
|
||||
returnVal = false;
|
||||
try {
|
||||
if (Iterables.isEmpty(storageStrategy.getBlobKeysInsideContainer(container)))
|
||||
storageStrategy.deleteContainer(container);
|
||||
else
|
||||
returnVal = false;
|
||||
} catch (IOException e) {
|
||||
logger.error(e, "An error occurred loading blobs contained into container %s", container);
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
return immediateFuture(returnVal);
|
||||
}
|
||||
|
@ -470,7 +481,13 @@ public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
|||
|
||||
blob = createUpdatedCopyOfBlobInContainer(containerName, blob);
|
||||
|
||||
storageStrategy.putBlob(containerName, blob);
|
||||
try {
|
||||
storageStrategy.putBlob(containerName, blob);
|
||||
} catch (IOException e) {
|
||||
logger.error(e, "An error occurred storing the new blob with name [%s] to container [%s].", blobKey,
|
||||
containerName);
|
||||
Throwables.propagate(e);
|
||||
}
|
||||
|
||||
String eTag = getEtag(blob);
|
||||
return immediateFuture(eTag);
|
||||
|
|
|
@ -95,6 +95,7 @@ public class TransientStorageStrategy implements LocalStorageStrategy {
|
|||
return containerToBlobs.get(containerName).keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation(final String containerName) {
|
||||
return containerToLocation.get(containerName);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue