接口
getClusterInstance
参数
参数 | 类型 | 是否必需 | 说明 |
---|---|---|---|
clusterId | String | 是 | 集群ID |
groupName | String | 是 | 实例组名称 |
id | String | 是 | 集群实例ID |
返回值
成功后返回一个 GetClusterInstanceResponse
实例,可以通过这个实例的 getClusterInstance()
方法,获取ClusterInstance
对象。如果失败,抛出异常:ClientException
。
例子
Java 源码:
import com.aliyuncs.batchcompute.main.v20151111.*;
import com.aliyuncs.batchcompute.model.v20151111.*;
import com.aliyuncs.batchcompute.pojo.v20151111.*;
import com.aliyuncs.exceptions.ClientException;
public class GetClusterInstance {
static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyId
static String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecret
static String REGION_ID = "cn-xxx"; //这里填写 region
static String ClusterId = "cls-xxx";
public static void main(String[] args) {
BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);
try{
String groupName = "group1";
String id = "ins-xxx"; //实例Id
GetClusterInstanceResponse response = client.getClusterInstance(ClusterId,groupName,id);
//成功
ClusterInstance clusterInstance = response.getClusterInstance();
System.out.println("\tId:" + clusterInstance.getId());
System.out.println("\tIP:" + clusterInstance.getIpAddress());
System.out.println("\tState:" + clusterInstance.getState());
}catch(ClientException e){
e.printStackTrace();
//失败
}
}
}
执行结果
{
Id:ins-6kivnjur5lnpkvo8276000
IP:10.170.104.77
State:Running
}
文档内容是否对您有帮助?