Explorar el Código

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

Siddharth Wagle hace 11 años
padre
commit
c85e308944

+ 1 - 1
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):

+ 23 - 1
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__())
+

+ 9 - 0
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

+ 5 - 0
ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementController.java

@@ -520,6 +520,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

+ 4 - 12
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;
   }

+ 31 - 0
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()
+

+ 4 - 1
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 = ""

+ 31 - 0
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()
+

+ 4 - 1
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 = ""