ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject git commit: AMBARI-3238. 1st host on a 2-node cluster goes to heartbeat lost state in UI after decommissioning datanode on 2nd host.
Date Sun, 15 Sep 2013 04:38:56 GMT
Updated Branches:
  refs/heads/trunk cc98f98ae -> f88f7135f


AMBARI-3238. 1st host on a 2-node cluster goes to heartbeat lost state in UI after decommissioning
datanode on 2nd host.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/f88f7135
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/f88f7135
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/f88f7135

Branch: refs/heads/trunk
Commit: f88f7135fb3f4e0c27f3266c6b64ec3e0ae3dd58
Parents: cc98f98
Author: Sumit Mohanty <smohanty@hortonworks.com>
Authored: Sat Sep 14 21:38:32 2013 -0700
Committer: Sumit Mohanty <smohanty@hortonworks.com>
Committed: Sat Sep 14 21:38:32 2013 -0700

----------------------------------------------------------------------
 .../main/python/ambari_agent/PuppetExecutor.py  | 18 +++++++---
 .../src/test/python/TestPuppetExecutor.py       |  5 +++
 .../AmbariManagementControllerImpl.java         | 36 ++++++++++++--------
 .../ambari/server/metadata/ActionMetadata.java  |  3 +-
 .../AmbariManagementControllerTest.java         |  3 +-
 5 files changed, 43 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f88f7135/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py b/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
index f7afc8a..c789840 100644
--- a/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
@@ -152,13 +152,21 @@ class PuppetExecutor:
   def isJavaAvailable(self, command):
     javaExecutablePath = "{0}/bin/java".format(command)
     return not self.sh.run([javaExecutablePath, '-version'])['exitCode']
-    
+
   def runCommand(self, command, tmpoutfile, tmperrfile):
     # After installing we must have jdk available for start/stop/smoke
-    java64_home = str(command['configurations']['global']['java64_home']).strip()
-    if command['roleCommand']!="INSTALL" and not self.isJavaAvailable(java64_home):
-      errMsg = JAVANOTVALID_MSG.format(java64_home)
-      return {'stdout': '', 'stderr': errMsg, 'exitcode': 1}
+    if command['roleCommand'] != "INSTALL":
+      java64_home = None
+      if ('global' in command['configurations']) and ('java64_home' in command['configurations']['global']):
+        java64_home = str(command['configurations']['global']['java64_home']).strip()
+      if java64_home is None or not self.isJavaAvailable(java64_home):
+        if java64_home is None:
+          errMsg = "Cannot access JDK! Make sure java64_home is specified in global config"
+        else:
+          errMsg = JAVANOTVALID_MSG.format(java64_home)
+        return {'stdout': '', 'stderr': errMsg, 'exitcode': 1}
+      pass
+    pass
 
     taskId = 0
     if command.has_key("taskId"):

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f88f7135/ambari-agent/src/test/python/TestPuppetExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestPuppetExecutor.py b/ambari-agent/src/test/python/TestPuppetExecutor.py
index 5c029cb..536a05f 100644
--- a/ambari-agent/src/test/python/TestPuppetExecutor.py
+++ b/ambari-agent/src/test/python/TestPuppetExecutor.py
@@ -99,6 +99,11 @@ class TestPuppetExecutor(TestCase):
     self.assertEquals(res["stderr"], errMsg)
     self.assertFalse(puppetInstance.reposInstalled)
 
+    parsedJson['configurations'] = {'random':{'name1':'value2'}}
+    res = puppetInstance.runCommand(parsedJson, tmpdir + '/out.txt', tmpdir + '/err.txt')
+    self.assertEquals(res["exitcode"], 1)
+    self.assertEquals(res["stderr"], "Cannot access JDK! Make sure java64_home is specified
in global config")
+
   @patch.object(PuppetExecutor, 'isJavaAvailable')
   @patch.object(RepoInstaller, 'generate_repo_manifests')
   @patch.object(PuppetExecutor, 'runPuppetFile')

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f88f7135/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
index 58fbef4..a280907 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
@@ -118,6 +118,8 @@ public class AmbariManagementControllerImpl implements
 
   private String baseLogDir = "/tmp/ambari";
 
+  private String clusterLevelTag = "tag";
+
   private final ActionManager actionManager;
 
   @SuppressWarnings("unused")
@@ -1893,12 +1895,13 @@ public class AmbariManagementControllerImpl implements
       // 1) start with cluster config
       Config config = cluster.getConfig(type, tag);
 
-      if (null == config)
+      if (null == config) {
         continue;
+      }
 
       Map<String, String> props = new HashMap<String, String>(config.getProperties());
       Map<String, String> tags = new HashMap<String, String>();
-      tags.put("tag", config.getVersionTag());
+      tags.put(clusterLevelTag, config.getVersionTag());
 
       // 2) apply the service overrides, if any are defined with different tags
       Service service = cluster.getService(serviceName);
@@ -1920,13 +1923,10 @@ public class AmbariManagementControllerImpl implements
         }
       }
 
