diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java index 4daae31d800..463c5b60dbd 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java @@ -112,7 +112,9 @@ public class ClusterStatus { DocCollection clusterStateCollection = entry.getValue(); if (clusterStateCollection == null) { if (collection != null) { - throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found"); + SolrException solrException = new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Collection: " + name + " not found"); + solrException.setMetadata("CLUSTERSTATUS","NOT_FOUND"); + throw solrException; } else { //collection might have got deleted at the same time continue; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java index 484eaada2b9..bbab3aa3cc9 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java @@ -95,7 +95,13 @@ public class HttpClusterStateProvider implements ClusterStateProvider { withHttpClient(httpClient).build()) { ClusterState cs = fetchClusterState(client, collection, null); return cs.getCollectionRef(collection); - } catch (SolrServerException | RemoteSolrException | IOException e) { + } 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) { @@ -257,9 +263,9 @@ public class HttpClusterStateProvider implements ClusterStateProvider { 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); + // not possible! (we passed in null for collection so it can't be an alias) + throw new RuntimeException("null should never cause NotACollectionException in " + + "fetchClusterState() Please report this as a bug!"); } } throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes +". However, " @@ -282,7 +288,9 @@ public class HttpClusterStateProvider implements ClusterStateProvider { log.warn("Attempt to fetch cluster state from " + Utils.getBaseUrlForNodeName(nodeName, urlScheme) + " failed.", e); } catch (NotACollectionException e) { - // should be an an alias, don't care + // not possible! (we passed in null for collection so it can't be an alias) + throw new RuntimeException("null should never cause NotACollectionException in " + + "fetchClusterState() Please report this as a bug!"); } } throw new RuntimeException("Tried fetching cluster state using the node names we knew of, i.e. " + liveNodes + ". However, "