Skip to content

armgit / solr

Public Imported from GitHub
0

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.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<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 Filter
if (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 Filter
ZkCoreNodeProps 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;
}
}