Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

followup to SOLR-1255 ... previous commit caused compilation errors in test cases, this commit alters the methods added to SolrCore/RequestHandlers both to fix the compilation error and be more generally useful beyond just SOLR-1255

Chris M. Hostetter2d1dae005673
diff --git a/src/java/org/apache/solr/core/RequestHandlers.java b/src/java/org/apache/solr/core/RequestHandlers.java
index 7cb70f602af..a7c68a59179 100644
--- a/src/java/org/apache/solr/core/RequestHandlers.java
+++ b/src/java/org/apache/solr/core/RequestHandlers.java
@@ -74,11 +74,16 @@ final class RequestHandlers {
return handlers.get(normalize(handlerName));
}
- public SolrRequestHandler get(Class clazz) {
- for (SolrRequestHandler requestHandler : handlers.values()) {
- if(requestHandler.getClass() == clazz) return requestHandler;
+ /**
+ * @return a Map of all registered handlers of the specified type.
+ */
+ public Map<String,SolrRequestHandler> getAll(Class clazz) {
+ Map<String,SolrRequestHandler> result
+ = new HashMap<String,SolrRequestHandler>(7);
+ for (Map.Entry<String,SolrRequestHandler> e : handlers.entrySet()) {
+ if(clazz.isInstance(e.getValue())) result.put(e.getKey(), e.getValue());
}
- return null;
+ return result;
}
/**
diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java
index 9cbd0bb3987..24a3e17c8db 100644
--- a/src/java/org/apache/solr/core/SolrCore.java
+++ b/src/java/org/apache/solr/core/SolrCore.java
@@ -768,8 +768,11 @@ public final class SolrCore implements SolrInfoMBean {
return reqHandlers.get(handlerName);
}
- public SolrRequestHandler getRequestHandler(Class clazz) {
- return reqHandlers.get(clazz);
+ /**
+ * Returns an unmodifieable Map containing the registered handlers of the specified type.
+ */
+ public Map<String,SolrRequestHandler> getRequestHandlers(Class clazz) {
+ return reqHandlers.getAll(clazz);
}
/**
diff --git a/src/webapp/web/admin/index.jsp b/src/webapp/web/admin/index.jsp
index b8fec41e2af..aee676fe8e2 100644
--- a/src/webapp/web/admin/index.jsp
+++ b/src/webapp/web/admin/index.jsp
@@ -29,7 +29,7 @@
<%-- jsp:include page="header.jsp"/ --%>
<%-- do a verbatim include so we can use the local vars --%>
<%@include file="header.jsp" %>
-<%SolrRequestHandler replicationhandler = core.getRequestHandler(ReplicationHandler.class);%>
+<%boolean replicationhandler = !core.getRequestHandlers(ReplicationHandler.class).isEmpty();%>
<br clear="all">
<table>
@@ -45,7 +45,7 @@
[<a href="file/?file=<%=core.getConfigResource()%>">Config</a>]
<% } %>
[<a href="analysis.jsp?highlight=on">Analysis</a>]
- [<a href="schema.jsp">Schema Browser</a>] <%if(replicationhandler != null ){%>[<a href="replication/index.jsp">Replication</a>]<%}%>
+ [<a href="schema.jsp">Schema Browser</a>] <%if(replicationhandler){%>[<a href="replication/index.jsp">Replication</a>]<%}%>
<br>
[<a href="stats.jsp">Statistics</a>]
[<a href="registry.jsp">Info</a>]
diff --git a/src/webapp/web/admin/replication/header.jsp b/src/webapp/web/admin/replication/header.jsp
index d4eb6564d4a..47b59d75cd1 100644
--- a/src/webapp/web/admin/replication/header.jsp
+++ b/src/webapp/web/admin/replication/header.jsp
@@ -20,7 +20,8 @@
org.apache.solr.common.util.SimpleOrderedMap,
org.apache.solr.request.LocalSolrQueryRequest,
org.apache.solr.request.SolrQueryResponse,
- org.apache.solr.request.SolrRequestHandler"%>
+ org.apache.solr.request.SolrRequestHandler,
+ java.util.Map"%>
<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
<%
request.setCharacterEncoding("UTF-8");
@@ -55,11 +56,15 @@ public NamedList executeCommand(String command, SolrCore core, SolrRequestHandle
%>
<%
-final SolrRequestHandler rh = core.getRequestHandler(ReplicationHandler.class);
- if(rh == null){
+final Map<String,SolrRequestHandler> all = core.getRequestHandlers(ReplicationHandler.class);
+ if(all.isEmpty()){
response.sendError( 404, "No ReplicationHandler registered" );
return;
}
+
+// :HACK: we should be more deterministic if multiple instances
+final SolrRequestHandler rh = all.values().iterator().next();
+
NamedList namedlist = executeCommand("details",core,rh);
NamedList detailsMap = (NamedList)namedlist.get("details");
if(detailsMap != null)