全部产品
Search
文档中心

:获取集群信息

更新时间:Apr 12, 2018

方法说明

通过指定的集群ID来获取集群信息(getCluster)。

参数说明

参数 类型 说明
clusterId String 集群ID

返回值说明

  • 成功后返回一个GetClusterResponse实例,可以通过这个实例的 getCluster()方法,拿到Cluster对象。

  • 如果失败,抛出异常: ClientException。

代码示例

  1. try{
  2. GetClusterResponse response = client.getCluster("cls-6vilcufsfd31i010");
  3. //成功
  4. Cluster cluster = response.getCluster();
  5. String state = cluster.getState();
  6. //assertEquals('Active', state); //集群状态。仅支持"Active"和"Deleting"。
  7. }catch(ClientException e){
  8. e.printStackTrace();
  9. //失败
  10. }