What error do you see?
Also, what are you trying to do? If you are trying to get the cluster's
state from an outside service, and not in a Solr plugin, maybe you should
use CloudSolrClient instead:
```
var client = new CloudSolrClient
.builder(Arrays.asList("zkHost1:port1,zkHost2:port2,..."),
Optional.empty()).build();
```
And then use either the `ClusterStateProvider` from
`client.getClusterStateProvider()` or use the
`CollectionAdminRequest.clusterStatus` request.
On Thu, Jul 8, 2021, 2:01 PM Reej M <[email protected]> wrote:
> Hi All,
>
> We are upgrading from solr 4 to solr 8. Updated the solr server to
> solr8.8.2, solrj8.8.2.
> We are trying to resume the code and in one place where we are trying to
> get a collection from clusterstate. Code used is as below
>
> Clusterstate clusterState = null;
> For(SearchSolrZookeeper zk:livezks){
> SolrZkClient zkClient = null;
> ZKStateReader stateReader = null;
> Try{
> Zkclient = new SolrZkClient(zk.getUrl(), 3000);
> stateReader = new ZKStateReader(Zkclient);
> stateReader.createClusterStateWatchersAndUpdate();
> clusterState = stateReader.getClusterState();
> Connected = true;
> Exception = null;
> break;
> }
> Catch(){
> }
> Finally{
> State reader.close();
> Zkclient.close();
> }
>
> If(clusterstate!=null){
> Doccollection dc = clusterstate.getCollection(“INVOICE”);
> //here dc is null
> }
> }
>
>
> Tried using getcollectionornull - returns null
> Getcollectionornull(collection name, true) — returns null
>
> When I debug I can see clusterstate has below values in it
>
> Znodeversion:0
> Live node:[192.123.33.44:3883_Solr, 192.123.33.44:9883
> _Solr,192.123.33.45:3883_Solr,192.123.33.45:3883_Solr]
> Collections:{ORDER=LazyCollectionRef(ORDER), INVOICE=
> LazyCollectionRef(INVOICE), PAYMENT= LazyCollectionRef(PAYMENT),etc..}
>
> From the document collection we get the slices and iterate each replica to
> show the cores in a admin page. But this page worked fine with the code in
> solr4, now with solr8 it throws error. Kindly help.
>
> Regards
> Reej