ES node client

Hi All,

Can anyone help me understand if there is method/way to check, if the node client has connection to cluster or not.
Or a method similar to get connectednodes() used for transport client.

The whole idea, is to check if there is way to understand the client object connection is still up/connected to cluster/node or not.

Regards,
Satyajit.

You might access http://your_node_ip:9200/_nodes/stats/os,process?pretty and will have statistics about how many nodes are connected to your cluster.

Every node will print information about the cluster it is connected to, so you might use the IP of any node in your cluster to check.

Okay, is there a way to call the same through Node client api??(Java)

Yes, you might use:

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();        
}

take a look at the docs here: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin-cluster.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.