|
@@ -22,6 +22,7 @@ import static org.apache.hadoop.io.retry.RetryPolicies.RETRY_FOREVER;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.TRY_ONCE_THEN_FAIL;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.TRY_ONCE_THEN_FAIL;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryByException;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryByException;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryByRemoteException;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryByRemoteException;
|
|
|
|
+import static org.apache.hadoop.io.retry.RetryPolicies.retryOtherThanRemoteException;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithFixedSleep;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithFixedSleep;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithProportionalSleep;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumCountWithProportionalSleep;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumTimeWithFixedSleep;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.retryUpToMaximumTimeWithFixedSleep;
|
|
@@ -29,6 +30,7 @@ import static org.apache.hadoop.io.retry.RetryPolicies.retryForeverWithFixedSlee
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.exponentialBackoffRetry;
|
|
import static org.apache.hadoop.io.retry.RetryPolicies.exponentialBackoffRetry;
|
|
import static org.junit.Assert.*;
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
@@ -213,8 +215,29 @@ public class TestRetryProxy {
|
|
} catch (RemoteException e) {
|
|
} catch (RemoteException e) {
|
|
// expected
|
|
// expected
|
|
}
|
|
}
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Test
|
|
|
|
+ public void testRetryOtherThanRemoteException() throws Throwable {
|
|
|
|
+ Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
|
|
|
|
+ Collections.<Class<? extends Exception>, RetryPolicy>singletonMap(
|
|
|
|
+ IOException.class, RETRY_FOREVER);
|
|
|
|
+
|
|
|
|
+ UnreliableInterface unreliable = (UnreliableInterface)
|
|
|
|
+ RetryProxy.create(UnreliableInterface.class, unreliableImpl,
|
|
|
|
+ retryOtherThanRemoteException(TRY_ONCE_THEN_FAIL,
|
|
|
|
+ exceptionToPolicyMap));
|
|
|
|
+ // should retry with local IOException.
|
|
|
|
+ unreliable.failsOnceWithIOException();
|
|
|
|
+ try {
|
|
|
|
+ // won't get retry on remote exception
|
|
|
|
+ unreliable.failsOnceWithRemoteException();
|
|
|
|
+ fail("Should fail");
|
|
|
|
+ } catch (RemoteException e) {
|
|
|
|
+ // expected
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Test
|
|
@Test
|
|
public void testRetryInterruptible() throws Throwable {
|
|
public void testRetryInterruptible() throws Throwable {
|
|
final UnreliableInterface unreliable = (UnreliableInterface)
|
|
final UnreliableInterface unreliable = (UnreliableInterface)
|