If you¹re using SolrJ, CloudSolrServer exposes the information you need
directly, although you¹d have to poll it for changes.
Specifically, this code path will get you a snapshot of the clusterstate:
http://lucene.apache.org/solr/4_5_0/solr-solrj/org/apache/solr/client/solrj
/impl/CloudSolrServer.html#getZkStateReader()

http://lucene.apache.org/solr/4_5_0/solr-solrj/org/apache/solr/common/cloud
/ZkStateReader.html#updateClusterState(boolean)

http://lucene.apache.org/solr/4_5_0/solr-solrj/org/apache/solr/common/cloud
/ZkStateReader.html#getClusterState()


If you¹re not using SolrJ, or don¹t want to poll, you really only need a
zookeeper client. As Shawn Heisey suggests, you put a watch on the
clusterstate.json, and write something to determine if the change was
relevant to you. 

A few months ago I wanted to do analysis of changes in my SolrCloud
cluster, so I threw together something using the Curator library to set
watches on clusterstate.json and commit the new version to a local git
repo whenever it changed.
(https://github.com/randomstatistic/git_zk_monitor) The hardest part
turned out to be learning about the Zookeeper watch semantics, but you
could use any client you like.



On 7/3/14, 9:23 AM, "Shawn Heisey" <s...@elyograg.org> wrote:

>On 7/3/2014 7:49 AM, Ugo Matrangolo wrote:
>> I would like to be informed as soon as a cluster event happens like a
>>node
>> dropping and/or starting a recovery process.
>> 
>> What is the best way (if any) to listening on SolrCloud events ?
>
>I don't know how it's done, but if you are using SolrJ and
>CloudSolrServer, you have access to the zookeeper client.  With the
>zookeeper client, you can put a watcher on various parts of the
>zookeeper database, which should fire whenever there is a change.
>
>Thanks,
>Shawn
>

Reply via email to