ElasticSearch High Level REST API【6】獲取集群信息


 ElasticSearch 可以通過info()方法檢索群集信息:

public void info(){
       RestHighLevelClient client = elasticClient.getRestHighLevelClient();
       MainResponse response = null;
       try {
           response = client.info(RequestOptions.DEFAULT);
       } catch (IOException e) {
           e.printStackTrace();
       }
       //返回集群的各種信息
       ClusterName clusterName = response.getClusterName(); //集群名稱
       String clusterUuid = response.getClusterUuid(); //群集的唯一標識符
       String nodeName = response.getNodeName(); //已執行請求的節點的名稱
       Version version = response.getVersion(); //已執行請求的節點的版本
       Build build = response.getBuild(); //已執行請求的節點的構建信息
   }

Ping API

通過使用ping()方法可以檢查集群是否連接成功,並返回一個布爾值:

boolean response = client.ping(RequestOptions.DEFAULT);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM