From 671e407ced6821b4acf070959b8d0cddce348d3a Mon Sep 17 00:00:00 2001 From: Inigo Goiri Date: Thu, 12 Apr 2018 08:43:12 -0700 Subject: [PATCH] Revert "HDFS-13388. RequestHedgingProxyProvider calls multiple configured NNs all the time. Contributed by Jinglun." This reverts commit 8c9dab978e2bdcbd6558c9e12b177c5bdca04393. --- .../ha/RequestHedgingProxyProvider.java | 3 -- .../ha/TestRequestHedgingProxyProvider.java | 34 ------------------- 2 files changed, 37 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/RequestHedgingProxyProvider.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/RequestHedgingProxyProvider.java index 1c387910780..7b9cd64dc5d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/RequestHedgingProxyProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/RequestHedgingProxyProvider.java @@ -79,9 +79,6 @@ public class RequestHedgingProxyProvider extends public Object invoke(Object proxy, final Method method, final Object[] args) throws Throwable { - if (currentUsedProxy != null) { - return method.invoke(currentUsedProxy.proxy, args); - } Map, ProxyInfo> proxyMap = new HashMap<>(); int numAttempts = 0; diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRequestHedgingProxyProvider.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRequestHedgingProxyProvider.java index 4b3fdf9b70e..8d6b02dc158 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRequestHedgingProxyProvider.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestRequestHedgingProxyProvider.java @@ -43,13 +43,10 @@ import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.assertEquals; import org.mockito.Matchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.mock; import com.google.common.collect.Lists; @@ -102,37 +99,6 @@ public class TestRequestHedgingProxyProvider { Mockito.verify(goodMock).getStats(); } - @Test - public void testRequestNNAfterOneSuccess() throws Exception { - final AtomicInteger count = new AtomicInteger(0); - final ClientProtocol goodMock = mock(ClientProtocol.class); - when(goodMock.getStats()).thenAnswer(new Answer() { - @Override - public long[] answer(InvocationOnMock invocation) throws Throwable { - count.incrementAndGet(); - Thread.sleep(1000); - return new long[]{1}; - } - }); - final ClientProtocol badMock = mock(ClientProtocol.class); - when(badMock.getStats()).thenAnswer(new Answer() { - @Override - public long[] answer(InvocationOnMock invocation) throws Throwable { - count.incrementAndGet(); - throw new IOException("Bad mock !!"); - } - }); - - RequestHedgingProxyProvider provider = - new RequestHedgingProxyProvider<>(conf, nnUri, ClientProtocol.class, - createFactory(badMock, goodMock, goodMock, badMock)); - ClientProtocol proxy = provider.getProxy().proxy; - proxy.getStats(); - assertEquals(2, count.get()); - proxy.getStats(); - assertEquals(3, count.get()); - } - @Test public void testHedgingWhenOneIsSlow() throws Exception { final ClientProtocol goodMock = Mockito.mock(ClientProtocol.class);