-      //TODO store empty map for now
-//      configurations.put(type, props);
       configTags.put(type, tags);
     }
 
 
-
     // HACK HACK HACK if the service has configs that are NOT included
     // in cluster-level, then use them anyway.  THIS IS GENERALLY A BAD
     // IDEA, but is included for backward compatability.  Do not check host
@@ -1936,10 +1936,10 @@ public class AmbariManagementControllerImpl implements
     for (Config c : service.getDesiredConfigs().values()) {
       String type = c.getType();
       if (!configurations.containsKey(type)) {
-        configurations.put(type, new HashMap<String,String>(c.getProperties()));
+        configurations.put(type, new HashMap<String, String>(c.getProperties()));
 
-        HashMap<String,String> tags = new HashMap<String,String>();
-        tags.put("tag", c.getVersionTag());
+        HashMap<String, String> tags = new HashMap<String, String>();
+        tags.put(clusterLevelTag, c.getVersionTag());
         configTags.put(type, tags);
       }
     }
@@ -4215,6 +4215,7 @@ public class AmbariManagementControllerImpl implements
   private void addDecommissionDatanodeAction(
       ActionRequest decommissionRequest, Stage stage)
       throws AmbariException {
+    String hdfsExcludeFileType = "hdfs-exclude-file";
     // Find hdfs admin host, just decommission from namenode.
     String clusterName = decommissionRequest.getClusterName();
     Cluster cluster = clusters.getCluster(clusterName);
@@ -4236,17 +4237,22 @@ public class AmbariManagementControllerImpl implements
     }
 
     Config config = clusters.getCluster(clusterName).getConfig(
-        "hdfs-exclude-file", excludeFileTag);
+        hdfsExcludeFileType, excludeFileTag);
+
+    LOG.info("Decommissioning data nodes: " + config.getProperties().get("datanodes") +
+        " " + hdfsExcludeFileType + " tag: " + excludeFileTag);
 
     Map<String, Map<String, String>> configurations =
         new TreeMap<String, Map<String, String>>();
-    configurations.put(config.getType(), config.getProperties());
-
     Map<String, Map<String, String>> configTags = new TreeMap<String,
-      Map<String, String>>();
+        Map<String, String>>();
 
     findConfigurationPropertiesWithOverrides(configurations, configTags,
-      cluster, serviceName, namenodeHost);
+        cluster, serviceName, namenodeHost);
+    // Add the tag for hdfs-exclude-file
+    Map<String, String> excludeTags = new HashMap<String, String>();
+    excludeTags.put(clusterLevelTag, config.getVersionTag());
+    configTags.put(hdfsExcludeFileType, excludeTags);
 
     stage.addHostRoleExecutionCommand(
         namenodeHost,
@@ -4257,7 +4263,7 @@ public class AmbariManagementControllerImpl implements
         clusterName, serviceName);
 
     ExecutionCommand execCmd = stage.getExecutionCommandWrapper(namenodeHost,
-      Role.DECOMMISSION_DATANODE.toString()).getExecutionCommand();
+        Role.DECOMMISSION_DATANODE.toString()).getExecutionCommand();
 
     execCmd.setConfigurations(configurations);
     execCmd.setConfigurationTags(configTags);
@@ -4265,7 +4271,7 @@ public class AmbariManagementControllerImpl implements
     Map<String, String> params = new TreeMap<String, String>();
     params.put("jdk_location", this.jdkResourceUrl);
     params.put("stack_version", cluster.getDesiredStackVersion()
-      .getStackVersion());
+        .getStackVersion());
     execCmd.setHostLevelParams(params);
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f88f7135/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
b/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
index d47a100..989ca2d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/metadata/ActionMetadata.java
@@ -53,7 +53,8 @@ public class ActionMetadata {
   }
 
   private void fillServiceActions() {
-    serviceActions.put("hdfs"       , Arrays.asList(Role.HDFS_SERVICE_CHECK.toString()));
+    serviceActions.put("hdfs"       , Arrays.asList(Role.HDFS_SERVICE_CHECK.toString(),
+                                                    Role.DECOMMISSION_DATANODE.toString()));
     serviceActions.put("hcfs"       , Arrays.asList(Role.HCFS_SERVICE_CHECK.toString()));
     serviceActions.put("hbase"      , Arrays.asList(Role.HBASE_SERVICE_CHECK.toString()));
     serviceActions.put("mapreduce"  , Arrays.asList(Role.MAPREDUCE_SERVICE_CHECK.toString()));

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/f88f7135/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 4502b93..6336bfe 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -5449,7 +5449,8 @@ public class AmbariManagementControllerTest {
     Assert.assertNotNull(execCmd.getConfigurationTags().get("hdfs-site"));
     Assert.assertEquals(1, storedTasks.size());
     Assert.assertEquals(host2, execCmd.getConfigurations().get
-      ("hdfs-exclude-file").get("datanodes"));
+        ("hdfs-exclude-file").get("datanodes"));
+    Assert.assertNotNull(execCmd.getConfigurationTags().get("hdfs-exclude-file"));
   }
 
   @Test


Mime
View raw message