Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

hossman

Dude .... you've got to at least run "ant test" before you commit ...
TestWriterPerf can't even compile now.

This breaks anyone that was explicitly passing null to the existing
getRequestHandler(String) method (like TestWriterPerf) ... but besides
that it also seems really weird to have a method that takes in a class and
arbitrarily returns the first instance of that class found -- especially
since it's iterating over the values in a Map, so if someone has multiple
instances of a handler they could get a different one each time this
method is called.

making a method that returns *all* the handlers of that type seems like a
better general feature for SolrCore/RequestHandlers, and then in this
specific use case of the replication JSP can be as arbitrary as it wants.


i've got a fix i'll commit as soon as my tests finish...



: Date: Fri, 10 Jul 2009 10:04:29 -0000
: From: [hidden email]
: Reply-To: [hidden email]
: To: [hidden email]
: Subject: svn commit: r792861 - in /lucene/solr/trunk/src:
:     java/org/apache/solr/core/RequestHandlers.java
:     java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp
:     webapp/web/admin/replication/header.jsp
:
: Author: noble
: Date: Fri Jul 10 10:04:29 2009
: New Revision: 792861
:
: URL: http://svn.apache.org/viewvc?rev=792861&view=rev
: Log:
: SOLR-1255 An attempt to visit the replication admin page when its not a defined handler should display an approp message
:
: Modified:
:     lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
:     lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
:     lucene/solr/trunk/src/webapp/web/admin/index.jsp
:     lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
:
: Modified: lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
: URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=792861&r1=792860&r2=792861&view=diff
: ==============================================================================
: --- lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java (original)
: +++ lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java Fri Jul 10 10:04:29 2009
: @@ -66,7 +66,7 @@
:    public RequestHandlers(SolrCore core) {
:        this.core = core;
:    }
: -  
: +
:    /**
:     * @return the RequestHandler registered at the given name
:     */
: @@ -74,6 +74,13 @@
:      return handlers.get(normalize(handlerName));
:    }
:  
: +  public SolrRequestHandler get(Class clazz) {
: +    for (SolrRequestHandler requestHandler : handlers.values()) {
: +      if(requestHandler.getClass() == clazz) return requestHandler;
: +    }
: +    return null;
: +  }
: +
:    /**
:     * Handlers must be initialized before calling this function.  As soon as this is
:     * called, the handler can immediately accept requests.
:
: Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
: URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=792861&r1=792860&r2=792861&view=diff
: ==============================================================================
: --- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
: +++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri Jul 10 10:04:29 2009
: @@ -767,6 +767,10 @@
:    public SolrRequestHandler getRequestHandler(String handlerName) {
:      return reqHandlers.get(handlerName);
:    }
: +
: +  public SolrRequestHandler getRequestHandler(Class clazz) {
: +    return reqHandlers.get(clazz);
: +  }
:    
:    /**
:     * Returns an unmodifieable Map containing the registered handlers
:
: Modified: lucene/solr/trunk/src/webapp/web/admin/index.jsp
: URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/index.jsp?rev=792861&r1=792860&r2=792861&view=diff
: ==============================================================================
: --- lucene/solr/trunk/src/webapp/web/admin/index.jsp (original)
: +++ lucene/solr/trunk/src/webapp/web/admin/index.jsp Fri Jul 10 10:04:29 2009
: @@ -24,11 +24,12 @@
:  <%@ page import="java.util.List" %>
:  <%@ page import="java.util.Collection" %>
:  <%@ page import="org.apache.solr.request.SolrRequestHandler"%>
: +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
:  
:  <%-- jsp:include page="header.jsp"/ --%>
:  <%-- do a verbatim include so we can use the local vars --%>
:  <%@include file="header.jsp" %>
: -<%SolrRequestHandler replicationhandler = core.getRequestHandler("/replication");%>
: +<%SolrRequestHandler replicationhandler = core.getRequestHandler(ReplicationHandler.class);%>
:  <br clear="all">
:  <table>
:  
:
: Modified: lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
: URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp?rev=792861&r1=792860&r2=792861&view=diff
: ==============================================================================
: --- lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp (original)
: +++ lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp Fri Jul 10 10:04:29 2009
: @@ -21,14 +21,14 @@
:   org.apache.solr.request.LocalSolrQueryRequest,
:   org.apache.solr.request.SolrQueryResponse,
:   org.apache.solr.request.SolrRequestHandler"%>
: -
: -<html>
: -<head>
: -
: +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
:  <%
:  request.setCharacterEncoding("UTF-8");
:  %>
:  
: +<html>
: +<head>
: +
:  <%@include file="../_info.jsp" %>
:  
:  <script>
: @@ -55,7 +55,11 @@
:  %>
:  
:  <%
: -final SolrRequestHandler rh = core.getRequestHandler("/replication");
: +final SolrRequestHandler rh = core.getRequestHandler(ReplicationHandler.class);
: +  if(rh == null){
: +    response.sendError( 404, "No ReplicationHandler registered" );
: +    return;
: +  }
:  NamedList namedlist = executeCommand("details",core,rh);
:  NamedList detailsMap = (NamedList)namedlist.get("details");
:  if(detailsMap != null)
:
:



-Hoss

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

Noble Paul നോബിള്‍  नोब्ळ्-2
mea culpa,

It looked like a trivial fix . I did an only ant example .

Thanks for catching this

On Sat, Jul 11, 2009 at 12:36 AM, Chris
Hostetter<[hidden email]> wrote:

>
> Dude .... you've got to at least run "ant test" before you commit ...
> TestWriterPerf can't even compile now.
>
> This breaks anyone that was explicitly passing null to the existing
> getRequestHandler(String) method (like TestWriterPerf) ... but besides
> that it also seems really weird to have a method that takes in a class and
> arbitrarily returns the first instance of that class found -- especially
> since it's iterating over the values in a Map, so if someone has multiple
> instances of a handler they could get a different one each time this
> method is called.
>
> making a method that returns *all* the handlers of that type seems like a
> better general feature for SolrCore/RequestHandlers, and then in this
> specific use case of the replication JSP can be as arbitrary as it wants.
>
>
> i've got a fix i'll commit as soon as my tests finish...
>
>
>
> : Date: Fri, 10 Jul 2009 10:04:29 -0000
> : From: [hidden email]
> : Reply-To: [hidden email]
> : To: [hidden email]
> : Subject: svn commit: r792861 - in /lucene/solr/trunk/src:
> :     java/org/apache/solr/core/RequestHandlers.java
> :     java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp
> :     webapp/web/admin/replication/header.jsp
> :
> : Author: noble
> : Date: Fri Jul 10 10:04:29 2009
> : New Revision: 792861
> :
> : URL: http://svn.apache.org/viewvc?rev=792861&view=rev
> : Log:
> : SOLR-1255 An attempt to visit the replication admin page when its not a defined handler should display an approp message
> :
> : Modified:
> :     lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
> :     lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
> :     lucene/solr/trunk/src/webapp/web/admin/index.jsp
> :     lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
> :
> : Modified: lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=792861&r1=792860&r2=792861&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java (original)
> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java Fri Jul 10 10:04:29 2009
> : @@ -66,7 +66,7 @@
> :    public RequestHandlers(SolrCore core) {
> :        this.core = core;
> :    }
> : -
> : +
> :    /**
> :     * @return the RequestHandler registered at the given name
> :     */
> : @@ -74,6 +74,13 @@
> :      return handlers.get(normalize(handlerName));
> :    }
> :
> : +  public SolrRequestHandler get(Class clazz) {
> : +    for (SolrRequestHandler requestHandler : handlers.values()) {
> : +      if(requestHandler.getClass() == clazz) return requestHandler;
> : +    }
> : +    return null;
> : +  }
> : +
> :    /**
> :     * Handlers must be initialized before calling this function.  As soon as this is
> :     * called, the handler can immediately accept requests.
> :
> : Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=792861&r1=792860&r2=792861&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java (original)
> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri Jul 10 10:04:29 2009
> : @@ -767,6 +767,10 @@
> :    public SolrRequestHandler getRequestHandler(String handlerName) {
> :      return reqHandlers.get(handlerName);
> :    }
> : +
> : +  public SolrRequestHandler getRequestHandler(Class clazz) {
> : +    return reqHandlers.get(clazz);
> : +  }
> :
> :    /**
> :     * Returns an unmodifieable Map containing the registered handlers
> :
> : Modified: lucene/solr/trunk/src/webapp/web/admin/index.jsp
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/index.jsp?rev=792861&r1=792860&r2=792861&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/webapp/web/admin/index.jsp (original)
> : +++ lucene/solr/trunk/src/webapp/web/admin/index.jsp Fri Jul 10 10:04:29 2009
> : @@ -24,11 +24,12 @@
> :  <%@ page import="java.util.List" %>
> :  <%@ page import="java.util.Collection" %>
> :  <%@ page import="org.apache.solr.request.SolrRequestHandler"%>
> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
> :
> :  <%-- jsp:include page="header.jsp"/ --%>
> :  <%-- do a verbatim include so we can use the local vars --%>
> :  <%@include file="header.jsp" %>
> : -<%SolrRequestHandler replicationhandler = core.getRequestHandler("/replication");%>
> : +<%SolrRequestHandler replicationhandler = core.getRequestHandler(ReplicationHandler.class);%>
> :  <br clear="all">
> :  <table>
> :
> :
> : Modified: lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp?rev=792861&r1=792860&r2=792861&view=diff
> : ==============================================================================
> : --- lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp (original)
> : +++ lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp Fri Jul 10 10:04:29 2009
> : @@ -21,14 +21,14 @@
> :                                org.apache.solr.request.LocalSolrQueryRequest,
> :                                org.apache.solr.request.SolrQueryResponse,
> :                                org.apache.solr.request.SolrRequestHandler"%>
> : -
> : -<html>
> : -<head>
> : -
> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
> :  <%
> :  request.setCharacterEncoding("UTF-8");
> :  %>
> :
> : +<html>
> : +<head>
> : +
> :  <%@include file="../_info.jsp" %>
> :
> :  <script>
> : @@ -55,7 +55,11 @@
> :  %>
> :
> :  <%
> : -final SolrRequestHandler rh = core.getRequestHandler("/replication");
> : +final SolrRequestHandler rh = core.getRequestHandler(ReplicationHandler.class);
> : +  if(rh == null){
> : +    response.sendError( 404, "No ReplicationHandler registered" );
> : +    return;
> : +  }
> :  NamedList namedlist = executeCommand("details",core,rh);
> :  NamedList detailsMap = (NamedList)namedlist.get("details");
> :  if(detailsMap != null)
> :
> :
>
>
>
> -Hoss
>
>



--
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

Erik Hatcher
In reply to this post by hossman
Also, may want to use instanceof instead of == for class comparison,  
in case subclasses are used.

        Erik

On Jul 10, 2009, at 3:06 PM, Chris Hostetter wrote:

>
> Dude .... you've got to at least run "ant test" before you commit ...
> TestWriterPerf can't even compile now.
>
> This breaks anyone that was explicitly passing null to the existing
> getRequestHandler(String) method (like TestWriterPerf) ... but besides
> that it also seems really weird to have a method that takes in a  
> class and
> arbitrarily returns the first instance of that class found --  
> especially
> since it's iterating over the values in a Map, so if someone has  
> multiple
> instances of a handler they could get a different one each time this
> method is called.
>
> making a method that returns *all* the handlers of that type seems  
> like a
> better general feature for SolrCore/RequestHandlers, and then in this
> specific use case of the replication JSP can be as arbitrary as it  
> wants.
>
>
> i've got a fix i'll commit as soon as my tests finish...
>
>
>
> : Date: Fri, 10 Jul 2009 10:04:29 -0000
> : From: [hidden email]
> : Reply-To: [hidden email]
> : To: [hidden email]
> : Subject: svn commit: r792861 - in /lucene/solr/trunk/src:
> :     java/org/apache/solr/core/RequestHandlers.java
> :     java/org/apache/solr/core/SolrCore.java webapp/web/admin/
> index.jsp
> :     webapp/web/admin/replication/header.jsp
> :
> : Author: noble
> : Date: Fri Jul 10 10:04:29 2009
> : New Revision: 792861
> :
> : URL: http://svn.apache.org/viewvc?rev=792861&view=rev
> : Log:
> : SOLR-1255 An attempt to visit the replication admin page when its  
> not a defined handler should display an approp message
> :
> : Modified:
> :     lucene/solr/trunk/src/java/org/apache/solr/core/
> RequestHandlers.java
> :     lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
> :     lucene/solr/trunk/src/webapp/web/admin/index.jsp
> :     lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
> :
> : Modified: lucene/solr/trunk/src/java/org/apache/solr/core/
> RequestHandlers.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=792861&r1=792860&r2=792861&view=diff
> :  
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> : --- lucene/solr/trunk/src/java/org/apache/solr/core/
> RequestHandlers.java (original)
> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/
> RequestHandlers.java Fri Jul 10 10:04:29 2009
> : @@ -66,7 +66,7 @@
> :    public RequestHandlers(SolrCore core) {
> :        this.core = core;
> :    }
> : -
> : +
> :    /**
> :     * @return the RequestHandler registered at the given name
> :     */
> : @@ -74,6 +74,13 @@
> :      return handlers.get(normalize(handlerName));
> :    }
> :
> : +  public SolrRequestHandler get(Class clazz) {
> : +    for (SolrRequestHandler requestHandler : handlers.values()) {
> : +      if(requestHandler.getClass() == clazz) return requestHandler;
> : +    }
> : +    return null;
> : +  }
> : +
> :    /**
> :     * Handlers must be initialized before calling this function.  
> As soon as this is
> :     * called, the handler can immediately accept requests.
> :
> : Modified: lucene/solr/trunk/src/java/org/apache/solr/core/
> SolrCore.java
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=792861&r1=792860&r2=792861&view=diff
> :  
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> : --- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java  
> (original)
> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java  
> Fri Jul 10 10:04:29 2009
> : @@ -767,6 +767,10 @@
> :    public SolrRequestHandler getRequestHandler(String handlerName) {
> :      return reqHandlers.get(handlerName);
> :    }
> : +
> : +  public SolrRequestHandler getRequestHandler(Class clazz) {
> : +    return reqHandlers.get(clazz);
> : +  }
> :
> :    /**
> :     * Returns an unmodifieable Map containing the registered  
> handlers
> :
> : Modified: lucene/solr/trunk/src/webapp/web/admin/index.jsp
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/index.jsp?rev=792861&r1=792860&r2=792861&view=diff
> :  
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> : --- lucene/solr/trunk/src/webapp/web/admin/index.jsp (original)
> : +++ lucene/solr/trunk/src/webapp/web/admin/index.jsp Fri Jul 10  
> 10:04:29 2009
> : @@ -24,11 +24,12 @@
> :  <%@ page import="java.util.List" %>
> :  <%@ page import="java.util.Collection" %>
> :  <%@ page import="org.apache.solr.request.SolrRequestHandler"%>
> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
> :
> :  <%-- jsp:include page="header.jsp"/ --%>
> :  <%-- do a verbatim include so we can use the local vars --%>
> :  <%@include file="header.jsp" %>
> : -<%SolrRequestHandler replicationhandler =  
> core.getRequestHandler("/replication");%>
> : +<%SolrRequestHandler replicationhandler =  
> core.getRequestHandler(ReplicationHandler.class);%>
> :  <br clear="all">
> :  <table>
> :
> :
> : Modified: lucene/solr/trunk/src/webapp/web/admin/replication/
> header.jsp
> : URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp?rev=792861&r1=792860&r2=792861&view=diff
> :  
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> : --- lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp  
> (original)
> : +++ lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp  
> Fri Jul 10 10:04:29 2009
> : @@ -21,14 +21,14 @@
> :   org.apache.solr.request.LocalSolrQueryRequest,
> :   org.apache.solr.request.SolrQueryResponse,
> :   org.apache.solr.request.SolrRequestHandler"%>
> : -
> : -<html>
> : -<head>
> : -
> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
> :  <%
> :  request.setCharacterEncoding("UTF-8");
> :  %>
> :
> : +<html>
> : +<head>
> : +
> :  <%@include file="../_info.jsp" %>
> :
> :  <script>
> : @@ -55,7 +55,11 @@
> :  %>
> :
> :  <%
> : -final SolrRequestHandler rh = core.getRequestHandler("/
> replication");
> : +final SolrRequestHandler rh =  
> core.getRequestHandler(ReplicationHandler.class);
> : +  if(rh == null){
> : +    response.sendError( 404, "No ReplicationHandler registered" );
> : +    return;
> : +  }
> :  NamedList namedlist = executeCommand("details",core,rh);
> :  NamedList detailsMap = (NamedList)namedlist.get("details");
> :  if(detailsMap != null)
> :
> :
>
>
>
> -Hoss

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

Noble Paul നോബിള്‍  नोब्ळ्-2
On Sat, Jul 11, 2009 at 7:15 PM, Erik Hatcher<[hidden email]> wrote:
> Also, may want to use instanceof instead of == for class comparison, in case
> subclasses are used.

should we do that ?

I did it intentionally. The user who makes that call knows the class
of the handler. If there is another handler which extends the class he
may get that instance which may not be desirable

>
>        Erik
>
> On Jul 10, 2009, at 3:06 PM, Chris Hostetter wrote:
>
>>
>> Dude .... you've got to at least run "ant test" before you commit ...
>> TestWriterPerf can't even compile now.
>>
>> This breaks anyone that was explicitly passing null to the existing
>> getRequestHandler(String) method (like TestWriterPerf) ... but besides
>> that it also seems really weird to have a method that takes in a class and
>> arbitrarily returns the first instance of that class found -- especially
>> since it's iterating over the values in a Map, so if someone has multiple
>> instances of a handler they could get a different one each time this
>> method is called.
>>
>> making a method that returns *all* the handlers of that type seems like a
>> better general feature for SolrCore/RequestHandlers, and then in this
>> specific use case of the replication JSP can be as arbitrary as it wants.
>>
>>
>> i've got a fix i'll commit as soon as my tests finish...
>>
>>
>>
>> : Date: Fri, 10 Jul 2009 10:04:29 -0000
>> : From: [hidden email]
>> : Reply-To: [hidden email]
>> : To: [hidden email]
>> : Subject: svn commit: r792861 - in /lucene/solr/trunk/src:
>> :     java/org/apache/solr/core/RequestHandlers.java
>> :     java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp
>> :     webapp/web/admin/replication/header.jsp
>> :
>> : Author: noble
>> : Date: Fri Jul 10 10:04:29 2009
>> : New Revision: 792861
>> :
>> : URL: http://svn.apache.org/viewvc?rev=792861&view=rev
>> : Log:
>> : SOLR-1255 An attempt to visit the replication admin page when its not a
>> defined handler should display an approp message
>> :
>> : Modified:
>> :     lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
>> :     lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
>> :     lucene/solr/trunk/src/webapp/web/admin/index.jsp
>> :     lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
>> :
>> : Modified:
>> lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
>> : URL:
>> http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java?rev=792861&r1=792860&r2=792861&view=diff
>> :
>> ==============================================================================
>> : --- lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
>> (original)
>> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/RequestHandlers.java
>> Fri Jul 10 10:04:29 2009
>> : @@ -66,7 +66,7 @@
>> :    public RequestHandlers(SolrCore core) {
>> :        this.core = core;
>> :    }
>> : -
>> : +
>> :    /**
>> :     * @return the RequestHandler registered at the given name
>> :     */
>> : @@ -74,6 +74,13 @@
>> :      return handlers.get(normalize(handlerName));
>> :    }
>> :
>> : +  public SolrRequestHandler get(Class clazz) {
>> : +    for (SolrRequestHandler requestHandler : handlers.values()) {
>> : +      if(requestHandler.getClass() == clazz) return requestHandler;
>> : +    }
>> : +    return null;
>> : +  }
>> : +
>> :    /**
>> :     * Handlers must be initialized before calling this function.  As
>> soon as this is
>> :     * called, the handler can immediately accept requests.
>> :
>> : Modified: lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
>> : URL:
>> http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java?rev=792861&r1=792860&r2=792861&view=diff
>> :
>> ==============================================================================
>> : --- lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java
>> (original)
>> : +++ lucene/solr/trunk/src/java/org/apache/solr/core/SolrCore.java Fri
>> Jul 10 10:04:29 2009
>> : @@ -767,6 +767,10 @@
>> :    public SolrRequestHandler getRequestHandler(String handlerName) {
>> :      return reqHandlers.get(handlerName);
>> :    }
>> : +
>> : +  public SolrRequestHandler getRequestHandler(Class clazz) {
>> : +    return reqHandlers.get(clazz);
>> : +  }
>> :
>> :    /**
>> :     * Returns an unmodifieable Map containing the registered handlers
>> :
>> : Modified: lucene/solr/trunk/src/webapp/web/admin/index.jsp
>> : URL:
>> http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/index.jsp?rev=792861&r1=792860&r2=792861&view=diff
>> :
>> ==============================================================================
>> : --- lucene/solr/trunk/src/webapp/web/admin/index.jsp (original)
>> : +++ lucene/solr/trunk/src/webapp/web/admin/index.jsp Fri Jul 10 10:04:29
>> 2009
>> : @@ -24,11 +24,12 @@
>> :  <%@ page import="java.util.List" %>
>> :  <%@ page import="java.util.Collection" %>
>> :  <%@ page import="org.apache.solr.request.SolrRequestHandler"%>
>> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
>> :
>> :  <%-- jsp:include page="header.jsp"/ --%>
>> :  <%-- do a verbatim include so we can use the local vars --%>
>> :  <%@include file="header.jsp" %>
>> : -<%SolrRequestHandler replicationhandler =
>> core.getRequestHandler("/replication");%>
>> : +<%SolrRequestHandler replicationhandler =
>> core.getRequestHandler(ReplicationHandler.class);%>
>> :  <br clear="all">
>> :  <table>
>> :
>> :
>> : Modified: lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
>> : URL:
>> http://svn.apache.org/viewvc/lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp?rev=792861&r1=792860&r2=792861&view=diff
>> :
>> ==============================================================================
>> : --- lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp
>> (original)
>> : +++ lucene/solr/trunk/src/webapp/web/admin/replication/header.jsp Fri
>> Jul 10 10:04:29 2009
>> : @@ -21,14 +21,14 @@
>> :
>>  org.apache.solr.request.LocalSolrQueryRequest,
>> :
>>  org.apache.solr.request.SolrQueryResponse,
>> :
>>  org.apache.solr.request.SolrRequestHandler"%>
>> : -
>> : -<html>
>> : -<head>
>> : -
>> : +<%@ page import="org.apache.solr.handler.ReplicationHandler" %>
>> :  <%
>> :  request.setCharacterEncoding("UTF-8");
>> :  %>
>> :
>> : +<html>
>> : +<head>
>> : +
>> :  <%@include file="../_info.jsp" %>
>> :
>> :  <script>
>> : @@ -55,7 +55,11 @@
>> :  %>
>> :
>> :  <%
>> : -final SolrRequestHandler rh = core.getRequestHandler("/replication");
>> : +final SolrRequestHandler rh =
>> core.getRequestHandler(ReplicationHandler.class);
>> : +  if(rh == null){
>> : +    response.sendError( 404, "No ReplicationHandler registered" );
>> : +    return;
>> : +  }
>> :  NamedList namedlist = executeCommand("details",core,rh);
>> :  NamedList detailsMap = (NamedList)namedlist.get("details");
>> :  if(detailsMap != null)
>> :
>> :
>>
>>
>>
>> -Hoss
>
>



--
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r792861 - in /lucene/solr/trunk/src: java/org/apache/solr/core/RequestHandlers.java java/org/apache/solr/core/SolrCore.java webapp/web/admin/index.jsp webapp/web/admin/replication/header.jsp

hossman

: > Also, may want to use instanceof instead of == for class comparison, in case
: > subclasses are used.
:
: should we do that ?

i already did.

: I did it intentionally. The user who makes that call knows the class
: of the handler. If there is another handler which extends the class he
: may get that instance which may not be desirable

inheritence is an "is a" relationship -- if a class is special enough that
people expecting instances of it won't function properly when given a
subclass, then that special class should be final.

In this specific case: if i subclass ReplicationHandler to record some
extra stats, or have some additional side effect, that shouldn't make that
link vanish.




-Hoss