You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sw...@apache.org on 2014/02/20 20:29:15 UTC

git commit: AMBARI-4708. Actual configs not updated after restart of host component. (Dmytro Sen via swagle)

Repository: ambari
Updated Branches:
  refs/heads/trunk d4c021d8d -> c85e30894


AMBARI-4708. Actual configs not updated after restart of host component. (Dmytro Sen via swagle)


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

Branch: refs/heads/trunk
Commit: c85e308944d130ddb41882fe6c9d5a43b3a91f12
Parents: d4c021d
Author: Siddharth Wagle <sw...@hortonworks.com>
Authored: Thu Feb 20 11:28:00 2014 -0800
Committer: Siddharth Wagle <sw...@hortonworks.com>
Committed: Thu Feb 20 11:28:57 2014 -0800

----------------------------------------------------------------------
 .../libraries/script/config_dictionary.py       |  2 +-
 .../libraries/script/hook.py                    | 24 ++++++++++++++-
 .../AmbariCustomCommandExecutionHelper.java     |  9 ++++++
 .../controller/AmbariManagementController.java  |  5 ++++
 .../AmbariManagementControllerImpl.java         | 16 +++-------
 .../1.3.2/hooks/before-RESTART/scripts/hook.py  | 31 ++++++++++++++++++++
 .../1.3.2/hooks/before-START/scripts/params.py  |  5 +++-
 .../2.0.6/hooks/before-RESTART/scripts/hook.py  | 31 ++++++++++++++++++++
 .../2.0.6/hooks/before-START/scripts/params.py  |  5 +++-
 9 files changed, 112 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-agent/src/main/python/resource_management/libraries/script/config_dictionary.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/script/config_dictionary.py b/ambari-agent/src/main/python/resource_management/libraries/script/config_dictionary.py
index ab94d60..9f7e2ce 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/script/config_dictionary.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/script/config_dictionary.py
@@ -55,7 +55,7 @@ class ConfigDictionary(dict):
     else: 
       try:
         value = int(value)
-      except (ValueError, TypeError):
+      exce  pt (ValueError, TypeError):
         try:
           value =  float(value)
         except (ValueError, TypeError):

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-agent/src/main/python/resource_management/libraries/script/hook.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/libraries/script/hook.py b/ambari-agent/src/main/python/resource_management/libraries/script/hook.py
index c5cae63..19b5204 100644
--- a/ambari-agent/src/main/python/resource_management/libraries/script/hook.py
+++ b/ambari-agent/src/main/python/resource_management/libraries/script/hook.py
@@ -21,6 +21,8 @@ limitations under the License.
 __all__ = ["Hook"]
 
 from resource_management.libraries.script import Script
+import subprocess
+import sys
 
 class Hook(Script):
   """
@@ -33,6 +35,26 @@ class Hook(Script):
 
   def choose_method_to_execute(self, command_name):
     """
