Solr API,用于获取分片的领导者/副本状态

编程入门 行业动态 更新时间:2024-10-25 08:19:45
本文介绍了Solr API,用于获取分片的领导者/副本状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Solr有一个Admin UI,我们可以在其中检查部署到Solr Cloud的每个集合.例如,我可以看到集合中是否存在切片/碎片,如下面的URL所述.

Solr has a Admin UI where we can check each and every Collections that were deployed to Solr Cloud. For example, I can see a Slice/Shard in a collection up or not as mentioned in the below URL.

出于安全原因,我们的生产环境无法提供对此Admin UI的访问权限.我需要提供一个API,以获取每个集合及其碎片和每个碎片副本的状态.我正在使用Solr API来做到这一点

Our production environment doesn't provide access to this Admin UI due to security reasons. I need to provide an API to get the status of each and every collection, and its shards and each shard's replica. I am using Solr APIs to do that

lucene.apache/solr/4_7_2 /solr-solrj/index.html

CloudSolrServer server = new CloudSolrServer(<zk quorum>); ZkStateReader reader = server.getZkStateReader(); Collection<Slice> slices = reader.getClusterState().getSlices(collection); Iterator<Slice> iter = slices.iterator(); while (iter.hasNext()) { Slice slice = iter.next(); System.out.println(slice.getName()); System.out.println(slice.getState()); }

上面的代码始终仅将shard的状态返回为Active,即使其副本显示在UI中.我假设这仅返回分片的状态,而不返回分片的领导者或副本的状态.

The above piece of code is always returning Active only as the state of shard, even its replica is showing down in the UI. I assume this returns only the state of a shard, not the state of shard's leader or replica.

如何通过Solr API获取副本状态?是否有为此的任何API? Solr Admin UI正在使用什么API获取分片的副本/领导者状态?

How can I get the replicas status through Solr APIs? is there any API for this? And what is the API being using by Solr Admin UI for getting shard's replicas/leader status?

谢谢

推荐答案

代码未查看副本状态.这是一个打印出副本状态的文件:

The code is not looking at replica status. Here is one that prints out replica status:

CloudSolrServer server = new CloudSolrServer(zknodesurlstring); server.setDefaultCollection("mycollection"); server.connect(); ZkStateReader reader = server.getZkStateReader(); Collection<Slice> slices = reader.getClusterState().getSlices("mycollection"); Iterator<Slice> iter = slices.iterator(); while (iter.hasNext()) { Slice slice = iter.next(); for(Replica replica:slice.getReplicas()) { System.out.println("replica state for " + replica.getStr("core") + " : "+ replica.getStr( "state" )); System.out.println(slice.getName()); System.out.println(slice.getState()); } }

更多推荐

Solr API,用于获取分片的领导者/副本状态

本文发布于:2023-11-28 15:43:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643006.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:副本   领导者   分片   状态   Solr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!