Is there a programmatic way to distinguish between a single-node Elasticsearch cluster and a two-node cluster
in which one of the clusters is temporarily unavailable.
If somebody can provide some pointers, that would be of great help
Is there a programmatic way to distinguish between a single-node Elasticsearch cluster and a two-node cluster
in which one of the clusters is temporarily unavailable.
If somebody can provide some pointers, that would be of great help
Interesting question... when a data node of a multi-node cluster is not running, I don't think you can find that missing node programmatically. Through a query, you may find that a shard (in a missing node) is missing from the index that you are querying for information.
Let's assume, the cluster is up and running, you have two options (from what I know)
through the REST interface, you can do http://host:port/_cat/nodes?v to get a list of nodes running in the cluster, under the node.role and master columns, you can have an idea about the cluster
through Java API TransportClient, once you make a connection to a cluster, you can call connectedNodes() to find out how many nodes this transport client is connected to.
If sniff enabled is off, this transport client is connected to only one (the one you specify initially)
If sniff enabled is on, this transport client is connected to one or more depending on how many "data nodes" in the cluster. If there is one and its name is the same as the one you specify initially, you may have a single node cluster. If you have one and its name is not the same or you have more than one, you may have a multi-node cluster.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.