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