接口
listClusterInstances
参数
参数 | 类型 | 是否必选 | 说明 |
---|---|---|---|
clusterId | String | 是 | 集群ID. |
groupName | String | 是 | 实例组名称. |
marker | String | 否 | 本页起始资源标识符。默认为空字符串。 |
maxItemCount | int | 否 | 返回条数,最大取值200,默认200 |
返回值
成功后返回一个 ListClusterInstancesResponse
实例, 可以通过这个实例的 getClusterInstance
方法, 获取 ClusterInstance
对象。如果失败,抛出异常: ClientException
。
例子
Java 源码:
import java.util.List;
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 ListClusterInstances {
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";
ListClusterInstancesResponse response = client.listClusterInstances(ClusterId, groupName);
//成功
List<ClusterInstance> list = response.getItems(); //集群实例列表
String marker = response.getNextMarker();//下一个起始Marker
for (int i = 0; i < list.size(); i++){
ClusterInstance clsIns = list.get(i);
System.out.println("{");
System.out.println("\tId:" + clsIns.getId());
System.out.println("\tIP:" + clsIns.getIpAddress());
System.out.println("\tState:" + clsIns.getState());
System.out.println("},");
}
}catch(ClientException e){
e.printStackTrace();
//失败
}
}
}
执行结果:
{
Id:ins-6kivnjur5lnpkvo8276000
IP:10.170.104.77
State:Running
}
文档内容是否对您有帮助?