mirror of https://github.com/apache/jclouds.git
Merge pull request #245 from andrewgaul/deleta-all-keys-cleanup
Clean up DeleteAllKeysInList.execute
This commit is contained in:
commit
81d9a0afcd
|
@ -91,8 +91,13 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
|
||||||
if (options.isRecursive())
|
if (options.isRecursive())
|
||||||
message = message + " recursively";
|
message = message + " recursively";
|
||||||
Map<StorageMetadata, Exception> exceptions = Maps.newHashMap();
|
Map<StorageMetadata, Exception> exceptions = Maps.newHashMap();
|
||||||
Iterable<? extends StorageMetadata> toDelete = getResourcesToDelete(containerName, options);
|
Iterable<? extends StorageMetadata> toDelete;
|
||||||
for (int i = 0; i < 3; i++) { // TODO parameterize
|
for (int i = 0; i < 3; i++) { // TODO parameterize
|
||||||
|
toDelete = getResourcesToDelete(containerName, options);
|
||||||
|
if (Iterables.isEmpty(toDelete)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Map<StorageMetadata, Future<?>> responses = Maps.newHashMap();
|
Map<StorageMetadata, Future<?>> responses = Maps.newHashMap();
|
||||||
try {
|
try {
|
||||||
for (final StorageMetadata md : toDelete) {
|
for (final StorageMetadata md : toDelete) {
|
||||||
|
@ -120,19 +125,15 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, message);
|
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, message);
|
||||||
toDelete = getResourcesToDelete(containerName, options);
|
}
|
||||||
if (Iterables.size(toDelete) == 0) {
|
if (!exceptions.isEmpty()) {
|
||||||
break;
|
retryHandler.imposeBackoffExponentialDelay(i + 1, message);
|
||||||
}
|
|
||||||
if (exceptions.size() > 0) {
|
|
||||||
toDelete = Iterables.concat(exceptions.keySet(), toDelete);
|
|
||||||
retryHandler.imposeBackoffExponentialDelay(i + 1, message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exceptions.size() > 0)
|
if (!exceptions.isEmpty())
|
||||||
throw new BlobRuntimeException(String.format("error %s: %s", message, exceptions));
|
throw new BlobRuntimeException(String.format("error %s: %s", message, exceptions));
|
||||||
assert Iterables.size(toDelete) == 0 : String.format("items remaining %s: %s", message,
|
toDelete = getResourcesToDelete(containerName, options);
|
||||||
|
assert Iterables.isEmpty(toDelete) : String.format("items remaining %s: %s", message,
|
||||||
toDelete);
|
toDelete);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue