mirror of https://github.com/apache/lucene.git
SOLR-7145: SolrRequest is now parametrized by its response type
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662198 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
caf9037242
commit
732f9aeecc
|
@ -186,6 +186,9 @@ Other Changes
|
|||
|
||||
* SOLR-7032: Clean up test remnants of old-style solr.xml (Erick Erickson)
|
||||
|
||||
* SOLR-7145: SolrRequest is now parametrized by its response type (Alan
|
||||
Woodward)
|
||||
|
||||
* SOLR-7142: Fix TestFaceting.testFacets. (Michal Kroliczek via shalin)
|
||||
|
||||
* SOLR-7156: Fix test failures due to resource leaks on windows.
|
||||
|
|
|
@ -24,14 +24,15 @@ public class OverseerSolrResponse extends SolrResponse {
|
|||
|
||||
NamedList responseList = null;
|
||||
|
||||
private long elapsedTime;
|
||||
|
||||
public OverseerSolrResponse(NamedList list) {
|
||||
responseList = list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getElapsedTime() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,6 +40,11 @@ public class OverseerSolrResponse extends SolrResponse {
|
|||
this.responseList = rsp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElapsedTime(long elapsedTime) {
|
||||
this.elapsedTime = elapsedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamedList<Object> getResponse() {
|
||||
return responseList;
|
||||
|
|
|
@ -85,7 +85,9 @@ public class HttpShardHandler extends ShardHandler {
|
|||
|
||||
|
||||
private static class SimpleSolrResponse extends SolrResponse {
|
||||
|
||||
long elapsedTime;
|
||||
|
||||
NamedList<Object> nl;
|
||||
|
||||
@Override
|
||||
|
@ -102,6 +104,11 @@ public class HttpShardHandler extends ShardHandler {
|
|||
public void setResponse(NamedList<Object> rsp) {
|
||||
nl = rsp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setElapsedTime(long elapsedTime) {
|
||||
this.elapsedTime = elapsedTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.apache.solr.analysis.TokenizerChain;
|
|||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrResponse;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.cloud.ZkController;
|
||||
import org.apache.solr.cloud.ZkSolrResourceLoader;
|
||||
|
@ -363,9 +362,10 @@ public final class ManagedIndexSchema extends IndexSchema {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SolrResponse process(SolrClient server) throws SolrServerException, IOException {
|
||||
protected SolrResponse createResponse(SolrClient client) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -17,21 +17,22 @@
|
|||
|
||||
package org.apache.solr.client.solrj;
|
||||
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public abstract class SolrRequest implements Serializable
|
||||
{
|
||||
public abstract class SolrRequest<T extends SolrResponse> implements Serializable {
|
||||
|
||||
public enum METHOD {
|
||||
GET,
|
||||
POST,
|
||||
|
@ -108,6 +109,29 @@ public abstract class SolrRequest implements Serializable
|
|||
}
|
||||
|
||||
public abstract SolrParams getParams();
|
||||
|
||||
public abstract Collection<ContentStream> getContentStreams() throws IOException;
|
||||
public abstract SolrResponse process( SolrClient server ) throws SolrServerException, IOException;
|
||||
|
||||
/**
|
||||
* Create a new SolrResponse to hold the response from the server
|
||||
* @param client the {@link SolrClient} the request will be sent to
|
||||
*/
|
||||
protected abstract T createResponse(SolrClient client);
|
||||
|
||||
/**
|
||||
* Send this request to a {@link SolrClient} and return the response
|
||||
* @param client the SolrClient to communicate with
|
||||
* @return the response
|
||||
* @throws SolrServerException if there is an error on the Solr server
|
||||
* @throws IOException if there is a communication error
|
||||
*/
|
||||
public T process(SolrClient client) throws SolrServerException, IOException {
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
T res = createResponse(client);
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,16 +17,16 @@
|
|||
|
||||
package org.apache.solr.client.solrj;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrException.ErrorCode;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -38,6 +38,8 @@ public abstract class SolrResponse implements Serializable {
|
|||
|
||||
public abstract void setResponse(NamedList<Object> rsp);
|
||||
|
||||
public abstract void setElapsedTime(long elapsedTime);
|
||||
|
||||
public abstract NamedList<Object> getResponse();
|
||||
|
||||
public static byte[] serializable(SolrResponse response) {
|
||||
|
|
|
@ -16,22 +16,18 @@ package org.apache.solr.client.solrj.request;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.UpdateParams;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
**/
|
||||
public abstract class AbstractUpdateRequest extends SolrRequest implements IsUpdateRequest {
|
||||
public abstract class AbstractUpdateRequest extends SolrRequest<UpdateResponse> implements IsUpdateRequest {
|
||||
protected ModifiableSolrParams params;
|
||||
protected int commitWithin = -1;
|
||||
|
||||
|
@ -117,14 +113,8 @@ public abstract class AbstractUpdateRequest extends SolrRequest implements IsUpd
|
|||
}
|
||||
|
||||
@Override
|
||||
public UpdateResponse process(SolrClient client) throws SolrServerException, IOException
|
||||
{
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
UpdateResponse res = new UpdateResponse();
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
protected UpdateResponse createResponse(SolrClient client) {
|
||||
return new UpdateResponse();
|
||||
}
|
||||
|
||||
public boolean isWaitSearcher() {
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
|
@ -36,14 +35,14 @@ import java.util.Collection;
|
|||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* This class is experimental and subject to change.
|
||||
*
|
||||
* @since solr 4.5
|
||||
*/
|
||||
public class CollectionAdminRequest extends SolrRequest {
|
||||
public class CollectionAdminRequest extends SolrRequest<CollectionAdminResponse> {
|
||||
|
||||
protected CollectionAction action = null;
|
||||
|
||||
private static String PROPERTY_PREFIX = "property.";
|
||||
|
@ -78,14 +77,8 @@ public class CollectionAdminRequest extends SolrRequest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CollectionAdminResponse process(SolrClient server) throws SolrServerException, IOException
|
||||
{
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
CollectionAdminResponse res = new CollectionAdminResponse();
|
||||
res.setResponse( server.request( this ) );
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
protected CollectionAdminResponse createResponse(SolrClient client) {
|
||||
return new CollectionAdminResponse();
|
||||
}
|
||||
|
||||
protected void addProperties(ModifiableSolrParams params, Properties props) {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.CoreAdminResponse;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
|
@ -32,15 +32,14 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* This class is experimental and subject to change.
|
||||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class CoreAdminRequest extends SolrRequest
|
||||
{
|
||||
public class CoreAdminRequest extends SolrRequest<CoreAdminResponse> {
|
||||
|
||||
protected String core = null;
|
||||
protected String other = null;
|
||||
protected boolean isIndexInfoNeeded = true;
|
||||
|
@ -48,6 +47,7 @@ public class CoreAdminRequest extends SolrRequest
|
|||
|
||||
//a create core request
|
||||
public static class Create extends CoreAdminRequest {
|
||||
|
||||
protected String instanceDir;
|
||||
protected String configName = null;
|
||||
protected String schemaName = null;
|
||||
|
@ -503,14 +503,8 @@ public class CoreAdminRequest extends SolrRequest
|
|||
}
|
||||
|
||||
@Override
|
||||
public CoreAdminResponse process(SolrClient client) throws SolrServerException, IOException
|
||||
{
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
CoreAdminResponse res = new CoreAdminResponse();
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
protected CoreAdminResponse createResponse(SolrClient client) {
|
||||
return new CoreAdminResponse();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
|
|
@ -19,15 +19,12 @@ package org.apache.solr.client.solrj.request;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Send arbitrary XML to a request handler
|
||||
|
@ -35,8 +32,8 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class DirectXmlRequest extends SolrRequest implements IsUpdateRequest
|
||||
{
|
||||
public class DirectXmlRequest extends SolrRequest<UpdateResponse> implements IsUpdateRequest {
|
||||
|
||||
final String xml;
|
||||
private SolrParams params;
|
||||
|
||||
|
@ -51,6 +48,11 @@ public class DirectXmlRequest extends SolrRequest implements IsUpdateRequest
|
|||
return ClientUtils.toContentStreams( xml, ClientUtils.TEXT_XML );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UpdateResponse createResponse(SolrClient client) {
|
||||
return new UpdateResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
return params;
|
||||
|
@ -61,13 +63,4 @@ public class DirectXmlRequest extends SolrRequest implements IsUpdateRequest
|
|||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateResponse process(SolrClient client) throws SolrServerException, IOException
|
||||
{
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
UpdateResponse res = new UpdateResponse();
|
||||
res.setResponse(client.request(this));
|
||||
res.setElapsedTime( TimeUnit.MILLISECONDS.convert(System.nanoTime()-startTime, TimeUnit.NANOSECONDS) );
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.response.DocumentAnalysisResponse;
|
||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
|
@ -32,7 +31,6 @@ import java.io.StringWriter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A request for the org.apache.solr.handler.DocumentAnalysisRequestHandler.
|
||||
|
@ -40,7 +38,7 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since solr 1.4
|
||||
*/
|
||||
public class DocumentAnalysisRequest extends SolrRequest {
|
||||
public class DocumentAnalysisRequest extends SolrRequest<DocumentAnalysisResponse> {
|
||||
|
||||
private List<SolrInputDocument> documents = new ArrayList<>();
|
||||
private String query;
|
||||
|
@ -70,6 +68,11 @@ public class DocumentAnalysisRequest extends SolrRequest {
|
|||
return ClientUtils.toContentStreams(getXML(), ClientUtils.TEXT_XML);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DocumentAnalysisResponse createResponse(SolrClient client) {
|
||||
return new DocumentAnalysisResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -83,19 +86,6 @@ public class DocumentAnalysisRequest extends SolrRequest {
|
|||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public DocumentAnalysisResponse process(SolrClient client) throws SolrServerException, IOException {
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
DocumentAnalysisResponse res = new DocumentAnalysisResponse();
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
}
|
||||
|
||||
//================================================ Helper Methods ==================================================
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,9 +17,8 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.response.FieldAnalysisResponse;
|
||||
import org.apache.solr.common.params.AnalysisParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -30,7 +29,6 @@ import java.io.IOException;
|
|||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* A request for the org.apache.solr.handler.FieldAnalysisRequestHandler.
|
||||
|
@ -38,7 +36,7 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since solr.14
|
||||
*/
|
||||
public class FieldAnalysisRequest extends SolrRequest {
|
||||
public class FieldAnalysisRequest extends SolrRequest<FieldAnalysisResponse> {
|
||||
|
||||
private String fieldValue;
|
||||
private String query;
|
||||
|
@ -70,6 +68,17 @@ public class FieldAnalysisRequest extends SolrRequest {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FieldAnalysisResponse createResponse(SolrClient client) {
|
||||
if (fieldTypes == null && fieldNames == null) {
|
||||
throw new IllegalStateException("At least one field type or field name need to be specified");
|
||||
}
|
||||
if (fieldValue == null) {
|
||||
throw new IllegalStateException("The field value must be set");
|
||||
}
|
||||
return new FieldAnalysisResponse();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -92,26 +101,6 @@ public class FieldAnalysisRequest extends SolrRequest {
|
|||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public FieldAnalysisResponse process(SolrClient server) throws SolrServerException, IOException {
|
||||
if (fieldTypes == null && fieldNames == null) {
|
||||
throw new IllegalStateException("At least one field type or field name need to be specified");
|
||||
}
|
||||
if (fieldValue == null) {
|
||||
throw new IllegalStateException("The field value must be set");
|
||||
}
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
FieldAnalysisResponse res = new FieldAnalysisResponse();
|
||||
res.setResponse(server.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
//================================================ Helper Methods ==================================================
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,26 +19,23 @@ package org.apache.solr.client.solrj.request;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.LukeResponse;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class LukeRequest extends SolrRequest
|
||||
{
|
||||
public class LukeRequest extends SolrRequest<LukeResponse> {
|
||||
|
||||
private List<String> fields;
|
||||
private int numTerms = -1;
|
||||
private boolean showSchema = false;
|
||||
|
@ -99,6 +96,11 @@ public class LukeRequest extends SolrRequest
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LukeResponse createResponse(SolrClient client) {
|
||||
return new LukeResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
|
@ -114,15 +116,5 @@ public class LukeRequest extends SolrRequest
|
|||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LukeResponse process( SolrClient client ) throws SolrServerException, IOException
|
||||
{
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
LukeResponse res = new LukeResponse();
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -34,8 +34,8 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class QueryRequest extends SolrRequest
|
||||
{
|
||||
public class QueryRequest extends SolrRequest<QueryResponse> {
|
||||
|
||||
private SolrParams query;
|
||||
|
||||
public QueryRequest()
|
||||
|
@ -78,25 +78,35 @@ public class QueryRequest extends SolrRequest
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected QueryResponse createResponse(SolrClient client) {
|
||||
return new QueryResponse(client);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this request to a {@link SolrClient} and return the response
|
||||
* @param client the SolrClient to communicate with
|
||||
* @return the response
|
||||
* @throws org.apache.solr.client.solrj.SolrServerException if there is an error on the Solr server
|
||||
*/
|
||||
@Override
|
||||
public QueryResponse process(SolrClient client) throws SolrServerException {
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
QueryResponse res = createResponse(client);
|
||||
try {
|
||||
res.setResponse(client.request(this));
|
||||
} catch (IOException e) {
|
||||
throw new SolrServerException("Error executing query", e);
|
||||
}
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public QueryResponse process( SolrClient client ) throws SolrServerException
|
||||
{
|
||||
try {
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
QueryResponse res = new QueryResponse( client.request( this ), client );
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
} catch (SolrServerException | SolrException e){
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new SolrServerException("Error executing query", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,12 @@ package org.apache.solr.client.solrj.request;
|
|||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrRequest;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.SolrPingResponse;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.util.ContentStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Verify that there is a working Solr core at the URL of a {@link org.apache.solr.client.solrj.SolrClient}.
|
||||
|
@ -36,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class SolrPing extends SolrRequest {
|
||||
public class SolrPing extends SolrRequest<SolrPingResponse> {
|
||||
|
||||
/** serialVersionUID. */
|
||||
private static final long serialVersionUID = 5828246236669090017L;
|
||||
|
@ -58,19 +55,13 @@ public class SolrPing extends SolrRequest {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ModifiableSolrParams getParams() {
|
||||
return params;
|
||||
protected SolrPingResponse createResponse(SolrClient client) {
|
||||
return new SolrPingResponse();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrPingResponse process(SolrClient client)
|
||||
throws SolrServerException, IOException {
|
||||
long startTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
SolrPingResponse res = new SolrPingResponse();
|
||||
res.setResponse(client.request(this));
|
||||
long endTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
|
||||
res.setElapsedTime(endTime - startTime);
|
||||
return res;
|
||||
public ModifiableSolrParams getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,19 +17,6 @@
|
|||
|
||||
package org.apache.solr.client.solrj.request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
|
||||
import org.apache.solr.client.solrj.util.ClientUtils;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
|
@ -40,12 +27,26 @@ import org.apache.solr.common.params.ModifiableSolrParams;
|
|||
import org.apache.solr.common.util.ContentStream;
|
||||
import org.apache.solr.common.util.XML;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @since solr 1.3
|
||||
*/
|
||||
public class UpdateRequest extends AbstractUpdateRequest {
|
||||
|
||||
public static final String REPFACT = "rf";
|
||||
public static final String MIN_REPFACT = "min_rf";
|
||||
public static final String VER = "ver";
|
||||
|
|
|
@ -17,6 +17,13 @@
|
|||
|
||||
package org.apache.solr.client.solrj.response;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CursorMarkParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
@ -25,13 +32,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.beans.DocumentObjectBinder;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.CursorMarkParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -99,6 +99,10 @@ public class QueryResponse extends SolrResponseBase
|
|||
this.solrClient = solrClient;
|
||||
}
|
||||
|
||||
public QueryResponse(SolrClient solrClient) {
|
||||
this.solrClient = solrClient;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResponse( NamedList<Object> res )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue