You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2018/11/12 11:55:33 UTC
[24/50] [abbrv] lucene-solr:jira/http2: SOLR-12938 - fix test case
for handling of bogus collection names that was failing when
HttpClusterStateProvider is used instead of ZkClusterStateProvider
SOLR-12938 - fix test case for handling of bogus collection names
that was failing when HttpClusterStateProvider is used instead of
ZkClusterStateProvider
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/53482e51
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/53482e51
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/53482e51
Branch: refs/heads/jira/http2
Commit: 53482e510c773fabd80fc0a5a0efa1f137f89def
Parents: 4794a16
Author: Gus Heck <gu...@apache.org>
Authored: Wed Nov 7 20:05:32 2018 -0500
Committer: Gus Heck <gu...@apache.org>
Committed: Wed Nov 7 20:05:32 2018 -0500
----------------------------------------------------------------------
.../apache/solr/handler/admin/ClusterStatus.java | 4 +++-
.../solrj/impl/HttpClusterStateProvider.java | 18 +++++++++++++-----
2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53482e51/solr/core/src/java/org/apache/solr/handler/admin/ClusterStatus.java
----------------------------------------------------------------------
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 4daae31..463c5b6 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;
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/53482e51/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java
----------------------------------------------------------------------
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 484eaad..bbab3aa 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, "