Skip to content

Commit e33f3e1

Browse files
aajisakaxiaole-shopee
authored andcommitted
YARN-10803. [JDK 11] TestRMFailoverProxyProvider and TestNoHaRMFailoverProxyProvider fails by ClassCastException. (apache#3068)
Reviewed-by: Takanobu Asanuma <[email protected]> (cherry picked from commit 9a17f97)
1 parent bb5e237 commit e33f3e1

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestNoHaRMFailoverProxyProvider.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,9 @@ public void testDefaultFPPGetOneProxy() throws Exception {
140140
// Create a proxy and mock a RMProxy
141141
Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null);
142142
Class protocol = ApplicationClientProtocol.class;
143-
RMProxy mockRMProxy = mock(RMProxy.class);
144-
DefaultNoHARMFailoverProxyProvider <RMProxy> fpp =
145-
new DefaultNoHARMFailoverProxyProvider<RMProxy>();
143+
RMProxy<Proxy> mockRMProxy = mock(RMProxy.class);
144+
DefaultNoHARMFailoverProxyProvider<Proxy> fpp =
145+
new DefaultNoHARMFailoverProxyProvider<>();
146146

147147
InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT);
148148

@@ -154,7 +154,7 @@ public void testDefaultFPPGetOneProxy() throws Exception {
154154

155155
// Initialize failover proxy provider and get proxy from it.
156156
fpp.init(conf, mockRMProxy, protocol);
157-
FailoverProxyProvider.ProxyInfo<RMProxy> actualProxy1 = fpp.getProxy();
157+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy1 = fpp.getProxy();
158158
assertEquals(
159159
"AutoRefreshRMFailoverProxyProvider doesn't generate " +
160160
"expected proxy",
@@ -180,7 +180,7 @@ public void testDefaultFPPGetOneProxy() throws Exception {
180180

181181
// Perform Failover and get proxy again from failover proxy provider
182182
fpp.performFailover(actualProxy1.proxy);
183-
FailoverProxyProvider.ProxyInfo<RMProxy> actualProxy2 = fpp.getProxy();
183+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy2 = fpp.getProxy();
184184
assertEquals("AutoRefreshRMFailoverProxyProvider " +
185185
"doesn't generate expected proxy after failover",
186186
mockProxy1, actualProxy2.proxy);
@@ -208,9 +208,9 @@ public void testAutoRefreshIPChange() throws Exception {
208208
Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null);
209209
Proxy mockProxy2 = new TestProxy((proxy, method, args) -> null);
210210
Class protocol = ApplicationClientProtocol.class;
211-
RMProxy mockRMProxy = mock(RMProxy.class);
212-
AutoRefreshNoHARMFailoverProxyProvider<RMProxy> fpp =
213-
new AutoRefreshNoHARMFailoverProxyProvider<RMProxy>();
211+
RMProxy<Proxy> mockRMProxy = mock(RMProxy.class);
212+
AutoRefreshNoHARMFailoverProxyProvider<Proxy> fpp =
213+
new AutoRefreshNoHARMFailoverProxyProvider<>();
214214

215215
// generate two address with different ports.
216216
InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT);
@@ -224,7 +224,7 @@ public void testAutoRefreshIPChange() throws Exception {
224224

225225
// Initialize proxy provider and get proxy from it.
226226
fpp.init(conf, mockRMProxy, protocol);
227-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy1 = fpp.getProxy();
227+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy1 = fpp.getProxy();
228228
assertEquals(
229229
"AutoRefreshRMFailoverProxyProvider doesn't generate " +
230230
"expected proxy",
@@ -259,7 +259,7 @@ public void testAutoRefreshIPChange() throws Exception {
259259

260260
// Perform Failover and get proxy again from failover proxy provider
261261
fpp.performFailover(actualProxy1.proxy);
262-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy2 = fpp.getProxy();
262+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy2 = fpp.getProxy();
263263
assertEquals("AutoRefreshNoHARMFailoverProxyProvider " +
264264
"doesn't generate expected proxy after failover",
265265
mockProxy2, actualProxy2.proxy);

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/test/java/org/apache/hadoop/yarn/client/TestRMFailoverProxyProvider.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ public void testFailoverChange() throws Exception {
8787
Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null);
8888

8989
Class protocol = ApplicationClientProtocol.class;
90-
RMProxy mockRMProxy = mock(RMProxy.class);
91-
ConfiguredRMFailoverProxyProvider<RMProxy> fpp =
92-
new ConfiguredRMFailoverProxyProvider<RMProxy>();
90+
RMProxy<Proxy> mockRMProxy = mock(RMProxy.class);
91+
ConfiguredRMFailoverProxyProvider<Proxy> fpp =
92+
new ConfiguredRMFailoverProxyProvider<>();
9393

9494
// generate two address with different ports.
9595
// Default port of yarn RM
@@ -104,7 +104,7 @@ public void testFailoverChange() throws Exception {
104104

105105
// Initialize failover proxy provider and get proxy from it.
106106
fpp.init(conf, mockRMProxy, protocol);
107-
FailoverProxyProvider.ProxyInfo<RMProxy> actualProxy1 = fpp.getProxy();
107+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy1 = fpp.getProxy();
108108
assertEquals(
109109
"ConfiguredRMFailoverProxyProvider doesn't generate " +
110110
"expected proxy",
@@ -139,7 +139,7 @@ public void testFailoverChange() throws Exception {
139139

140140
// Perform Failover and get proxy again from failover proxy provider
141141
fpp.performFailover(actualProxy1.proxy);
142-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy2 = fpp.getProxy();
142+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy2 = fpp.getProxy();
143143
assertEquals("ConfiguredRMFailoverProxyProvider " +
144144
"doesn't generate expected proxy after failover",
145145
mockProxy2, actualProxy2.proxy);
@@ -167,7 +167,7 @@ public void testFailoverChange() throws Exception {
167167

168168
// Perform Failover and get proxy again from failover proxy provider
169169
fpp.performFailover(actualProxy2.proxy);
170-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy3 = fpp.getProxy();
170+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy3 = fpp.getProxy();
171171

172172
// check the proxy is the same as the one we created before.
173173
assertEquals("ConfiguredRMFailoverProxyProvider " +
@@ -202,11 +202,10 @@ public void testAutoRefreshFailoverChange() throws Exception {
202202
// Create three proxies and mock a RMProxy
203203
Proxy mockProxy1 = new TestProxy((proxy, method, args) -> null);
204204
Proxy mockProxy2 = new TestProxy((proxy, method, args) -> null);
205-
Proxy mockProxy3 = new TestProxy((proxy, method, args) -> null);
206205
Class protocol = ApplicationClientProtocol.class;
207-
RMProxy mockRMProxy = mock(RMProxy.class);
208-
AutoRefreshRMFailoverProxyProvider<RMProxy> fpp =
209-
new AutoRefreshRMFailoverProxyProvider<RMProxy>();
206+
RMProxy<Proxy> mockRMProxy = mock(RMProxy.class);
207+
AutoRefreshRMFailoverProxyProvider<Proxy> fpp =
208+
new AutoRefreshRMFailoverProxyProvider<>();
210209

211210
// generate three address with different ports.
212211
InetSocketAddress mockAdd1 = new InetSocketAddress(RM1_PORT);
@@ -222,7 +221,7 @@ public void testAutoRefreshFailoverChange() throws Exception {
222221

223222
// Initialize failover proxy provider and get proxy from it.
224223
fpp.init(conf, mockRMProxy, protocol);
225-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy1 = fpp.getProxy();
224+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy1 = fpp.getProxy();
226225
assertEquals(
227226
"AutoRefreshRMFailoverProxyProvider doesn't generate " +
228227
"expected proxy",
@@ -257,7 +256,7 @@ public void testAutoRefreshFailoverChange() throws Exception {
257256

258257
// Perform Failover and get proxy again from failover proxy provider
259258
fpp.performFailover(actualProxy1.proxy);
260-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy2 = fpp.getProxy();
259+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy2 = fpp.getProxy();
261260
assertEquals("AutoRefreshRMFailoverProxyProvider " +
262261
"doesn't generate expected proxy after failover",
263262
mockProxy2, actualProxy2.proxy);
@@ -285,7 +284,7 @@ public void testAutoRefreshFailoverChange() throws Exception {
285284

286285
// Perform Failover and get proxy again from failover proxy provider
287286
fpp.performFailover(actualProxy2.proxy);
288-
FailoverProxyProvider.ProxyInfo <RMProxy> actualProxy3 = fpp.getProxy();
287+
FailoverProxyProvider.ProxyInfo<Proxy> actualProxy3 = fpp.getProxy();
289288

290289
// check the proxy is the same as the one we created before.
291290
assertEquals("ConfiguredRMFailoverProxyProvider " +

0 commit comments

Comments
 (0)