Ottomata has submitted this change and it was merged.

Change subject: Make hive-metastore service depend on libmysql-jar in classpath
......................................................................


Make hive-metastore service depend on libmysql-jar in classpath

Bug: T133198
Change-Id: Iae87cd859d3fd4f206bd8e04a7a5401a6a0ff76d
---
M manifests/hive/metastore.pp
M manifests/hive/metastore/mysql.pp
A manifests/hive/metastore/mysql/jar.pp
3 files changed, 34 insertions(+), 12 deletions(-)

Approvals:
  Ottomata: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/manifests/hive/metastore.pp b/manifests/hive/metastore.pp
index 094311c..b8230ce 100644
--- a/manifests/hive/metastore.pp
+++ b/manifests/hive/metastore.pp
@@ -23,6 +23,14 @@
         require => Package['hive-metastore'],
     }
 
+    # If the metastore will use MySQL for storage, then
+    # we need to make sure the libmysql-java .jar is in
+    # hive-metastore's classpath before it launches.
+    if $::cdh::hive::jdbc_protocol == 'mysql' {
+        include cdh::hive::metastore::mysql::jar
+        Class['cdh::hive::metastore::mysql::jar'] -> Service['hive-metastore']
+    }
+
     service { 'hive-metastore':
         ensure     => 'running',
         require    => [
diff --git a/manifests/hive/metastore/mysql.pp 
b/manifests/hive/metastore/mysql.pp
index c5e45ab..c791862 100644
--- a/manifests/hive/metastore/mysql.pp
+++ b/manifests/hive/metastore/mysql.pp
@@ -26,17 +26,9 @@
         }
     }
 
-    if (!defined(Package['libmysql-java'])) {
-        package { 'libmysql-java':
-            ensure => 'installed',
-        }
-    }
-    # symlink the mysql.jar into /var/lib/hive/lib
-    file { '/usr/lib/hive/lib/libmysql-java.jar':
-        ensure  => 'link',
-        target  => '/usr/share/java/mysql.jar',
-        require => Package['libmysql-java'],
-    }
+    # Install the libmysql-java .jar into Hive's classpath so that
+    # hive schematool can run.
+    include cdh::hive::metastore::mysql::jar
 
     # Infer mysql creds from either cdh::hive class
     # or from hiera, if the cdh::hive class has not been included.
@@ -85,7 +77,7 @@
         unless  => "/usr/bin/mysql ${username_option} ${password_option} -D 
${jdbc_database} -e \"SHOW TABLES;\" | grep -q 'VERSION'",
         user    => 'root',
         require => [
-            File['/usr/lib/hive/lib/libmysql-java.jar'],
+            Class['cdh::hive::metastore::mysql::jar'],
             Exec['hive_mysql_create_user'],
             Exec['hive_mysql_create_database'],
             Package['hive'],
diff --git a/manifests/hive/metastore/mysql/jar.pp 
b/manifests/hive/metastore/mysql/jar.pp
new file mode 100644
index 0000000..479490b
--- /dev/null
+++ b/manifests/hive/metastore/mysql/jar.pp
@@ -0,0 +1,22 @@
+# == Class cdh::hive::metastore::mysql::jar
+# Installs libmysql-java and symlinks the .jar artifact
+# into /usr/lib/hive/lib.
+#
+# This is a standalone class so that it is possible to safely
+# include it from multiple classes (e.g. cdh::hive::metastore::mysql
+# and cdh::hive::metastore).
+#
+class cdh::hive::metastore::mysql::jar {
+    Package['hive'] -> Class['cdh::hive::metastore::mysql::jar']
+
+    if (!defined(Package['libmysql-java'])) {
+        package { 'libmysql-java':
+            ensure => 'installed',
+        }
+    }
+    file { '/usr/lib/hive/lib/libmysql-java.jar':
+        ensure  => 'link',
+        target  => '/usr/share/java/mysql.jar',
+        require => Package['libmysql-java'],
+    }
+}

-- 
To view, visit https://gerrit.wikimedia.org/r/284506
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iae87cd859d3fd4f206bd8e04a7a5401a6a0ff76d
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet/cdh
Gerrit-Branch: master
Gerrit-Owner: Ottomata <[email protected]>
Gerrit-Reviewer: Elukey <[email protected]>
Gerrit-Reviewer: Ottomata <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to