Hi all, I am using the code below to get the replica state:
ZkStateReader reader = cloudSolrClient.getZkStateReader(); ClusterState slices22 = reader.getClusterState(); DocCollection slices = reader.getClusterState().getCollection(collection); Iterator<Slice> iter = slices.iterator(); while (iter.hasNext()) { Slice slice = iter.next(); for(Replica replica:slice.getReplicas()) { System.out.println(replica.getStr( "state" )); } } question is I can manage to get the correct replica state if I start and stop solr using command line. how if solr failure or crashed, how can I get the correct replica state? regards, yy On Mon, Jun 11, 2018 at 4:28 AM, Erick Erickson <erickerick...@gmail.com> wrote: > You have to cross check with live_nodes. This is especially true if > you stop Solr un-gracefully, i.e. "kill -9" or the like (which is > _not_ recommended). > > During graceful shutdown, the Solr instance has a chance to change all > replica's states correctly. There's no chance to do that if you kill > Solr though. At that point, Zookeeper will eventually tryto contact > the Solr node and, if the Solr node is unavailable, remove it's > ephemeral node from the live_nodes znode. It does _not_, however, > change any replica's states that are hosted on that Solr instance, > thus you must check live_nodes too. > > Or shut Solr down gracefully. This may require that you lengthen > "SOLR_STOP_WAIT" in solr.in.sh (Solr 6.3). If your version is earlier > than 6.3, you'll have to modify your local copy of bin/solr. > > Best, > Erick. > > On Sun, Jun 10, 2018 at 8:11 AM, yy lee <solryy...@gmail.com> wrote: > > hi all, > > > > I am try to get the replica status from solrj, > > but I found out that the status I get is not correct. > > I still get the state of the replica as "active", although I have stop my > > solr. > > Is there any way I can get the correct replica state from solrj? > > > > regards, > > yy >