SOLR-654 -- add setResponse( NamedList<Object> rsp ) to SolrResponse base class and remove the constructor initalization from the implementaions

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@679649 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2008-07-25 03:18:24 +00:00
parent d5a66e7bc9
commit 0f5af69cff
15 changed files with 40 additions and 29 deletions

View File

@ -30,5 +30,6 @@ import org.apache.solr.common.util.NamedList;
public abstract class SolrResponse implements Serializable public abstract class SolrResponse implements Serializable
{ {
public abstract long getElapsedTime(); public abstract long getElapsedTime();
public abstract void setResponse( NamedList<Object> rsp );
public abstract NamedList<Object> getResponse(); public abstract NamedList<Object> getResponse();
} }

View File

@ -58,7 +58,8 @@ public class DirectXmlRequest extends SolrRequest
public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException
{ {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
UpdateResponse res = new UpdateResponse( server.request( this ) ); UpdateResponse res = new UpdateResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime ); res.setElapsedTime( System.currentTimeMillis()-startTime );
return res; return res;
} }

View File

@ -117,7 +117,8 @@ public class LukeRequest extends SolrRequest
public LukeResponse process( SolrServer server ) throws SolrServerException, IOException public LukeResponse process( SolrServer server ) throws SolrServerException, IOException
{ {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
LukeResponse res = new LukeResponse( server.request( this ) ); LukeResponse res = new LukeResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime ); res.setElapsedTime( System.currentTimeMillis()-startTime );
return res; return res;
} }

View File

@ -130,7 +130,8 @@ public class MultiCoreRequest extends SolrRequest
public MultiCoreResponse process(SolrServer server) throws SolrServerException, IOException public MultiCoreResponse process(SolrServer server) throws SolrServerException, IOException
{ {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
MultiCoreResponse res = new MultiCoreResponse( server.request( this ) ); MultiCoreResponse res = new MultiCoreResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime ); res.setElapsedTime( System.currentTimeMillis()-startTime );
return res; return res;
} }

View File

@ -56,7 +56,8 @@ public class SolrPing extends SolrRequest
public SolrPingResponse process( SolrServer server ) throws SolrServerException, IOException public SolrPingResponse process( SolrServer server ) throws SolrServerException, IOException
{ {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
SolrPingResponse res = new SolrPingResponse( server.request( this ) ); SolrPingResponse res = new SolrPingResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime ); res.setElapsedTime( System.currentTimeMillis()-startTime );
return res; return res;
} }

View File

@ -213,7 +213,8 @@ public class UpdateRequest extends SolrRequest
public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException public UpdateResponse process( SolrServer server ) throws SolrServerException, IOException
{ {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
UpdateResponse res = new UpdateResponse( server.request( this ) ); UpdateResponse res = new UpdateResponse();
res.setResponse( server.request( this ) );
res.setElapsedTime( System.currentTimeMillis()-startTime ); res.setElapsedTime( System.currentTimeMillis()-startTime );
return res; return res;
} }

View File

