获取集群实例信息

接口

getClusterInstance

参数

参数 类型 是否必需 说明
clusterId String 集群ID
groupName String 实例组名称
id String 集群实例ID

返回值

成功后返回一个 GetClusterInstanceResponse 实例,可以通过这个实例的 getClusterInstance() 方法,获取ClusterInstance 对象。如果失败,抛出异常: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 GetClusterInstance {
  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";
  10. public static void main(String[] args) {
  11. BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
  12. try{
  13. String groupName = "group1";
  14. String id = "ins-xxx"; //实例Id
  15. GetClusterInstanceResponse response = client.getClusterInstance(ClusterId,groupName,id);
  16. //成功
  17. ClusterInstance clusterInstance = response.getClusterInstance();
  18. System.out.println("\tId:" + clusterInstance.getId());
  19. System.out.println("\tIP:" + clusterInstance.getIpAddress());
  20. System.out.println("\tState:" + clusterInstance.getState());
  21. }catch(ClientException e){
  22. e.printStackTrace();
  23. //失败
  24. }
  25. }
  26. }

执行结果

  1. {
  2. Id:ins-6kivnjur5lnpkvo8276000
  3. IP:10.170.104.77
  4. State:Running
  5. }