From c408c5258e4bf9c2a0ee90212a0308e620e29eb6 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 24 Feb 2014 17:04:16 +0000 Subject: [PATCH] SOLR-5770: All attempts to match a SolrCore with it's state in clusterstate.json should be done with the CoreNodeName. git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1571349 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../src/java/org/apache/solr/cloud/ZkController.java | 10 +++++----- .../org/apache/solr/common/cloud/ClusterState.java | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 005d8c60082..ab3babafb6f 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -401,6 +401,9 @@ Bug Fixes * SOLR-5448: ShowFileRequestHandler treats everything as Directory, when in Cloud-Mode. (Erick Erickson, steffkes) +* SOLR-5770: All attempts to match a SolrCore with it's state in clusterstate.json + should be done with the CoreNodeName. (Steve Davids via Mark Miller) + Optimizations ---------------------- diff --git a/solr/core/src/java/org/apache/solr/cloud/ZkController.java b/solr/core/src/java/org/apache/solr/cloud/ZkController.java index a5b6b8ba753..debf0c080b8 100644 --- a/solr/core/src/java/org/apache/solr/cloud/ZkController.java +++ b/solr/core/src/java/org/apache/solr/cloud/ZkController.java @@ -1049,7 +1049,7 @@ public final class ZkController { final CloudDescriptor cloudDesc = desc.getCloudDescriptor(); - final String shardId = state.getShardId(getBaseUrl(), desc.getName()); + final String shardId = state.getShardId(getNodeName(), desc.getName()); if (shardId != null) { cloudDesc.setShardId(shardId); @@ -1256,13 +1256,13 @@ public final class ZkController { for (Replica replica : slice.getReplicas()) { // TODO: for really large clusters, we could 'index' on this - String baseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP); + String nodeName = replica.getStr(ZkStateReader.NODE_NAME_PROP); String core = replica.getStr(ZkStateReader.CORE_NAME_PROP); - String msgBaseUrl = getBaseUrl(); + String msgNodeName = getNodeName(); String msgCore = descriptor.getName(); - if (baseUrl.equals(msgBaseUrl) && core.equals(msgCore)) { + if (nodeName.equals(msgNodeName) && core.equals(msgCore)) { descriptor.getCloudDescriptor() .setCoreNodeName(replica.getName()); return; @@ -1282,7 +1282,7 @@ public final class ZkController { log.info("waiting to find shard id in clusterstate for " + cd.getName()); int retryCount = 320; while (retryCount-- > 0) { - final String shardId = zkStateReader.getClusterState().getShardId(getBaseUrl(), cd.getName()); + final String shardId = zkStateReader.getClusterState().getShardId(getNodeName(), cd.getName()); if (shardId != null) { cd.getCloudDescriptor().setShardId(shardId); return; diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java index 52f7bda768a..0c8549d200d 100644 --- a/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java +++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ClusterState.java @@ -199,15 +199,15 @@ public class ClusterState implements JSONWriter.Writable { return Collections.unmodifiableSet(liveNodes); } - public String getShardId(String baseUrl, String coreName) { + public String getShardId(String nodeName, String coreName) { // System.out.println("###### getShardId(" + baseUrl + "," + coreName + ") in " + collectionStates); for (DocCollection coll : collectionStates.values()) { for (Slice slice : coll.getSlices()) { for (Replica replica : slice.getReplicas()) { // TODO: for really large clusters, we could 'index' on this - String rbaseUrl = replica.getStr(ZkStateReader.BASE_URL_PROP); + String rnodeName = replica.getStr(ZkStateReader.NODE_NAME_PROP); String rcore = replica.getStr(ZkStateReader.CORE_NAME_PROP); - if (baseUrl.equals(rbaseUrl) && coreName.equals(rcore)) { + if (nodeName.equals(rnodeName) && coreName.equals(rcore)) { return slice.getName(); } }