# Elastic search dynamic number of replicas from Java API

**URL:** <https://discuss.elastic.co/t/elastic-search-dynamic-number-of-replicas-from-java-api/18563>\
**Category:** Elasticsearch\
**Created:** [July 9, 2014, 9:57pm UTC](https://discuss.elastic.co/t/elastic-search-dynamic-number-of-replicas-from-java-api/18563 "2014-07-09T21:57:53Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 25, 2014, 9:49am UTC](https://discuss.elastic.co/t/elastic-search-dynamic-number-of-replicas-from-java-api/18563/21 "2014-08-25T09:49:02Z")

</div>

An example of a server-side cluster state listener is in JDBC river plugin

[https://github.com/jprante/elasticsearch-river-jdbc/blob/master/src/main/java/org/xbib/elasticsearch/action/river/jdbc/state/RiverStateService.java](https://github.com/jprante/elasticsearch-river-jdbc/blob/master/src/main/java/org/xbib/elasticsearch/action/river/jdbc/state/RiverStateService.java)

I use it to augment the cluster state with river state info.

Jörg

On Fri, Aug 22, 2014 at 10:08 AM, 'Sandeep Ramesh Khanzode' via  
elasticsearch [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com) wrote:

> Hi Jorg,
> 
> Can you please give a server-side or client-side example of using  
> CLusterStateListener?  
> Do I have to use a plugin. if so, which module do I register/override?  
> If not, do I have to use a Node Client (not a TransportClient), and  
> retrieve the ClusterService somehow and then register?
> 
> Thanks  
> Sandeep
> 
> On Thursday, 10 July 2014 22:25:51 UTC+5:30, Jörg Prante wrote:
> 
> > On the client side, you can't use cluster state listener, it is for nodes  
> > that have access to a local copy of the master cluster state. Clients must  
> > execute an action to ask for cluster state, and with the current transport  
> > request/response cycle, they must poll for new events ...
> > 
> > Jörg
> > 
> > On Thu, Jul 10, 2014 at 6:38 PM, Ivan Brusic [iv...@brusic.com](mailto:iv...@brusic.com) wrote:
> > 
> > > Jörg, have you actually implemented your own ClusterStateListener? I  
> > > never had much success. Tried using that interface or even  
> > > PublishClusterStateAction.NewClusterStateListener, but either I could  
> > > not configure successfully the module (the former) or received no events  
> > > (the latter). Implemented on the client side, not as a plugin.
> > > 
> > > Cheers,
> > > 
> > > Ivan
> > > 
> > > On Wed, Jul 9, 2014 at 4:21 PM, [joerg...@gmail.com](mailto:joerg...@gmail.com) [joerg...@gmail.com](mailto:joerg...@gmail.com)  
> > > wrote:
> > > 
> > > > 1. Yes. Use org.elasticsearch.cluster.ClusterStateListener
> > > > 
> > > > --  
> > > > You received this message because you are subscribed to the Google  
> > > > Groups "elasticsearch" group.  
> > > > To unsubscribe from this group and stop receiving emails from it, send  
> > > > an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/CALY%3DcQBB%3DW\_qG9E7i-  
> > > > sEc6HZeMskxKgbqzaKgqzSQ26sjgT5%2BQ%[40mail.gmail.com](http://40mail.gmail.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBB%3DW\_qG9E7i-sEc6HZeMskxKgbqzaKgqzSQ26sjgT5%2BQ%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQBB%3DW_qG9E7i-sEc6HZeMskxKgbqzaKgqzSQ26sjgT5%2BQ%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/35f6b64e-3787-4891-a3a8-518dfd7638e3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/35f6b64e-3787-4891-a3a8-518dfd7638e3%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/35f6b64e-3787-4891-a3a8-518dfd7638e3%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/35f6b64e-3787-4891-a3a8-518dfd7638e3%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEcFAp443apYZfesyF7%2Bkj-KPMiimObDQ5wOeFuQiUHpw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEcFAp443apYZfesyF7%2Bkj-KPMiimObDQ5wOeFuQiUHpw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 1:06am UTC](https://discuss.elastic.co/t/elastic-search-dynamic-number-of-replicas-from-java-api/18563/22 "2017-07-06T01:06:43Z")

</div>



[Previous page](https://discuss.elastic.co/t/elastic-search-dynamic-number-of-replicas-from-java-api/18563.md?page=1)
