Apache Solr open-source search software
SOLR-4210: Fix it
Mark Robert Miller43f384e57f71
diff --git a/solr/cloud-dev/solrcloud-start.sh b/solr/cloud-dev/solrcloud-start.shindex b9e2ee2cf0d..082c0f684ef 100644--- a/solr/cloud-dev/solrcloud-start.sh+++ b/solr/cloud-dev/solrcloud-start.sh@@ -16,13 +16,15 @@ rm -f example/example.logant example dist+rm -r example/solr-webapp/*+unzip example/webapps/solr.war -d example/solr-webapp/webapp+cp -r -f example example2cp -r -f example example3cp -r -f example example4cp -r -f example example5cp -r -f example example6-unzip example/webapps/solr.war -d example/solr-webappjava -classpath "example/solr-webapp/webapp/WEB-INF/lib/*" org.apache.solr.cloud.ZkCLI -cmd bootstrap -zkhost 127.0.0.1:9983 -solrhome example/solr -runzk 8983cd examplediff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.javaindex 2724c539d4c..6226736559f 100644--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java@@ -405,8 +405,10 @@ public class SolrDispatchFilter implements Filterprivate String getRemotCoreUrl(CoreContainer cores, String collectionName) {ClusterState clusterState = cores.getZkController().getClusterState();Collection<Slice> slices = clusterState.getSlices(collectionName);-+ boolean byCoreName = false;if (slices == null) {+ // look by core name+ byCoreName = true;Set<String> collections = clusterState.getCollections();for (String collection : collections) {slices = new ArrayList<Slice>();@@ -417,7 +419,7 @@ public class SolrDispatchFilter implements Filterif (slices == null || slices.size() == 0) {return null;}-+Set<String> liveNodes = clusterState.getLiveNodes();Iterator<Slice> it = slices.iterator();while (it.hasNext()) {@@ -427,14 +429,19 @@ public class SolrDispatchFilter implements FilterZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps);if (liveNodes.contains(coreNodeProps.getNodeName())&& coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) {- String coreUrl = coreNodeProps.getCoreUrl();- if (coreUrl.endsWith("/")) {- coreUrl = coreUrl.substring(0, coreUrl.length() - 1);+ if (byCoreName && !collectionName.equals(coreNodeProps.getCoreName())) {+ // if it's by core name, make sure they match+ continue;}if (coreNodeProps.getBaseUrl().equals(cores.getZkController().getBaseUrl())) {// don't count a local core- return null;+ continue;}+ String coreUrl = coreNodeProps.getCoreUrl();+ if (coreUrl.endsWith("/")) {+ coreUrl = coreUrl.substring(0, coreUrl.length() - 1);+ }+return coreUrl;}}