获取集群信息
更新时间:
接口
get_cluster
参数
| 参数 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
| clusterId | String | 是 | 集群ID |
返回值
成功后返回一个 GetClusterResponse 实例,可以通过这个实例的 getCluster() 方法,拿到Cluster对象。如果失败,抛出异常: 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 GetCluster {static String ACCESS_KEY_ID = "xxx"; //这里填写您的 AccessKeyIdstatic String ACCESS_KEY_SECRET = "xxx"; //这里填写您的 AccessKeySecretstatic String REGION_ID = "cn-xxx"; //这里填写 regionstatic String ClusterId = "cls-xxx"; //这里填写 集群Idpublic static void main(String[] args) {BatchCompute client = new BatchComputeClient(REGION_ID, ACCESS_KEY_ID, ACCESS_KEY_SECRET);try{GetClusterResponse response = client.getCluster(ClusterId);//成功Cluster cluster = response.getCluster();String state = cluster.getState();String name = cluster.getName();System.out.println("Name:" + name);System.out.println("State:" + state);}catch(ClientException e){e.printStackTrace();//失败}}}
执行结果
{Name: cluster_testState: Active}
该文章对您有帮助吗?