Пример #1
0
    def install(self, env):
        from common import presto_cli_file
        from common_func import exec_command

        try:
            exec_command('cp -r {1} {0}/presto-cli'.format(
                '/usr/bin', presto_cli_file))
            exec_command('chmod +x {0}/presto-cli'.format('/usr/bin'))
        except BaseException:
            pass
Пример #2
0
    def configure(self, env):
        import os
        from common import node_properties, jvm_config, config_properties, \
            presto_etc_dir, memory_configs
        from common_func import create_connectors, delete_connectors

        key_val_template = '{0}={1}\n'
        hostname = exec_command('hostname')

        with open(os.path.join(presto_etc_dir, 'node.properties'), 'w') as f:
            for key, value in node_properties.iteritems():
                f.write(key_val_template.format(key, value))
            f.write(key_val_template.format('node.id', hostname))

        with open(os.path.join(presto_etc_dir, 'jvm.config'), 'w') as f:
            f.write(jvm_config['jvm.config'])

        with open(os.path.join(presto_etc_dir, 'config.properties'), 'w') as f:
            for key, value in config_properties.iteritems():
                if key in memory_configs:
                    value += 'MB'
                f.write(key_val_template.format(key, value))
            f.write(key_val_template.format('coordinator', 'true'))
            f.write(key_val_template.format('discovery-server.enabled',
                                            'true'))

        create_connectors()
        delete_connectors()
Пример #3
0
    def start(self, env):
        from common import presto_launcher_script, config_properties, host_info
        from presto_client import PrestoClient, smoketest_presto

        self.configure(env)
        exec_command('{0} start'.format(presto_launcher_script))
        # test
        if 'presto_worker_hosts' in host_info.keys():
            all_hosts = host_info['presto_worker_hosts'] + \
                        host_info['presto_coordinator_hosts']
        else:
            all_hosts = host_info['presto_coordinator_hosts']
        # use Set, coordinator could be worker
        all_hosts = set(all_hosts)
        smoketest_presto(
            PrestoClient('localhost', 'root',
                         config_properties['http-server.http.port']),
            all_hosts)
Пример #4
0
from common_func import exec_command, kv_print

from resource_management.libraries.script.script import Script

# Read config
package_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
config = cp.ConfigParser()
config.read(os.path.join(package_dir, 'config.ini'))

# JAVA_HOME
java_home = config.get('other', 'java_home')
kv_print('java_home', java_home)

# Tarball file
presto_tar_file_0 = config.get('download', 'presto_tar_file')
presto_tar_file = exec_command('ls {0}'.format(presto_tar_file_0))
# presto_tar_name = presto_tar_file.split('/')[-1]

presto_cli_file_0 = config.get('download', 'presto_cli_file')
presto_cli_file = exec_command('ls {0}'.format(presto_cli_file_0))
kv_print('presto_tar_file', presto_tar_file)
kv_print('presto_cli_file', presto_cli_file)

# Config object that holds the configurations declared in the config xml file
script_config = Script.get_config()

host_info = script_config['clusterHostInfo']
host_level_params = script_config['hostLevelParams']
kv_print('host_info', host_info)
kv_print('host_level_params', host_level_params)
Пример #5
0
    def install(self, env):
        from common import presto_install_dir, presto_plugin_dir, presto_launcher_script, \
            java_home, presto_tar_file
        from common_func import init_dirs

        # 0: presto_tar_file; 1: presto_install_dir; 2: bin or lib or plugin; 3: strip-components
        tar_pattern = 'tar -xzvf {0} -C {1} --strip-components={3} `tar -tf {0} | head -n 1`{2}'
        # cleanup
        exec_command('rm -rf {0}'.format(presto_install_dir))
        # init dirs
        init_dirs()
        # bin, java_home
        exec_command(
            tar_pattern.format(presto_tar_file, presto_install_dir, 'bin', 1))
        exec_command('sed -i "2iexport JAVA_HOME={0}" {1}'.format(
            java_home, presto_launcher_script))
        exec_command(
            'sed -i "3iexport PATH=\$JAVA_HOME/bin:\$PATH" {0}'.format(
                presto_launcher_script))
        # lib
        exec_command(
            tar_pattern.format(presto_tar_file, presto_install_dir, 'lib', 1))
        # plugin
        exec_command(
            tar_pattern.format(presto_tar_file, presto_plugin_dir, 'plugin',
                               2))
        # config
        self.configure(env)
Пример #6
0
    def status(self, env):
        from common import presto_launcher_script

        stdout = exec_command('{0} status'.format(presto_launcher_script))
        if 'Not running' in stdout:
            raise ComponentIsNotRunning(stdout)
Пример #7
0
    def stop(self, env):
        from common import presto_launcher_script

        exec_command('{0} stop'.format(presto_launcher_script))
    def start(self, env):
        from common import presto_launcher_script

        self.configure(self)
        exec_command('{0} start'.format(presto_launcher_script))