From 43f384e57f71338be30bae2cf2025c7f28565745 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 3 Mar 2013 01:29:48 +0000 Subject: [PATCH] SOLR-4210: Fix it git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1451987 13f79535-47bb-0310-9956-ffa450edef68 --- solr/cloud-dev/solrcloud-start.sh | 4 +++- .../solr/servlet/SolrDispatchFilter.java | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/solr/cloud-dev/solrcloud-start.sh b/solr/cloud-dev/solrcloud-start.sh index 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.log ant example dist +rm -r example/solr-webapp/* +unzip example/webapps/solr.war -d example/solr-webapp/webapp + cp -r -f example example2 cp -r -f example example3 cp -r -f example example4 cp -r -f example example5 cp -r -f example example6 -unzip example/webapps/solr.war -d example/solr-webapp java -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 8983 cd example diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java index 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 Filter private String getRemotCoreUrl(CoreContainer cores, String collectionName) { ClusterState clusterState = cores.getZkController().getClusterState(); Collection slices = clusterState.getSlices(collectionName); - + boolean byCoreName = false; if (slices == null) { + // look by core name + byCoreName = true; Set collections = clusterState.getCollections(); for (String collection : collections) { slices = new ArrayList(); @@ -417,7 +419,7 @@ public class SolrDispatchFilter implements Filter if (slices == null || slices.size() == 0) { return null; } - + Set liveNodes = clusterState.getLiveNodes(); Iterator it = slices.iterator(); while (it.hasNext()) { @@ -427,14 +429,19 @@ public class SolrDispatchFilter implements Filter ZkCoreNodeProps coreNodeProps = new ZkCoreNodeProps(nodeProps); if (liveNodes.contains(coreNodeProps.getNodeName()) && coreNodeProps.getState().equals(ZkStateReader.ACTIVE)) { + 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 + continue; + } String coreUrl = coreNodeProps.getCoreUrl(); if (coreUrl.endsWith("/")) { coreUrl = coreUrl.substring(0, coreUrl.length() - 1); } - if (coreNodeProps.getBaseUrl().equals(cores.getZkController().getBaseUrl())) { - // don't count a local core - return null; - } + return coreUrl; } }