Merge "Remove verbose code for hive metastore schema creation in MapR plugin"

This commit is contained in:
Jenkins 2015-11-16 09:26:38 +00:00 committed by Gerrit Code Review
commit e864cb15bb
3 changed files with 9 additions and 39 deletions

View File

@ -38,8 +38,6 @@ HIVE_SERVER_2 = np.NodeProcess(
class Hive(s.Service):
SCHEMA_PATH_TEMPLATE = ("%(hive_home)s/scripts/metastore/upgrade/mysql/"
"hive-schema-%(hive_version)s.0.mysql.sql")
def __init__(self):
super(Hive, self).__init__()
@ -112,13 +110,6 @@ class Hive(s.Service):
LOG.debug("Creating Hive warehouse dir")
r.execute_command(cmd % args, raise_when_error=False)
def get_schema_path(self, cluster_context):
args = {
"hive_home": self.home_dir(cluster_context),
"hive_version": self.version,
}
return self.SCHEMA_PATH_TEMPLATE % args
class HiveV013(Hive):
def __init__(self):
@ -132,11 +123,3 @@ class HiveV10(Hive):
super(HiveV10, self).__init__()
self._version = "1.0"
self._dependencies = [("mapr-hive", self.version)]
def get_schema_path(self, cluster_context):
args = {
"hive_home": self.home_dir(cluster_context),
# Hive 1.0 uses schema for Hive 0.14
"hive_version": "0.14",
}
return self.SCHEMA_PATH_TEMPLATE % args

View File

@ -10,6 +10,14 @@
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>datanucleus.autoCreateSchema</name>
<value>true</value>
<description>
creates necessary schema on a startup if one doesn't exist.
</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>

View File

@ -43,9 +43,6 @@ class MySQL(s.Service):
SELECT_DATA % "SELECT Host FROM mysql.user WHERE mysql.user.User='%s'"
)
SCHEMA_PATH = (
'/opt/mapr/hive/hive-{0}/scripts/metastore/upgrade/mysql/'
'hive-schema-{0}.0.mysql.sql')
DRIVER_CLASS = 'com.mysql.jdbc.Driver'
MYSQL_SERVER_PORT = 3306
MYSQL_INSTALL_SCRIPT = 'plugins/mapr/resources/install_mysql.sh'
@ -115,25 +112,7 @@ class MySQL(s.Service):
db_name = MySQL.METASTORE_SPECS.db_name
if db_name not in databases:
MySQL._create_service_db(instance, MySQL.METASTORE_SPECS)
MySQL._grant_access(instance, MySQL.METASTORE_SPECS, instances)
with hive_meta.remote() as r:
hive_serv = cluster_context.get_service(hive.HIVE_METASTORE)
schema_path = hive_serv.get_schema_path(cluster_context)
script = MySQL._create_script_obj('hive_schema.sql',
'hive_schema.sql',
db_name=db_name,
path=schema_path)
r.write_file_to(script.remote_path, script.render())
args = {
'user': MySQL.METASTORE_SPECS.user,
'password': MySQL.METASTORE_SPECS.password,
'host': instance.internal_ip,
'path': script.remote_path
}
cmd = 'mysql -h{host} -u{user} -p{password} < {path}'
r.execute_command(cmd.format(**args), run_as_root=True)
else:
MySQL._grant_access(instance, MySQL.METASTORE_SPECS, instances)
MySQL._grant_access(instance, MySQL.METASTORE_SPECS, instances)
@staticmethod
def _create_oozie_db(instance, databases, instances):