diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt
index 33225f06dbb..ef98e212f2b 100644
--- a/hadoop-yarn-project/CHANGES.txt
+++ b/hadoop-yarn-project/CHANGES.txt
@@ -286,6 +286,9 @@ Release 2.4.0 - UNRELEASED
YARN-1549. Fixed a bug in ResourceManager's ApplicationMasterService that
was causing unamanged AMs to not finish correctly. (haosdent via vinodkv)
+ YARN-1559. Race between ServerRMProxy and ClientRMProxy setting
+ RMProxy#INSTANCE. (kasha and vinodkv via kasha)
+
Release 2.3.0 - UNRELEASED
INCOMPATIBLE CHANGES
diff --git a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
index 486bebfec50..74ca61b8578 100644
--- a/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
+++ b/hadoop-yarn-project/hadoop-yarn/dev-support/findbugs-exclude.xml
@@ -309,13 +309,4 @@
-
-
-
-
-
-
-
-
-
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/ClientRMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/ClientRMProxy.java
index 06bbc3555c4..91d0bf7fc92 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/ClientRMProxy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/ClientRMProxy.java
@@ -39,16 +39,13 @@
public class ClientRMProxy extends RMProxy {
private static final Log LOG = LogFactory.getLog(ClientRMProxy.class);
+ private static final ClientRMProxy INSTANCE = new ClientRMProxy();
private interface ClientRMProtocols extends ApplicationClientProtocol,
ApplicationMasterProtocol, ResourceManagerAdministrationProtocol {
// Add nothing
}
- static {
- INSTANCE = new ClientRMProxy();
- }
-
private ClientRMProxy(){
super();
}
@@ -63,9 +60,7 @@ private ClientRMProxy(){
*/
public static T createRMProxy(final Configuration configuration,
final Class protocol) throws IOException {
- // This method exists only to initiate this class' static INSTANCE. TODO:
- // FIX if possible
- return RMProxy.createRMProxy(configuration, protocol);
+ return createRMProxy(configuration, protocol, INSTANCE);
}
private static void setupTokens(InetSocketAddress resourceManagerAddress)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java
index 913eb04613c..c15018bde8a 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/client/RMProxy.java
@@ -50,7 +50,6 @@
public class RMProxy {
private static final Log LOG = LogFactory.getLog(RMProxy.class);
- protected static RMProxy INSTANCE;
protected RMProxy() {}
@@ -79,17 +78,17 @@ protected InetSocketAddress getRMAddress(
*/
@Private
protected static T createRMProxy(final Configuration configuration,
- final Class protocol) throws IOException {
+ final Class protocol, RMProxy instance) throws IOException {
YarnConfiguration conf = (configuration instanceof YarnConfiguration)
? (YarnConfiguration) configuration
: new YarnConfiguration(configuration);
RetryPolicy retryPolicy = createRetryPolicy(conf);
if (HAUtil.isHAEnabled(conf)) {
RMFailoverProxyProvider provider =
- INSTANCE.createRMFailoverProxyProvider(conf, protocol);
+ instance.createRMFailoverProxyProvider(conf, protocol);
return (T) RetryProxy.create(protocol, provider, retryPolicy);
} else {
- InetSocketAddress rmAddress = INSTANCE.getRMAddress(conf, protocol);
+ InetSocketAddress rmAddress = instance.getRMAddress(conf, protocol);
LOG.info("Connecting to ResourceManager at " + rmAddress);
T proxy = RMProxy.getProxy(conf, protocol, rmAddress);
return (T) RetryProxy.create(protocol, proxy, retryPolicy);
@@ -159,25 +158,6 @@ private RMFailoverProxyProvider createRMFailoverProxyProvider(
return provider;
}
- /**
- * A RetryPolicy to allow failing over upto the specified maximum time.
- */
- private static class FailoverUptoMaximumTimePolicy implements RetryPolicy {
- private long maxTime;
-
- FailoverUptoMaximumTimePolicy(long maxTime) {
- this.maxTime = maxTime;
- }
-
- @Override
- public RetryAction shouldRetry(Exception e, int retries, int failovers,
- boolean isIdempotentOrAtMostOnce) throws Exception {
- return System.currentTimeMillis() < maxTime
- ? RetryAction.FAILOVER_AND_RETRY
- : RetryAction.FAIL;
- }
- }
-
/**
* Fetch retry policy from Configuration
*/
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ServerRMProxy.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ServerRMProxy.java
index 15a26e51260..5d4fc462c12 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ServerRMProxy.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/api/ServerRMProxy.java
@@ -32,10 +32,7 @@
public class ServerRMProxy extends RMProxy {
private static final Log LOG = LogFactory.getLog(ServerRMProxy.class);
-
- static {
- INSTANCE = new ServerRMProxy();
- }
+ private static final ServerRMProxy INSTANCE = new ServerRMProxy();
private ServerRMProxy() {
super();
@@ -51,10 +48,8 @@ private ServerRMProxy() {
*/
public static T createRMProxy(final Configuration configuration,
final Class protocol) throws IOException {
- // This method exists only to initiate this class' static INSTANCE. TODO:
- // FIX if possible
- return RMProxy.createRMProxy(configuration, protocol);
- }
+ return createRMProxy(configuration, protocol, INSTANCE);
+}
@InterfaceAudience.Private
@Override