You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/03/24 19:18:35 UTC
ambari git commit: AMBARI-15544: Creating multinode cluster using
Blueprints fails.
Repository: ambari
Updated Branches:
refs/heads/trunk 7afb17719 -> dbbce96b1
AMBARI-15544: Creating multinode cluster using Blueprints fails.
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/dbbce96b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/dbbce96b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/dbbce96b
Branch: refs/heads/trunk
Commit: dbbce96b130dd83b4ec6e9f328fda01076cc784a
Parents: 7afb177
Author: Nahappan Somasundaram <ns...@hortonworks.com>
Authored: Wed Mar 23 15:19:10 2016 -0700
Committer: Nahappan Somasundaram <ns...@hortonworks.com>
Committed: Thu Mar 24 11:18:21 2016 -0700
----------------------------------------------------------------------
.../server/agent/RecoveryConfigHelper.java | 8 +++
.../configuration/RecoveryConfigHelperTest.java | 54 ++++++++++++++++++--
2 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/dbbce96b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java
index dca4a9b..951b04b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/agent/RecoveryConfigHelper.java
@@ -143,6 +143,14 @@ public class RecoveryConfigHelper {
Long timestamp = hostTimestamp.get(hostname);
+ /*
+ * An agent that did not get the configuration during registration because it
+ * was not yet a part of a cluster but now is will not have an entry.
+ */
+ if (timestamp == null) {
+ return true;
+ }
+
if (timestamp.longValue() != recoveryTimestamp) {
return true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/dbbce96b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
index f7c85b6..93d261b 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
@@ -308,8 +308,50 @@ public class RecoveryConfigHelperTest {
assertEquals(recoveryConfig.getEnabledComponents(), "");
}
- private Cluster getDummyCluster(final String hostname)
- throws AmbariException {
+ /**
+ * Test a cluster with two hosts. The first host gets the configuration during registration.
+ * The second host gets it during it's first heartbeat.
+ *
+ * @throws AmbariException
+ */
+ @Test
+ public void testMultiNodeCluster()
+ throws AmbariException {
+ Set<String> hostNames = new HashSet<String>() {{
+ add("Host1");
+ add("Host2");
+ }};
+
+ // Create a cluster with 2 hosts
+ Cluster cluster = getDummyCluster(hostNames);
+
+ // Add HDFS service with DATANODE component to the cluster
+ Service hdfs = cluster.addService(HDFS);
+ hdfs.persist();
+
+ hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
+ hdfs.getServiceComponent(DATANODE).persist();
+
+ // Add SCH to Host1 and Host2
+ hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host1").persist();
+ hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host2").persist();
+
+ // Simulate registration for Host1: Get the recovery configuration right away for Host1.
+ // It makes an entry for cluster name and Host1 in the timestamp dictionary.
+ RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), "Host1");
+ assertEquals(recoveryConfig.getEnabledComponents(), "DATANODE");
+
+ // Simulate heartbeat for Host2: When second host heartbeats, it first checks if config stale.
+ // This should return true since it did not get the configuration during registration.
+ // There is an entry for the cluster name, made by Host1, but no entry for Host2 in the timestamp
+ // dictionary since we skipped registration. Lookup for cluster name will succeed but lookup for Host2
+ // will return null.
+ boolean isConfigStale = recoveryConfigHelper.isConfigStale(cluster.getClusterName(), "Host2", -1);
+ assertTrue(isConfigStale);
+ }
+
+ private Cluster getDummyCluster(Set<String> hostNames)
+ throws AmbariException {
Map<String, String> configProperties = new HashMap<String, String>() {{
put(RecoveryConfigHelper.RECOVERY_ENABLED_KEY, "true");
put(RecoveryConfigHelper.RECOVERY_TYPE_KEY, "AUTO_START");
@@ -319,10 +361,16 @@ public class RecoveryConfigHelperTest {
put(RecoveryConfigHelper.RECOVERY_RETRY_GAP_KEY, "2");
}};
+ return heartbeatTestHelper.getDummyCluster("cluster1", "HDP-0.1", configProperties, hostNames);
+ }
+
+ private Cluster getDummyCluster(final String hostname)
+ throws AmbariException {
+
Set<String> hostNames = new HashSet<String>(){{
add(hostname);
}};
- return heartbeatTestHelper.getDummyCluster("cluster1", "HDP-0.1", configProperties, hostNames);
+ return getDummyCluster(hostNames);
}
}