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 2013/06/10 04:32:16 UTC

svn commit: r1491326 - in /incubator/ambari/branches/branch-1.2.4: ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/ ambari-agent/src/main/puppet/modules/hdp/manifests/ ambari-server/src/main/java/org/apache/ambari/server/configuration/ ambari...

Author: smohanty
Date: Mon Jun 10 02:32:15 2013
New Revision: 1491326

URL: http://svn.apache.org/r1491326
Log:
AMBARI-2336. Datanode start failed (with Oracle DB) due to RCA setup. (Siddharth Wagle via smohanty)

Modified:
    incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/init.pp
    incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp
    incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
    incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java

Modified: incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/init.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/init.pp?rev=1491326&r1=1491325&r2=1491326&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/init.pp (original)
+++ incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/init.pp Mon Jun 10 02:32:15 2013
@@ -38,10 +38,8 @@ class hdp-hadoop::initialize()
   hdp-hadoop::common { 'common':}
   anchor{'hdp-hadoop::initialize::begin':} -> Hdp-hadoop::Common['common'] -> anchor{'hdp-hadoop::initialize::end':}
 
-# Configs generation  
-
-debug('##Configs generation for hdp-hadoop')
-
+  # Configs generation
+  debug('##Configs generation for hdp-hadoop')
 
   if has_key($configuration, 'mapred-queue-acls') {
     configgenerator::configfile{'mapred-queue-acls': 
@@ -276,6 +274,29 @@ class hdp-hadoop(
       owner => $hdfs_user,
     }
 
+    # Copy database drivers for rca enablement
+    $server_db_name = $hdp::params::server_db_name
+    $hadoop_lib_home = $hdp::params::hadoop_lib_home
+    $db_driver_filename = $hdp::params::db_driver_file
+    $oracle_driver_url = $hdp::params::oracle_jdbc_url
+    $mysql_driver_url = $hdp::params::mysql_jdbc_url
+
+    if ($server_db_name == 'oracle' and $oracle_driver_url != "") {
+      $db_driver_dload_cmd = "curl -f --retry 5 $oracle_driver_url -o ${hadoop_lib_home}/${db_driver_filename}"
+    } elsif ($server_db_name == 'mysql' and $mysql_driver_url != "") {
+      $db_driver_dload_cmd = "curl -f --retry 5 $mysql_driver_url -o ${hadoop_lib_home}/${db_driver_filename}"
+    }
+    if ($db_driver_dload_cmd != undef) {
+      exec { '${db_driver_dload_cmd}':
+        command => $db_driver_dload_cmd,
+        unless  => "test -e ${hadoop_lib_home}/${db_driver_filename}",
+        creates => "${hadoop_lib_home}/${db_driver_filename}",
+        path    => ["/bin","/usr/bin/"],
+        require => Hdp-hadoop::Package['hadoop'],
+        before  => Anchor['hdp-hadoop::end']
+      }
+    }
+
     Anchor['hdp-hadoop::begin'] -> Hdp-hadoop::Package<||> ->  Hdp::User<|title == $hdfs_user or title == $mapred_user|>  ->
       Hdp::Directory_recursive_create[$hadoop_config_dir] -> Hdp-hadoop::Configfile<|tag == 'common'|> ->
       Hdp::Directory_recursive_create[$logdirprefix] -> Hdp::Directory_recursive_create[$piddirprefix] -> Anchor['hdp-hadoop::end']

Modified: incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp?rev=1491326&r1=1491325&r2=1491326&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp (original)
+++ incubator/ambari/branches/branch-1.2.4/ambari-agent/src/main/puppet/modules/hdp/manifests/params.pp Mon Jun 10 02:32:15 2013
@@ -237,6 +237,10 @@ class hdp::params()
 
   $jce_policy_zip = "jce_policy-6.zip"
   $jce_location = hdp_default("jce_location","http://download.oracle.com/otn-pub/java/jce_policy/6")
+  $server_db_name = hdp_default("db_name", "postgres")
+  $oracle_jdbc_url = hdp_default("oracle_jdbc_url", "")
+  $mysql_jdbc_url = hdp_default("mysql_jdbc_url", "")
+  $db_driver_file = hdp_default("db_driver_filename", "")
 
   #####
   $hadoop_home = hdp_default("hadoop_home","/usr")

Modified: incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java?rev=1491326&r1=1491325&r2=1491326&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java (original)
+++ incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java Mon Jun 10 02:32:15 2013
@@ -75,6 +75,15 @@ public class Configuration {
 
   public static final String CLIENT_SECURITY_KEY = "client.security";
   public static final String CLIENT_API_PORT_KEY = "client.api.port";
+  public static final String SERVER_DB_NAME_KEY = "server.jdbc.database";
+  public static final String SERVER_DB_NAME_DEFAULT = "postgres";
+  public static final String ORACLE_DB_NAME = "oracle";
+  public static final String MYSQL_DB_NAME = "mysql";
+
+  public static final String OJDBC_JAR_NAME_KEY = "db.oracle.jdbc.name";
+  public static final String OJDBC_JAR_NAME_DEFAULT = "ojdbc6.jar";
+  public static final String MYSQL_JAR_NAME_KEY = "db.mysql.jdbc.name";
+  public static final String MYSQL_JAR_NAME_DEFAULT = "mysql-connector-java.jar";
   public static final String LDAP_USE_SSL_KEY = "authentication.ldap.useSSL";
   public static final String LDAP_PRIMARY_URL_KEY =
       "authentication.ldap.primaryUrl";
@@ -526,6 +535,18 @@ public class Configuration {
     return Integer.parseInt(properties.getProperty(CLIENT_API_PORT_KEY, String.valueOf(CLIENT_API_PORT_DEFAULT)));
   }
 
+  public String getOjdbcJarName() {
+	  return properties.getProperty(OJDBC_JAR_NAME_KEY, OJDBC_JAR_NAME_DEFAULT);
+  }
+  
+  public String getServerDBName() {
+	  return properties.getProperty(SERVER_DB_NAME_KEY, SERVER_DB_NAME_DEFAULT);
+  }
+  
+  public String getMySQLJarName() {
+	  return properties.getProperty(MYSQL_JAR_NAME_KEY, MYSQL_JAR_NAME_DEFAULT);
+  }
+  
   public JPATableGenerationStrategy getJPATableGenerationStrategy() {
     return JPATableGenerationStrategy.fromString(System.getProperty(SERVER_JDBC_GENERATE_TABLES_KEY));
   }

Modified: incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java?rev=1491326&r1=1491325&r2=1491326&view=diff
==============================================================================
--- incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java (original)
+++ incubator/ambari/branches/branch-1.2.4/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariManagementControllerImpl.java Mon Jun 10 02:32:15 2013
@@ -156,7 +156,10 @@ public class AmbariManagementControllerI
       "/resources/";
 
   final private String jdkResourceUrl;
-
+  final private String ojdbcUrl;
+  final private String serverDB;
+  final private String mysqljdbcUrl;
+  
   @Inject
   public AmbariManagementControllerImpl(ActionManager actionManager,
       Clusters clusters, Injector injector) throws Exception {
@@ -175,6 +178,13 @@ public class AmbariManagementControllerI
     } else {
     		this.jdkResourceUrl = null;
     }
+    
+    this.ojdbcUrl = "http://" + masterHostname + ":" + 
+    	 + configs.getClientApiPort() + JDK_RESOURCE_LOCATION + "/" + configs.getOjdbcJarName();
+    
+    this.mysqljdbcUrl = "http://" + masterHostname + ":" + 
+       	 + configs.getClientApiPort() + JDK_RESOURCE_LOCATION + "/" + configs.getMySQLJarName();
+    this.serverDB = configs.getServerDBName();
   }
 
   @Override
@@ -970,6 +980,16 @@ public class AmbariManagementControllerI
     params.put("repo_info", repoInfo);
     params.put("jdk_location", this.jdkResourceUrl);
     params.put("stack_version", stackId.getStackVersion());
+    params.put("db_name", this.serverDB);
+    params.put("mysql_jdbc_url" , this.mysqljdbcUrl);
+    params.put("oracle_jdbc_url", this.ojdbcUrl);
+    if (configs.getServerDBName().equalsIgnoreCase(Configuration
+      .ORACLE_DB_NAME)) {
+      params.put("db_driver_filename", configs.getOjdbcJarName());
+    } else if (configs.getServerDBName().equalsIgnoreCase(Configuration
+      .MYSQL_DB_NAME)) {
+      params.put("db_driver_filename", configs.getMySQLJarName());
+    }
     execCmd.setHostLevelParams(params);
 
     Map<String, String> roleParams = new TreeMap<String, String>();