-    Changes loogics of resolving method name
+    Changes logics of resolving method name
     """
     return super(Hook, self).choose_method_to_execute(self.HOOK_METHOD_NAME)
+
+
+  def run_custom_hook(self, command):
+    """
+    Runs custom hook
+    """
+    args = sys.argv
+    #Hook script to run
+    args[0] = args[0].replace(args[1], command)
+    #Hook script base directory
+    args[3] = args[3].replace(args[1], command)
+
+
+    cmd = [sys.executable]
+    cmd.extend(args)
+
+    if subprocess.call(cmd) != 0:
+      self.fail_with_error("Error: Unable to run the custom hook script " +
+                           cmd.__str__())
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
index be800e7..0d83e88 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariCustomCommandExecutionHelper.java
@@ -675,6 +675,15 @@ public class AmbariCustomCommandExecutionHelper {
           Configuration.HIVE_METASTORE_PASSWORD_PROPERTY, "", true);
     }
 
+    String jobtrackerHost = amc.getJobTrackerHost(cluster);
+    if (!scHost.getHostName().equals(jobtrackerHost)) {
+      if (configTags.get(Configuration.GLOBAL_CONFIG_TAG) != null) {
+        configHelper.applyCustomConfig(
+          configurations, Configuration.GLOBAL_CONFIG_TAG,
+          Configuration.RCA_ENABLED_PROPERTY, "false", false);
+      }
+    }
+
     execCmd.setConfigurations(configurations);
     execCmd.setConfigurationTags(configTags);
     if (commandParams == null) { // if not defined

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
index a6e52b0..2063f88 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java
@@ -521,6 +521,11 @@ public interface AmbariManagementController {
   public ExecutionScheduleManager getExecutionScheduleManager();
 
   /**
+   * Get JobTracker hostname
+   */
+  public String getJobTrackerHost(Cluster cluster);
+
+  /**
    * Gets the effective passive state for a host component
    * @param cluster the cluster
    * @param service the service

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/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 8bf5afa..6ab0ca9 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
@@ -18,17 +18,6 @@
 
 package org.apache.ambari.server.controller;
 
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.AMBARI_DB_RCA_DRIVER;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.AMBARI_DB_RCA_PASSWORD;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.AMBARI_DB_RCA_URL;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.AMBARI_DB_RCA_USERNAME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JAVA_HOME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JCE_NAME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_LOCATION;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.JDK_NAME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_NAME;
-import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.STACK_VERSION;
-
 import java.io.File;
 import java.io.IOException;
 import java.net.InetAddress;
@@ -118,6 +107,8 @@ import com.google.inject.Injector;
 import com.google.inject.Singleton;
 import com.google.inject.persist.Transactional;
 
+import static org.apache.ambari.server.agent.ExecutionCommand.KeyNames.*;
+
 @Singleton
 public class AmbariManagementControllerImpl implements
     AmbariManagementController {
@@ -925,7 +916,7 @@ public class AmbariManagementControllerImpl implements
     return null;
   }
 
-  private String getJobTrackerHost(Cluster cluster) {
+  public String getJobTrackerHost(Cluster cluster) {
     try {
       Service svc = cluster.getService("MAPREDUCE");
       ServiceComponent sc = svc.getServiceComponent(Role.JOBTRACKER.toString());
@@ -1350,6 +1341,7 @@ public class AmbariManagementControllerImpl implements
     hostLevelParams.put(JCE_NAME, getJCEName());
     hostLevelParams.put(STACK_NAME, stackId.getStackName());
     hostLevelParams.put(STACK_VERSION, stackId.getStackVersion());
+    hostLevelParams.put(DB_NAME, getServerDB());
     hostLevelParams.putAll(getRcaParameters());
     return hostLevelParams;
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py
new file mode 100644
index 0000000..7042602
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-RESTART/scripts/hook.py
@@ -0,0 +1,31 @@
+##!/usr/bin/env python2.6
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+from resource_management import *
+
+class BeforeConfigureHook(Hook):
+
+  def hook(self, env):
+    self.run_custom_hook('START')
+
+if __name__ == "__main__":
+  BeforeConfigureHook().execute()
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/params.py
index 0b62c87..e602895 100644
--- a/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/1.3.2/hooks/before-START/scripts/params.py
@@ -116,7 +116,10 @@ ambari_db_rca_driver = config['hostLevelParams']['ambari_db_rca_driver']
 ambari_db_rca_username = config['hostLevelParams']['ambari_db_rca_username']
 ambari_db_rca_password = config['hostLevelParams']['ambari_db_rca_password']
 
-rca_enabled = config['configurations']['global']['rca_enabled']
+if 'rca_enabled' in config['configurations']['global']:
+  rca_enabled =  config['configurations']['global']['rca_enabled']
+else:
+  rca_enabled = False
 rca_disabled_prefix = "###"
 if rca_enabled == True:
   rca_prefix = ""

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py
new file mode 100644
index 0000000..7042602
--- /dev/null
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-RESTART/scripts/hook.py
@@ -0,0 +1,31 @@
+##!/usr/bin/env python2.6
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+"""
+
+from resource_management import *
+
+class BeforeConfigureHook(Hook):
+
+  def hook(self, env):
+    self.run_custom_hook('START')
+
+if __name__ == "__main__":
+  BeforeConfigureHook().execute()
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/c85e3089/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py
index 3239c7a..85ee2b9 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/hooks/before-START/scripts/params.py
@@ -116,7 +116,10 @@ ambari_db_rca_driver = config['hostLevelParams']['ambari_db_rca_driver'][0]
 ambari_db_rca_username = config['hostLevelParams']['ambari_db_rca_username'][0]
 ambari_db_rca_password = config['hostLevelParams']['ambari_db_rca_password'][0]
 
-rca_enabled = config['configurations']['global']['rca_enabled']
+if 'rca_enabled' in config['configurations']['global']:
+  rca_enabled =  config['configurations']['global']['rca_enabled']
+else:
+  rca_enabled = False
 rca_disabled_prefix = "###"
 if rca_enabled == True:
   rca_prefix = ""