From 9a17f9713376b23fb3dfeb898282dbfd61c64962 Mon Sep 17 00:00:00 2001 From: Akira Ajisaka Date: Thu, 10 Jun 2021 14:29:47 +0900 Subject: [PATCH] YARN-10803. [JDK 11] TestRMFailoverProxyProvider and TestNoHaRMFailoverProxyProvider fails by ClassCastException. (#3068) Reviewed-by: Takanobu Asanuma --- .../TestNoHaRMFailoverProxyProvider.java | 20 +++++++-------- .../client/TestRMFailoverProxyProvider.java | 25 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNoHaRMFailoverProxyProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNoHaRMFailoverProxyProvider.java index e7223b73ea..fb9c65b6c2 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNoHaRMFailoverProxyProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNoHaRMFailoverProxyProvider.java @@ -140,9 +140,9 @@ public void testDefaultFPPGetOneProxy() throws Exception { // Create a proxy and mock a RMProxy Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null); Class protocol = ApplicationClientProtocol.class; - RMProxy mockRMProxy = mock(RMProxy.class); - DefaultNoHARMFailoverProxyProvider fpp = - new DefaultNoHARMFailoverProxyProvider(); + RMProxy mockRMProxy = mock(RMProxy.class); + DefaultNoHARMFailoverProxyProvider fpp = + new DefaultNoHARMFailoverProxyProvider<>(); InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT); @@ -154,7 +154,7 @@ public void testDefaultFPPGetOneProxy() throws Exception { // Initialize failover proxy provider and get proxy from it. fpp.init(conf, mockRMProxy, protocol); - FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); assertEquals( "AutoRefreshRMFailoverProxyProvider doesn't generate " + "expected proxy", @@ -180,7 +180,7 @@ public void testDefaultFPPGetOneProxy() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy1.proxy); - FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); assertEquals("AutoRefreshRMFailoverProxyProvider " + "doesn't generate expected proxy after failover", mockProxy1, actualProxy2.proxy); @@ -208,9 +208,9 @@ public void testAutoRefreshIPChange() throws Exception { Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null); Proxy mockProxy2 = new TestProxy((proxy, method, args) -> null); Class protocol = ApplicationClientProtocol.class; - RMProxy mockRMProxy = mock(RMProxy.class); - AutoRefreshNoHARMFailoverProxyProvider fpp = - new AutoRefreshNoHARMFailoverProxyProvider(); + RMProxy mockRMProxy = mock(RMProxy.class); + AutoRefreshNoHARMFailoverProxyProvider fpp = + new AutoRefreshNoHARMFailoverProxyProvider<>(); // generate two address with different ports. InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT); @@ -224,7 +224,7 @@ public void testAutoRefreshIPChange() throws Exception { // Initialize proxy provider and get proxy from it. fpp.init(conf, mockRMProxy, protocol); - FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); assertEquals( "AutoRefreshRMFailoverProxyProvider doesn't generate " + "expected proxy", @@ -259,7 +259,7 @@ public void testAutoRefreshIPChange() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy1.proxy); - FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); assertEquals("AutoRefreshNoHARMFailoverProxyProvider " + "doesn't generate expected proxy after failover", mockProxy2, actualProxy2.proxy); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailoverProxyProvider.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailoverProxyProvider.java index bda72d8b92..ce9af23744 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailoverProxyProvider.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailoverProxyProvider.java @@ -87,9 +87,9 @@ public void testFailoverChange() throws Exception { Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null); Class protocol = ApplicationClientProtocol.class; - RMProxy mockRMProxy = mock(RMProxy.class); - ConfiguredRMFailoverProxyProvider fpp = - new ConfiguredRMFailoverProxyProvider(); + RMProxy mockRMProxy = mock(RMProxy.class); + ConfiguredRMFailoverProxyProvider fpp = + new ConfiguredRMFailoverProxyProvider<>(); // generate two address with different ports. // Default port of yarn RM @@ -104,7 +104,7 @@ public void testFailoverChange() throws Exception { // Initialize failover proxy provider and get proxy from it. fpp.init(conf, mockRMProxy, protocol); - FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); assertEquals( "ConfiguredRMFailoverProxyProvider doesn't generate " + "expected proxy", @@ -139,7 +139,7 @@ public void testFailoverChange() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy1.proxy); - FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); assertEquals("ConfiguredRMFailoverProxyProvider " + "doesn't generate expected proxy after failover", mockProxy2, actualProxy2.proxy); @@ -167,7 +167,7 @@ public void testFailoverChange() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy2.proxy); - FailoverProxyProvider.ProxyInfo actualProxy3 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy3 = fpp.getProxy(); // check the proxy is the same as the one we created before. assertEquals("ConfiguredRMFailoverProxyProvider " + @@ -202,11 +202,10 @@ public void testAutoRefreshFailoverChange() throws Exception { // Create three proxies and mock a RMProxy Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null); Proxy mockProxy2 = new TestProxy((proxy, method, args) -> null); - Proxy mockProxy3 = new TestProxy((proxy, method, args) -> null); Class protocol = ApplicationClientProtocol.class; - RMProxy mockRMProxy = mock(RMProxy.class); - AutoRefreshRMFailoverProxyProvider fpp = - new AutoRefreshRMFailoverProxyProvider(); + RMProxy mockRMProxy = mock(RMProxy.class); + AutoRefreshRMFailoverProxyProvider fpp = + new AutoRefreshRMFailoverProxyProvider<>(); // generate three address with different ports. InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT); @@ -222,7 +221,7 @@ public void testAutoRefreshFailoverChange() throws Exception { // Initialize failover proxy provider and get proxy from it. fpp.init(conf, mockRMProxy, protocol); - FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy1 = fpp.getProxy(); assertEquals( "AutoRefreshRMFailoverProxyProvider doesn't generate " + "expected proxy", @@ -257,7 +256,7 @@ public void testAutoRefreshFailoverChange() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy1.proxy); - FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy2 = fpp.getProxy(); assertEquals("AutoRefreshRMFailoverProxyProvider " + "doesn't generate expected proxy after failover", mockProxy2, actualProxy2.proxy); @@ -285,7 +284,7 @@ public void testAutoRefreshFailoverChange() throws Exception { // Perform Failover and get proxy again from failover proxy provider fpp.performFailover(actualProxy2.proxy); - FailoverProxyProvider.ProxyInfo actualProxy3 = fpp.getProxy(); + FailoverProxyProvider.ProxyInfo actualProxy3 = fpp.getProxy(); // check the proxy is the same as the one we created before. assertEquals("ConfiguredRMFailoverProxyProvider " +