@Override public ClusterState.CollectionRef getState(String collection) { ClusterState clusterState = zkStateReader.getClusterState(); if (clusterState != null) { return clusterState.getCollectionRef(collection); } else { return null; } } public ZkStateReader getZkStateReader(){
ClusterState.CollectionRef ref = clusterState.getCollectionRef(collection); if (ref == null || legacyCollectionStates.containsKey(collection)) {
ClusterState.CollectionRef ref = clusterState.getCollectionRef(collection); if (ref == null) {
@Override public CollectionRef getState(String collection) { for (String nodeName: liveNodes) { try (HttpSolrClient client = new HttpSolrClient.Builder(). withBaseSolrUrl(Utils.getBaseUrlForNodeName(nodeName, urlScheme)). withHttpClient(httpClient).build()) { ClusterState cs = fetchClusterState(client, collection, null); return cs.getCollectionRef(collection); } catch (SolrServerException | IOException e) { log.warn("Attempt to fetch cluster state from " + Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e); } catch (RemoteSolrException e) { if ("NOT_FOUND".equals(e.getMetadata("CLUSTERSTATUS"))) { return null; } log.warn("Attempt to fetch cluster state from " + Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e); } catch (NotACollectionException e) { // Cluster state for the given collection was not found, could be an alias. // Lets fetch/update our aliases: getAliases(true); return null; } } throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes +". However, " + "succeeded in obtaining the cluster state from none of them." + "If you think your Solr cluster is up and is accessible," + " you could try re-creating a new CloudSolrClient using working" + " solrUrl(s) or zkHost(s)."); }