百度智能云

All Product Document

          MapReduce

          InstanceGroup

          Query Instance Group Lists

          The following code is used to obtain instance group information based on cluster 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)

          Modify Instance Group Configurations

          BMR can modify the configuration of CORE and TASK nodes, and the example code is as follows:

           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)
          Previous
          Instance
          Next
          Cluster