~bigdata-dev/charms/trusty/apache-hive/rewrite

« back to all changes in this revision

Viewing changes to hooks/callbacks.py

  • Committer: Cory Johns
  • Date: 2015-02-19 22:27:53 UTC
  • Revision ID: cory.johns@canonical.com-20150219222753-pgbh6ruigkey6406
Added DB schema init

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
            props['javax.jdo.option.ConnectionPassword'] = mysql['password']
71
71
            props['javax.jdo.option.ConnectionDriverName'] = "com.mysql.jdbc.Driver"
72
72
            props['hive.hwi.war.file'] = self.DIRS['hive_installed'] / "lib/hive-hwi-%s.jar" % self.HIVE_VERSION
 
73
        self.run('hive', 'bin/schematool', '-initSchema', '-dbType', 'mysql')
73
74
        self.hadoop_base.run('hdfs', 'bin/hdfs', 'dfs', '-mkdir', '-p', '/user/hive/warehouse')
74
75
        self.hadoop_base.run('hdfs', 'bin/hdfs', 'dfs', '-chown', '-R', 'hive', '/user/hive/warehouse')
75
76
 
78
79
            r'.*export HADOOP_HEAPSIZE *=.*': 'export HADOOP_HEAPSIZE=%s' % config['heap'],
79
80
        })
80
81
 
 
82
    def run(self, user, command, *args):
 
83
        """
 
84
        Run a Hive command as the `hive` user in the foreground, checking the return code.
 
85
 
 
86
        :param str command: Command to run, prefixed with `bin/` or `sbin/`
 
87
        :param list args: Additional args to pass to the command
 
88
        """
 
89
        parts = [self.DIRS['hive_installed'] / command] + list(args)
 
90
        quoted = ' '.join("'%s'" % p for p in parts)
 
91
        check_call(['su', user, '-c', quoted])
 
92
 
81
93
    def run_bg(self, user, command, *args):
82
94
        """
83
95
        Run a Hive command as the `hive` user in the background.