mirror of https://github.com/apache/lucene.git
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
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@793088 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6fcc6ed152
commit
2d1dae0056
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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>]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue