Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Parameterize max errors for clear container
Browse files Browse the repository at this point in the history
Also use setter injection for max request time.
  • Loading branch information
Andrew Gaul committed Mar 29, 2013
1 parent e93b79d commit 15f4d04
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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());
}
Expand All @@ -89,7 +101,6 @@ public void execute(final String containerName, ListContainerOptions options) {
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;
Expand Down

0 comments on commit 15f4d04

Please sign in to comment.