List of usage examples for org.apache.solr.cloud ZkController getClusterState
public ClusterState getClusterState()
From source file:edu.harvard.gis.hhypermap.bop.solrplugins.DateShardRoutingSearchHandler.java
License:Apache License
List<Slice> getOrderedSlices(ZkController zkController, String collection) { DocCollection coll = zkController.getClusterState().getCollection(collection); //TODO cache sorted for same coll ? List<Slice> slices = new ArrayList<>(coll.getSlices()); slices.removeIf((s) -> s.getName().equals(SHARD_RT_NAME)); // assumption: shard names sort in date order slices.sort(Comparator.comparing(Slice::getName)); return slices; }
From source file:org.tallison.solr.search.concordance.KeywordCooccurRankHandler.java
License:Apache License
@SuppressWarnings("unchecked") private void doZooQuery(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); String field = getField(params); CooccurConfig config = configureParams(field, params); boolean debug = params.getBool("debug", false); NamedList nlDebug = new SimpleOrderedMap(); if (debug)// www . j a va 2 s.c o m rsp.add("DEBUG", nlDebug); ZkController zoo = req.getCore().getCoreDescriptor().getCoreContainer().getZkController(); Set<String> nodes = zoo.getClusterState().getLiveNodes(); List<String> shards = new ArrayList<String>(nodes.size()); String thisUrl = req.getCore().getCoreDescriptor().getCoreContainer().getZkController().getBaseUrl(); for (String node : nodes) { String shard = node.replace("_", "/"); if (thisUrl.contains(shard)) continue; shard += "/" + req.getCore().getName(); shards.add(shard); } System.out.println("SHARDS SIZE: " + shards.size()); RequestThreads<CooccurConfig> threads = initRequestPump(shards, req); Results results = new Results(threads.getMetadata()); /* //skip local NamedList nl = doLocalSearch(req); for (int i = 0; i < nl.size(); i++) { System.out.println("RETURNED FROM SERVER: " + "LOCAL" + " : " + nl.getName(i) + " ; " + nl.getVal(i)); } results.add(nl, "local");*/ results = spinWait(threads, results); rsp.add(NODE, results.toNamedList()); }
From source file:org.tallison.solr.search.concordance.SolrConcordanceBase.java
License:Apache License
public static List<String> getShards(SolrQueryRequest req, boolean bIncludeLocal) { ZkController zoo = req.getCore().getCoreDescriptor().getCoreContainer().getZkController(); //TODO: non-replica's Set<String> nodes = zoo.getClusterState().getLiveNodes(); List<String> shards = new ArrayList<String>(nodes.size()); String thisUrl = req.getCore().getCoreDescriptor().getCoreContainer().getZkController().getBaseUrl(); for (String node : nodes) { String shard = node.replace("_", "/"); if (!bIncludeLocal && thisUrl.contains(shard)) continue; shard += "/" + req.getCore().getName(); shards.add(shard);/*w w w .j av a 2 s . c om*/ } return shards; }