百度MapReduce BMR

    InstanceGroup(实例组)

    查询实例组列表

    如下代码可根据集群ID获取其实例组信息:

     try:
        response = bmr_client.list_instance_groups(cluster_id)
        for instance_group in response.instance_groups:
            LOG.debug('list instance groups %s: %s' % (instance_group.id, instance_group))
    except BceHttpClientError as e:
        if isinstance(e.last_error, BceServerError):
            LOG.error('list_instance_groups failed. Response %s, code: %s, msg: %s'
                      % (e.last_error.status_code, e.last_error.code, e.last_error.message))
        else:
            LOG.error('list_instance_groups failed. Unknown exception: %s' % e)

    修改实例组配置

    BMR支持对CORE、TASK节点进行配置变更,示例代码如下:

     try:
        bmr_client.scale_cluster(cluster_id, instance_group_id, instance_count)
    except BceHttpClientError as e:
        if isinstance(e.last_error, BceServerError):
            LOG.error('scale_cluster failed. Response %s, code: %s, msg: %s'
                      % (e.last_error.status_code, e.last_error.code, e.last_error.message))
        else:
            LOG.error('scale_cluster failed. Unknown exception: %s' % e)
    一篇
    Instance(实例)
    一篇
    Cluster(集群)