@ -188,9 +188,10 @@ public class LukeResponse extends SolrResponseBase {
private Map<String, FieldInfo> fieldInfo; private Map<String, FieldInfo> fieldInfo;
private Map<String, FieldTypeInfo> fieldTypeInfo; private Map<String, FieldTypeInfo> fieldTypeInfo;
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public LukeResponse(NamedList<Object> res) { public void setResponse(NamedList<Object> res) {
super(res); super.setResponse(res);
// Parse indexinfo // Parse indexinfo
indexInfo = (NamedList<Object>) res.get("index"); indexInfo = (NamedList<Object>) res.get("index");

View File

@ -26,11 +26,7 @@ import org.apache.solr.common.util.NamedList;
* @since solr 1.3 * @since solr 1.3
*/ */
public class MultiCoreResponse extends SolrResponseBase public class MultiCoreResponse extends SolrResponseBase
{ {
public MultiCoreResponse(NamedList<Object> res) {
super(res);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public NamedList<NamedList<Object>> getCoreStatus() public NamedList<NamedList<Object>> getCoreStatus()
{ {

View File

@ -58,16 +58,24 @@ public class QueryResponse extends SolrResponseBase
private Map<String,String> _explainMap = null; private Map<String,String> _explainMap = null;
// utility variable used for automatic binding -- it should not be serialized // utility variable used for automatic binding -- it should not be serialized
private transient SolrServer solrServer; private transient final SolrServer solrServer;
public QueryResponse(){
solrServer = null;
}
/**
* Utility constructor to set the solrServer and namedList
*/
public QueryResponse( NamedList<Object> res , SolrServer solrServer){ public QueryResponse( NamedList<Object> res , SolrServer solrServer){
this(res); this.setResponse( res );
this.solrServer = solrServer; this.solrServer = solrServer;
} }
public QueryResponse( NamedList<Object> res ) @Override
public void setResponse( NamedList<Object> res )
{ {
super( res ); super.setResponse( res );
// Look for known things // Look for known things
for( int i=0; i<res.size(); i++ ) { for( int i=0; i<res.size(); i++ ) {

View File

@ -26,7 +26,5 @@ import org.apache.solr.common.util.NamedList;
*/ */
public class SolrPingResponse extends SolrResponseBase public class SolrPingResponse extends SolrResponseBase
{ {
public SolrPingResponse(NamedList<Object> res) { // nothing special now...
super(res);
}
} }

View File

@ -31,11 +31,6 @@ public class SolrResponseBase extends SolrResponse
private NamedList<Object> response = null; private NamedList<Object> response = null;
private String requestUrl = null; private String requestUrl = null;
public SolrResponseBase( NamedList<Object> res )
{
response = res;
}
@Override @Override
public long getElapsedTime() { public long getElapsedTime() {
return elapsedTime; return elapsedTime;
@ -50,6 +45,7 @@ public class SolrResponseBase extends SolrResponse
return response; return response;
} }
@Override
public void setResponse(NamedList<Object> response) { public void setResponse(NamedList<Object> response) {
this.response = response; this.response = response;
} }

View File

@ -28,7 +28,5 @@ import org.apache.solr.common.util.NamedList;
*/ */
public class UpdateResponse extends SolrResponseBase public class UpdateResponse extends SolrResponseBase
{ {
public UpdateResponse(NamedList<Object> res) { // nothing special now...
super(res);
}
} }

View File

@ -42,7 +42,7 @@ public class TestDocumentObjectBinder extends TestCase
XMLResponseParser parser = new XMLResponseParser(); XMLResponseParser parser = new XMLResponseParser();
NamedList<Object> nl = null; NamedList<Object> nl = null;
nl = parser.processResponse(new StringReader(xml)); nl = parser.processResponse(new StringReader(xml));
QueryResponse res = new QueryResponse(nl); QueryResponse res = new QueryResponse(nl, null);
SolrDocumentList solDocList = res.getResults(); SolrDocumentList solDocList = res.getResults();
List<Item> l = binder.getBeans(Item.class,res.getResults()); List<Item> l = binder.getBeans(Item.class,res.getResults());
Assert.assertEquals(solDocList.size(), l.size()); Assert.assertEquals(solDocList.size(), l.size());

View File

@ -42,7 +42,7 @@ public class QueryResponseTest {
NamedList<Object> response = parser.processResponse(in); NamedList<Object> response = parser.processResponse(in);
in.close(); in.close();
QueryResponse qr = new QueryResponse(response); QueryResponse qr = new QueryResponse(response, null);
Assert.assertNotNull(qr); Assert.assertNotNull(qr);
Assert.assertNotNull(qr.getFacetDates()); Assert.assertNotNull(qr.getFacetDates());

View File

@ -332,13 +332,21 @@ class HttpCommComponent {
private static class SimpleSolrResponse extends SolrResponse { private static class SimpleSolrResponse extends SolrResponse {
long elapsedTime; long elapsedTime;
NamedList<Object> nl; NamedList<Object> nl;
@Override
public long getElapsedTime() { public long getElapsedTime() {
return elapsedTime; return elapsedTime;
} }
@Override
public NamedList<Object> getResponse() { public NamedList<Object> getResponse() {
return nl; return nl;
} }
@Override
public void setResponse(NamedList<Object> rsp) {
nl = rsp;
}
} }
void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) { void submit(final ShardRequest sreq, final String shard, final ModifiableSolrParams params) {