diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 956ae4f56b6..22d89d9d1bb 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -206,6 +206,9 @@ Release 2.0.0 - UNRELEASED HADOOP-8238. NetUtils#getHostNameOfIP blows up if given ip:port string w/o port. (eli) + HADOOP-8243. Security support broken in CLI (manual) failover controller + (todd) + BREAKDOWN OF HADOOP-7454 SUBTASKS HADOOP-7455. HA: Introduce HA Service Protocol Interface. (suresh) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java index d1dad189545..22f245a9c84 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/FailoverController.java @@ -52,14 +52,22 @@ public class FailoverController { public FailoverController(Configuration conf) { this.conf = conf; - this.gracefulFenceTimeout = conf.getInt( + this.gracefulFenceTimeout = getGracefulFenceTimeout(conf); + this.rpcTimeoutToNewActive = getRpcTimeoutToNewActive(conf); + } + + static int getGracefulFenceTimeout(Configuration conf) { + return conf.getInt( CommonConfigurationKeys.HA_FC_GRACEFUL_FENCE_TIMEOUT_KEY, CommonConfigurationKeys.HA_FC_GRACEFUL_FENCE_TIMEOUT_DEFAULT); - this.rpcTimeoutToNewActive = conf.getInt( + } + + static int getRpcTimeoutToNewActive(Configuration conf) { + return conf.getInt( CommonConfigurationKeys.HA_FC_NEW_ACTIVE_TIMEOUT_KEY, CommonConfigurationKeys.HA_FC_NEW_ACTIVE_TIMEOUT_DEFAULT); } - + /** * Perform pre-failover checks on the given service we plan to * failover to, eg to prevent failing over to a service (eg due diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java index 75c0c11eee7..a3d898cf3e5 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAAdmin.java @@ -114,7 +114,8 @@ public abstract class HAAdmin extends Configured implements Tool { return -1; } - HAServiceProtocol proto = resolveTarget(argv[1]).getProxy(); + HAServiceProtocol proto = resolveTarget(argv[1]).getProxy( + getConf(), 0); HAServiceProtocolHelper.transitionToActive(proto); return 0; } @@ -127,7 +128,8 @@ public abstract class HAAdmin extends Configured implements Tool { return -1; } - HAServiceProtocol proto = resolveTarget(argv[1]).getProxy(); + HAServiceProtocol proto = resolveTarget(argv[1]).getProxy( + getConf(), 0); HAServiceProtocolHelper.transitionToStandby(proto); return 0; } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java index e3f887611c2..90c887d2923 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/HAServiceTarget.java @@ -68,11 +68,4 @@ public abstract class HAServiceTarget { getAddress(), confCopy, factory, timeoutMs); } - - /** - * @return a proxy to connect to the target HA Service. - */ - public final HAServiceProtocol getProxy() throws IOException { - return getProxy(new Configuration(), 0); // default conf, timeout - } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java index fd95c952eaf..9a50fe684ec 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java @@ -245,7 +245,8 @@ public abstract class ZKFailoverController implements Tool { private synchronized void becomeActive() { LOG.info("Trying to make " + localTarget + " active..."); try { - localTarget.getProxy().transitionToActive(); + HAServiceProtocolHelper.transitionToActive(localTarget.getProxy( + conf, FailoverController.getRpcTimeoutToNewActive(conf))); LOG.info("Successfully transitioned " + localTarget + " to active state"); } catch (Throwable t) { @@ -267,7 +268,8 @@ public abstract class ZKFailoverController implements Tool { LOG.info("ZK Election indicated that " + localTarget + " should become standby"); try { - localTarget.getProxy().transitionToStandby(); + int timeout = FailoverController.getGracefulFenceTimeout(conf); + localTarget.getProxy(conf, timeout).transitionToStandby(); LOG.info("Successfully transitioned " + localTarget + " to standby state"); } catch (Exception e) {