zoukankan      html  css  js  c++  java
  • ElasticSearch(十四) Cluster Administration

    ClusterAdminClient clusterAdminClient = client.admin().cluster();

    Cluster Health

    ClusterHealthResponse healths = client.admin().cluster().prepareHealth().get(); 
    String clusterName = healths.getClusterName();              
    int numberOfDataNodes = healths.getNumberOfDataNodes();     
    int numberOfNodes = healths.getNumberOfNodes();             
    for (ClusterIndexHealth health : healths.getIndices().values()) { 
        String index = health.getIndex();                       
        int numberOfShards = health.getNumberOfShards();        
        int numberOfReplicas = health.getNumberOfReplicas();    
        ClusterHealthStatus status = health.getStatus();        
    }

    Wait for status

    You can use the cluster health API to wait for a specific status for the whole cluster or for a given index:

    client.admin().cluster().prepareHealth()            
            .setWaitForYellowStatus()                   
            .get();
    client.admin().cluster().prepareHealth("company")   
            .setWaitForGreenStatus()                    
            .get();
    
    client.admin().cluster().prepareHealth("employee")  
            .setWaitForGreenStatus()                    
            .setTimeout(TimeValue.timeValueSeconds(2))  
            .get();

    If the index does not have the expected status and you want to fail in that case, you need to explicitly interpret the result:

    ClusterHealthResponse response = client.admin().cluster().prepareHealth("company")
            .setWaitForGreenStatus()    
            .get();
    
    ClusterHealthStatus status = response.getIndices().get("company").getStatus();
    if (!status.equals(ClusterHealthStatus.GREEN)) {
        throw new RuntimeException("Index is in " + status + " state"); 
    }



  • 相关阅读:
    idea html,js修改不用重启进程
    opencv rtsp 人脸识别
    The system is running in low-graphics mode UB16
    阿里云ecs 增加虚拟网卡
    rtsp
    mysql5.7报err 1055错误 sql_mode=only_full_group_by
    python 生成requirements.txt
    Linux 保护文件 不给修改
    logback logback.xml常用配置详解(三) <filter>
    logback 常用配置详解(二) <appender>
  • 原文地址:https://www.cnblogs.com/xiaocandou/p/8127462.html
Copyright © 2011-2022 走看看