Ejemplo n.º 1
0
    def distribution(self, *master_template_args, **kwargs):
        """
        Master makes the distribution

        This only needs to run if there are more than 1 node (self.size>1)
        """
        config_path = resolve_config_paths(self.options.hodconf, self.options.dist)
        m_config = load_hod_config(config_path, self.options.workdir, self.options.modulepaths, self.options.modules)
        m_config.autogen_configs()
        resolver = _setup_template_resolver(m_config, master_template_args)
        _setup_config_paths(m_config, resolver)
Ejemplo n.º 2
0
def gen_cluster_info(label, options):
    """Generate cluster info as a dict, intended to use as template values for CLUSTER_ENV_TEMPLATE."""
    # list of modules that should be loaded: modules for selected service + extra modules specified via --modules
    config_path = resolve_config_paths(options.hodconf, options.dist)
    hodconf = hc.load_hod_config(config_path, options.workdir, options.modules)
    cluster_info = {
        'hadoop_conf_dir': hodconf.configdir,
        'hod_localworkdir': hodconf.localworkdir,
        'label': label,
        'modules': ' '.join(hodconf.modules),
        'workdir': options.workdir
    }
    return cluster_info
Ejemplo n.º 3
0
def gen_cluster_info(label, options):
    """Generate cluster info as a dict, intended to use as template values for CLUSTER_ENV_TEMPLATE."""
    # list of modules that should be loaded: modules for selected service + extra modules specified via --modules
    config_path = resolve_config_paths(options.hodconf, options.dist)
    hodconf = hc.load_hod_config(config_path, options.workdir, options.modulepaths, options.modules)
    cluster_info = {
        'hadoop_conf_dir': hodconf.configdir,
        'hod_localworkdir': hodconf.localworkdir,
        'label': label,
        'modpaths': ' '.join(hodconf.modulepaths),
        'modules': ' '.join(hodconf.modules),
        'workdir': options.workdir
    }
    return cluster_info
Ejemplo n.º 4
0
    def distribution(self, *master_template_args, **kwargs):
        """Master makes the distribution"""
        self.tasks = []
        config_path = resolve_config_paths(self.options.hodconf, self.options.dist)
        m_config = load_hod_config(config_path, self.options.workdir, self.options.modulepaths, self.options.modules)
        m_config.autogen_configs()

        resolver = _setup_template_resolver(m_config, master_template_args)
        _setup_config_paths(m_config, resolver)

        master_env = dict([(v, os.getenv(v)) for v in m_config.master_env])
        # There may be scripts in the hod.conf dir so add it to the PATH
        master_env['PATH'] = master_env.get('PATH', os.getenv('PATH')) + os.pathsep + m_config.hodconfdir
        self.log.debug('MasterEnv is: %s', env2str(master_env))

        svc_cfgs = m_config.service_files
        self.log.info('Loading %d service configs.', len(svc_cfgs))
        for config_filename in svc_cfgs:
            self.log.info('Loading "%s" service config', config_filename)
            config = ConfigOpts.from_file(open(config_filename, 'r'), resolver)
            ranks_to_run = config.runs_on(MASTERRANK, range(self.size))
            self.log.debug('Adding ConfiguredService Task to work with config: %s', str(config))
            cfg_opts = config.to_params(m_config.workdir, m_config.modulepaths, m_config.modules, master_template_args)
            self.tasks.append(Task(ConfiguredService, config.name, ranks_to_run, cfg_opts, master_env))

        if hasattr(self.options, 'script') and self.options.script is not None:
            label = self.options.label
            env_script = 'source ' + hc.cluster_env_file(label)
            script = self.options.script
            script_stdout, script_stderr = _script_output_paths(script, label)
            redirection = ' > %s 2> %s' % (script_stdout, script_stderr)
            start_script = env_script + ' && ' + script + redirection + '; qdel $PBS_JOBID'
            self.log.debug('Adding script Task: %s', start_script)
            # TODO: How can we test this?
            config = ConfigOpts(script, RUNS_ON_MASTER, '', start_script, '', master_env, resolver, timeout=NO_TIMEOUT)
            ranks_to_run = config.runs_on(MASTERRANK, range(self.size))
            cfg_opts = config.to_params(m_config.workdir, m_config.modulepaths, m_config.modules, master_template_args)
            self.tasks.append(Task(ConfiguredService, config.name, ranks_to_run, cfg_opts, master_env))