Merge pull request #1442 from maginatics/clear-container-parameterize-max-errors

Parameterize max errors for clear container
This commit is contained in:
Matt Stephenson 2013-04-01 10:52:19 -07:00
commit f0a1054958
1 changed files with 15 additions and 4 deletions

View File

@ -63,10 +63,12 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
private final ListeningExecutorService userExecutor;
protected final AsyncBlobStore connection;
/** Maximum duration in milliseconds of a request. */
@Inject(optional = true)
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
protected Long maxTime = Long.MAX_VALUE;
protected long maxTime = Long.MAX_VALUE;
/** Maximum times to retry an operation. */
protected int maxErrors = 3;
@Inject
DeleteAllKeysInList(@Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
@ -76,6 +78,16 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
this.retryHandler = retryHandler;
}
@Inject(optional = true)
void setMaxTime(@Named(Constants.PROPERTY_REQUEST_TIMEOUT) long maxTime) {
this.maxTime = maxTime;
}
@Inject(optional = true)
void setMaxErrors(@Named(Constants.PROPERTY_MAX_RETRIES) int maxErrors) {
this.maxErrors = maxErrors;
}
public void execute(String containerName) {
execute(containerName, recursive());
}
@ -89,7 +101,6 @@ public class DeleteAllKeysInList implements ClearListStrategy, ClearContainerStr
message += " recursively";
logger.debug(message);
Map<StorageMetadata, Exception> exceptions = Maps.newHashMap();
int maxErrors = 3; // TODO parameterize
for (int numErrors = 0; numErrors < maxErrors; ) {
// fetch partial directory listing
PageSet<? extends StorageMetadata> listing;