文档

获取集群信息

更新时间:

接口

get_cluster

参数

参数 类型 是否必需 说明
clusterId String 集群ID

返回值

成功后返回一个 GetClusterResponse 实例,可以通过这个实例的 getCluster() 方法,拿到Cluster对象。如果失败,抛出异常: ClientException

例子

Java 源码:

  1. import com.aliyuncs.batchcompute.main.v20151111.*;
  2. import com.aliyuncs.batchcompute.model.v20151111.*;
  3. import com.aliyuncs.batchcompute.pojo.v20151111.*;
  4. import com.aliyuncs.exceptions.ClientException;
  5. public class GetCluster {
  6. static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
  7. static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
  8. static String REGION_ID = "cn-xxx"; //这里填写 region
  9. static String ClusterId = "cls-xxx"; //这里填写 集群Id
  10. public static void main(String[] args) {
  11. BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
  12. try{
  13. GetClusterResponse response = client.getCluster(ClusterId);
  14. //成功
  15. Cluster cluster = response.getCluster();
  16. String state = cluster.getState();
  17. String name = cluster.getName();
  18. System.out.println("Name:" + name);
  19. System.out.println("State:" + state);
  20. }catch(ClientException e){
  21. e.printStackTrace();
  22. //失败
  23. }
  24. }
  25. }

执行结果

  1. {
  2. Name: cluster_test
  3. State: Active
  4. }
  • 本页导读 (0)
文档反馈