From commits-return-104912-archive-asf-public=cust-asf.ponee.io@lucene.apache.org Thu Nov 8 00:01:27 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6358F180649 for ; Thu, 8 Nov 2018 00:01:27 +0100 (CET) Received: (qmail 28614 invoked by uid 500); 7 Nov 2018 23:01:26 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 28605 invoked by uid 99); 7 Nov 2018 23:01:26 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Nov 2018 23:01:26 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 494B4E0041; Wed, 7 Nov 2018 23:01:26 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gus@apache.org To: commits@lucene.apache.org Message-Id: <35712ae58da7429c99eed73e150024bf@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:branch_7x: SOLR-12938 - fix test case for handling of bogus collection names that was failing when HttpClusterStateProvider is used instead of ZkClusterStateProvider Date: Wed, 7 Nov 2018 23:01:26 +0000 (UTC) Repository: lucene-solr Updated Branches: refs/heads/branch_7x 5f51517a4 -> 3dc799171 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/3dc79917 Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/3dc79917 Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/3dc79917 Branch: refs/heads/branch_7x Commit: 3dc79917148e8753d4f5544b5604708143f92499 Parents: 5f51517 Author: Gus Heck Authored: Wed Nov 7 18:00:51 2018 -0500 Committer: Gus Heck Committed: Wed Nov 7 18:00:51 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/3dc79917/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/3dc79917/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, "