apache_bigtop_base.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:juju-apache-bigtop 作者: c0s 项目源码 文件源码
def prepare_bigtop_config(self, hr_conf, NN=None, RM=None, extra=None):
        '''
        NN: fqdn of the namenode (head node)
        RM: fqdn of the resourcemanager (optional)
        extra: list of extra cluster components
        '''
        # TODO storage dirs should be configurable
        # TODO list of cluster components should be configurable
        cluster_components = ['hadoop']
        # Setting NN (our head node) is required; exit and log if we dont have it
        if NN is None:
            hookenv.log("No NN hostname given for install")
            hookenv.status_set("waiting", "Cannot install without NN")
            sys.exit(1)
        else:
            nn_fqdn = NN
            hookenv.log("Using %s as our hadoop_head_node" % nn_fqdn)

        # If we have an RM, add 'yarn' to the installed components
        if RM is None:
            rm_fqdn = ''
            hookenv.log("No RM hostname given for install")
        else:
            rm_fqdn = RM
            cluster_components.append('yarn')

        # Add anything else the user wanted
        if extra is not None:
            cluster_components.extend(extra)

        java_package_name = self.options.get('java_package_name')
        bigtop_apt = self.options.get('bigtop_repo-{}'.format(utils.cpu_arch()))

        yaml_data = {
            'bigtop::hadoop_head_node': nn_fqdn,
            'hadoop::common_yarn::hadoop_rm_host': rm_fqdn,
            'hadoop::hadoop_storage_dirs': ['/data/1', '/data/2'],
            'hadoop_cluster_node::cluster_components': cluster_components,
            'bigtop::jdk_package_name': '{0}'.format(java_package_name),
            'bigtop::bigtop_repo_uri': '{0}'.format(bigtop_apt),
        }

        Path(hr_conf).dirname().makedirs_p()
        with open(hr_conf, 'w+') as fd:
            yaml.dump(yaml_data, fd)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号