|
@@ -22,7 +22,9 @@ package org.apache.hadoop.tools.util;
|
|
|
import org.apache.commons.logging.Log;
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
import org.apache.hadoop.io.retry.RetryPolicy;
|
|
|
+import org.apache.hadoop.io.retry.RetryPolicy.RetryAction;
|
|
|
import org.apache.hadoop.io.retry.RetryPolicies;
|
|
|
+import org.apache.hadoop.util.ThreadUtil;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -80,7 +82,7 @@ public abstract class RetriableCommand {
|
|
|
public Object execute(Object... arguments) throws Exception {
|
|
|
Exception latestException;
|
|
|
int counter = 0;
|
|
|
- do {
|
|
|
+ while (true) {
|
|
|
try {
|
|
|
return doExecute(arguments);
|
|
|
} catch(Exception exception) {
|
|
@@ -88,7 +90,13 @@ public abstract class RetriableCommand {
|
|
|
latestException = exception;
|
|
|
}
|
|
|
counter++;
|
|
|
- } while (retryPolicy.shouldRetry(latestException, counter, 0, true).equals(RetryPolicy.RetryAction.RETRY));
|
|
|
+ RetryAction action = retryPolicy.shouldRetry(latestException, counter, 0, true);
|
|
|
+ if (action.action == RetryPolicy.RetryAction.RetryDecision.RETRY) {
|
|
|
+ ThreadUtil.sleepAtLeastIgnoreInterrupts(action.delayMillis);
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
throw new IOException("Couldn't run retriable-command: " + description,
|
|
|
latestException);
|