Detect ES cluster node join/leave

Hi,

We are using a elastic search cluster alongside our application
cluster, and would like to be able to detect nodes joining/leaving
(some sort of callback) so we can then do a index health check for
availability. We are using 0.14.3 at the moment.

Right now we just do a index health check every 5-10 seconds, which is
not optimal I think.

I looked through the source and was able to find ClusterStateListener,
but this doesn't seem to be exposed via the Java API.

I like to know if this could be on the works (feature request) or
already exists somewhere that we can make use of?

Thanks for a great search system!

You can hack into it a bit, but its not exposed as an API. Doing an index status api is suboptimal, its much better to use the cluster health / cluster state API.

You can get the ClusterService if you cast the Node you get to InternalNode and get it from the Guice injector:

((InternalNode) node).injector().getInstance(ClusterService.class), and then register your listener there. Note, your callback should not do anything blocking or something that takes time on this calling thread!.

-shay.banon
On Tuesday, February 1, 2011 at 10:16 AM, cwho80 wrote:

Hi,

We are using a Elasticsearch cluster alongside our application
cluster, and would like to be able to detect nodes joining/leaving
(some sort of callback) so we can then do a index health check for
availability. We are using 0.14.3 at the moment.

Right now we just do a index health check every 5-10 seconds, which is
not optimal I think.

I looked through the source and was able to find ClusterStateListener,
but this doesn't seem to be exposed via the Java API.

I like to know if this could be on the works (feature request) or
already exists somewhere that we can make use of?

Thanks for a great search system!