mirror of https://github.com/apache/lucene.git
SOLR-7151: SolrClient query methods throw IOException
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1662670 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c84653e08
commit
d7eefdd7a7
|
@ -71,6 +71,16 @@ Apache UIMA 2.3.1
|
|||
Apache ZooKeeper 3.4.6
|
||||
Jetty 9.2.6.v20141205
|
||||
|
||||
Upgrading from Solr 5.0
|
||||
-----------------------
|
||||
|
||||
* SolrClient query functions now declare themselves as throwing IOException in
|
||||
addition to SolrServerException, to bring them in line with the update
|
||||
functions.
|
||||
|
||||
* SolrRequest.process() is now final. Subclasses should instead be parametrized
|
||||
by their corresponding SolrResponse type, and implement createResponse()
|
||||
|
||||
Detailed Change List
|
||||
----------------------
|
||||
|
||||
|
@ -216,6 +226,8 @@ Other Changes
|
|||
* SOLR-7130: Make stale state notification work without failing the requests
|
||||
(Noble Paul, shalin)
|
||||
|
||||
* SOLR-7151: SolrClient query methods throw IOException
|
||||
|
||||
================== 5.0.0 ==================
|
||||
|
||||
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
|
||||
|
|
|
@ -196,7 +196,7 @@ public class SolrEntityProcessor extends EntityProcessorBase {
|
|||
QueryResponse response = null;
|
||||
try {
|
||||
response = solrClient.query(solrQuery);
|
||||
} catch (SolrServerException e) {
|
||||
} catch (SolrServerException | IOException e) {
|
||||
if (ABORT.equals(onError)) {
|
||||
wrapAndThrow(SEVERE, e);
|
||||
} else if (SKIP.equals(onError)) {
|
||||
|
|
|
@ -686,7 +686,7 @@ public class MorphlineGoLiveMiniMRTest extends AbstractFullDistribZkTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
private SolrDocumentList executeSolrQuery(SolrClient collection, String queryString) throws SolrServerException {
|
||||
private SolrDocumentList executeSolrQuery(SolrClient collection, String queryString) throws SolrServerException, IOException {
|
||||
SolrQuery query = new SolrQuery(queryString).setRows(2 * RECORD_COUNT).addSort("id", ORDER.asc);
|
||||
QueryResponse response = collection.query(query);
|
||||
return response.getResults();
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.apache.solr.common.params.ModifiableSolrParams;
|
|||
import org.apache.solr.common.util.NamedList;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* TODO? perhaps use:
|
||||
* http://docs.codehaus.org/display/JETTY/ServletTester
|
||||
|
@ -266,7 +268,7 @@ public class TestDistributedGrouping extends BaseDistributedSearchTestCase {
|
|||
simpleQuery("q", "*:*", "rows", 10, "fl", "id," + i1, "group", "true", "group.field", i1, "debug", "true");
|
||||
}
|
||||
|
||||
private void simpleQuery(Object... queryParams) throws SolrServerException {
|
||||
private void simpleQuery(Object... queryParams) throws SolrServerException, IOException {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
for (int i = 0; i < queryParams.length; i += 2) {
|
||||
params.add(queryParams[i].toString(), queryParams[i + 1].toString());
|
||||
|
|
|
@ -17,11 +17,6 @@
|
|||
|
||||
package org.apache.solr;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
|
@ -39,6 +34,12 @@ import org.apache.solr.common.params.ShardParams;
|
|||
import org.apache.solr.common.util.NamedList;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* TODO? perhaps use:
|
||||
* http://docs.codehaus.org/display/JETTY/ServletTester
|
||||
|
@ -633,7 +634,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
|||
if (verifyStress) {
|
||||
comparePartialResponses(rsp, controlRsp, upShards);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -648,7 +649,7 @@ public class TestDistributedSearch extends BaseDistributedSearchTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
protected QueryResponse queryRandomUpServer(ModifiableSolrParams params, List<SolrClient> upClients) throws SolrServerException {
|
||||
protected QueryResponse queryRandomUpServer(ModifiableSolrParams params, List<SolrClient> upClients) throws SolrServerException, IOException {
|
||||
// query a random "up" server
|
||||
int which = r.nextInt(upClients.size());
|
||||
SolrClient client = upClients.get(which);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetFieldsPhaseError() throws SolrServerException {
|
||||
public void testGetFieldsPhaseError() throws SolrServerException, IOException {
|
||||
BadResponseWriter.failOnGetFields = true;
|
||||
BadResponseWriter.failOnGetTopIds = false;
|
||||
SolrQuery query = new SolrQuery();
|
||||
|
@ -157,7 +157,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetTopIdsPhaseError() throws SolrServerException {
|
||||
public void testGetTopIdsPhaseError() throws SolrServerException, IOException {
|
||||
BadResponseWriter.failOnGetTopIds = true;
|
||||
BadResponseWriter.failOnGetFields = false;
|
||||
SolrQuery query = new SolrQuery();
|
||||
|
|
|
@ -1127,7 +1127,7 @@ public class BasicDistributedZkTest extends AbstractFullDistribZkTestBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||
|
||||
if (r.nextBoolean())
|
||||
return super.queryServer(params);
|
||||
|
|
|
@ -1144,7 +1144,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
|||
}
|
||||
|
||||
@Override
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||
|
||||
if (r.nextBoolean())
|
||||
return super.queryServer(params);
|
||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.solr.util.DefaultSolrThreadFactory;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -447,7 +448,7 @@ public class CustomCollectionTest extends AbstractFullDistribZkTestBase {
|
|||
|
||||
|
||||
@Override
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||
|
||||
if (r.nextBoolean())
|
||||
return super.queryServer(params);
|
||||
|
|
|
@ -169,7 +169,7 @@ public class DistribDocExpirationUpdateProcessorTest extends AbstractFullDistrib
|
|||
*/
|
||||
private void waitForNoResults(int maxTimeLimitSeconds,
|
||||
SolrParams params)
|
||||
throws SolrServerException, InterruptedException {
|
||||
throws SolrServerException, InterruptedException, IOException {
|
||||
|
||||
final long giveUpAfter = System.currentTimeMillis() + (1000L * maxTimeLimitSeconds);
|
||||
long numFound = cloudClient.query(params).getResults().getNumFound();
|
||||
|
|
|
@ -751,7 +751,7 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
|
|||
assertEquals(1, res.getResults().getNumFound());
|
||||
}
|
||||
|
||||
private QueryResponse query(SolrClient client) throws SolrServerException {
|
||||
private QueryResponse query(SolrClient client) throws SolrServerException, IOException {
|
||||
SolrQuery query = new SolrQuery("*:*");
|
||||
return client.query(query);
|
||||
}
|
||||
|
|
|
@ -16,36 +16,42 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.response.FieldStatsInfo;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.PivotField;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.params.FacetParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.params.StatsParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.schema.TrieDateField;
|
||||
|
||||
import org.apache.solr.common.params.FacetParams; // jdoc lint
|
||||
import static org.apache.solr.common.params.FacetParams.*;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.apache.solr.common.params.FacetParams.FACET;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_LIMIT;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_MISSING;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_OFFSET;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_OVERREQUEST_COUNT;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_OVERREQUEST_RATIO;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_PIVOT;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_PIVOT_MINCOUNT;
|
||||
import static org.apache.solr.common.params.FacetParams.FACET_SORT;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -320,7 +326,7 @@ public class TestCloudPivotFacet extends AbstractFullDistribZkTestBase {
|
|||
* @param params base solr parameters
|
||||
*/
|
||||
private void assertPivotData(String pivotName, PivotField constraint, SolrParams params)
|
||||
throws SolrServerException {
|
||||
throws SolrServerException, IOException {
|
||||
|
||||
SolrParams p = SolrParams.wrapDefaults(params("rows","0"), params);
|
||||
QueryResponse res = cloudClient.query(p);
|
||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.solr.handler;
|
|||
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.util.IOUtils;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.BaseDistributedSearchTestCase;
|
||||
|
@ -172,7 +171,7 @@ public class TestReplicationHandler extends SolrTestCaseJ4 {
|
|||
return s.add(doc).getStatus();
|
||||
}
|
||||
|
||||
NamedList query(String query, SolrClient s) throws SolrServerException {
|
||||
NamedList query(String query, SolrClient s) throws SolrServerException, IOException {
|
||||
NamedList res = new SimpleOrderedMap();
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ public class ShowFileRequestHandlerTest extends SolrJettyTestBase {
|
|||
createJetty(legacyExampleCollection1SolrHome(), null, null);
|
||||
}
|
||||
|
||||
public void test404ViaHttp() throws SolrServerException {
|
||||
public void test404ViaHttp() throws SolrServerException, IOException {
|
||||
SolrClient client = getSolrClient();
|
||||
QueryRequest request = new QueryRequest(params("file",
|
||||
"does-not-exist-404.txt"));
|
||||
|
@ -80,7 +80,7 @@ public class ShowFileRequestHandlerTest extends SolrJettyTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testDirList() throws SolrServerException {
|
||||
public void testDirList() throws SolrServerException, IOException {
|
||||
SolrClient client = getSolrClient();
|
||||
//assertQ(req("qt", "/admin/file")); TODO file bug that SolrJettyTestBase extends SolrTestCaseJ4
|
||||
QueryRequest request = new QueryRequest();
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
|
@ -263,7 +264,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
|
|||
|
||||
}
|
||||
|
||||
private void verifyDebugSections(SolrQuery query, SolrClient client) throws SolrServerException {
|
||||
private void verifyDebugSections(SolrQuery query, SolrClient client) throws SolrServerException, IOException {
|
||||
query.set("debugQuery", "true");
|
||||
query.remove("debug");
|
||||
QueryResponse response = client.query(query);
|
||||
|
@ -343,7 +344,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
|
|||
assertNull(response.getDebugMap());
|
||||
}
|
||||
|
||||
public void testCompareWithNonDistributedRequest() throws SolrServerException {
|
||||
public void testCompareWithNonDistributedRequest() throws SolrServerException, IOException {
|
||||
SolrQuery query = new SolrQuery();
|
||||
query.setQuery("id:1");
|
||||
query.setFilterQueries("id:[0 TO 10]");
|
||||
|
@ -375,7 +376,7 @@ public class DistributedDebugComponentTest extends SolrJettyTestBase {
|
|||
assertSameKeys((NamedList<?>)nonDistribResponse.getDebugMap().get("timing"), (NamedList<?>)distribResponse.getDebugMap().get("timing"));
|
||||
}
|
||||
|
||||
public void testTolerantSearch() throws SolrServerException {
|
||||
public void testTolerantSearch() throws SolrServerException, IOException {
|
||||
String badShard = "[ff01::0083]:3334";
|
||||
SolrQuery query = new SolrQuery();
|
||||
query.setQuery("*:*");
|
||||
|
|
|
@ -17,12 +17,6 @@ package org.apache.solr.handler.component;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
|
@ -31,6 +25,12 @@ import org.apache.solr.common.util.SimpleOrderedMap;
|
|||
import org.apache.solr.common.util.StrUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Test for QueryComponent's distributed querying optimization.
|
||||
* If the "fl" param is just "id" or just "id,score", all document data to return is already fetched by STAGE_EXECUTE_QUERY.
|
||||
|
|
|
@ -125,7 +125,7 @@ public class TestRemoteStreaming extends SolrJettyTestBase {
|
|||
/** SOLR-3161
|
||||
* Technically stream.body isn't remote streaming, but there wasn't a better place for this test method. */
|
||||
@Test(expected = SolrException.class)
|
||||
public void testQtUpdateFails() throws SolrServerException {
|
||||
public void testQtUpdateFails() throws SolrServerException, IOException {
|
||||
SolrQuery query = new SolrQuery();
|
||||
query.setQuery( "*:*" );//for anything
|
||||
query.add("echoHandler","true");
|
||||
|
@ -152,7 +152,7 @@ public class TestRemoteStreaming extends SolrJettyTestBase {
|
|||
return client.getBaseURL()+"/update?commit=true&stream.body="+ URLEncoder.encode(deleteQuery, "UTF-8");
|
||||
}
|
||||
|
||||
private boolean searchFindsIt() throws SolrServerException {
|
||||
private boolean searchFindsIt() throws SolrServerException, IOException {
|
||||
SolrQuery query = new SolrQuery();
|
||||
query.setQuery( "id:1234" );
|
||||
QueryResponse rsp = getSolrClient().query(query);
|
||||
|
|
|
@ -305,7 +305,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
* Performs a query to the Solr server
|
||||
* @param params an object holding all key/value parameters to send along the request
|
||||
*/
|
||||
public QueryResponse query(SolrParams params) throws SolrServerException {
|
||||
public QueryResponse query(SolrParams params) throws SolrServerException, IOException {
|
||||
return new QueryRequest(params).process(this);
|
||||
}
|
||||
|
||||
|
@ -314,7 +314,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
* @param params an object holding all key/value parameters to send along the request
|
||||
* @param method specifies the HTTP method to use for the request, such as GET or POST
|
||||
*/
|
||||
public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException {
|
||||
public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException, IOException {
|
||||
return new QueryRequest(params, method).process(this);
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
*
|
||||
* @return retrieved SolrDocument, null if no document is found.
|
||||
*/
|
||||
public SolrDocument getById(String id) throws SolrServerException {
|
||||
public SolrDocument getById(String id) throws SolrServerException, IOException {
|
||||
return getById(id, null);
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
*
|
||||
* @return retrieved SolrDocument, null if no document is found.
|
||||
*/
|
||||
public SolrDocument getById(String id, SolrParams params) throws SolrServerException {
|
||||
public SolrDocument getById(String id, SolrParams params) throws SolrServerException, IOException {
|
||||
SolrDocumentList docs = getById(Arrays.asList(id), params);
|
||||
if (!docs.isEmpty()) {
|
||||
return docs.get(0);
|
||||
|
@ -365,7 +365,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
* Retrieves the SolrDocuments associated with the given identifiers.
|
||||
* If a document was not found, it will not be added to the SolrDocumentList.
|
||||
*/
|
||||
public SolrDocumentList getById(Collection<String> ids) throws SolrServerException {
|
||||
public SolrDocumentList getById(Collection<String> ids) throws SolrServerException, IOException {
|
||||
return getById(ids, null);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ public abstract class SolrClient implements Serializable, Closeable {
|
|||
* the SolrParams to execute the request.
|
||||
* If a document was not found, it will not be added to the SolrDocumentList.
|
||||
*/
|
||||
public SolrDocumentList getById(Collection<String> ids, SolrParams params) throws SolrServerException {
|
||||
public SolrDocumentList getById(Collection<String> ids, SolrParams params) throws SolrServerException, IOException {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
throw new IllegalArgumentException("Must provide an identifier of a document to retrieve.");
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public abstract class SolrRequest<T extends SolrResponse> implements Serializabl
|
|||
* @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 {
|
||||
public final 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));
|
||||
|
|
|
@ -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.QueryResponse;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -83,26 +80,6 @@ public class QueryRequest extends SolrRequest<QueryResponse> {
|
|||
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;
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -65,7 +66,7 @@ public abstract class LargeVolumeTestBase extends SolrJettyTestBase
|
|||
log.info("done");
|
||||
}
|
||||
|
||||
private void query(int count) throws SolrServerException {
|
||||
private void query(int count) throws SolrServerException, IOException {
|
||||
SolrClient client = this.getSolrClient();
|
||||
SolrQuery query = new SolrQuery("*:*");
|
||||
QueryResponse response = client.query(query);
|
||||
|
|
|
@ -1441,7 +1441,7 @@ abstract public class SolrExampleTests extends SolrExampleTestsBase
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testQueryWithParams() throws SolrServerException {
|
||||
public void testQueryWithParams() throws SolrServerException, IOException {
|
||||
SolrClient client = getSolrClient();
|
||||
SolrQuery q = new SolrQuery("query");
|
||||
q.setParam("debug", true);
|
||||
|
|
|
@ -536,7 +536,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
}
|
||||
}
|
||||
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException {
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params) throws SolrServerException, IOException {
|
||||
// query a random server
|
||||
int which = r.nextInt(clients.size());
|
||||
SolrClient client = clients.get(which);
|
||||
|
@ -607,7 +607,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
if (verifyStress) {
|
||||
compareResponses(rsp, controlRsp);
|
||||
}
|
||||
} catch (SolrServerException e) {
|
||||
} catch (SolrServerException | IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -623,10 +623,10 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
|
|||
return rsp;
|
||||
}
|
||||
|
||||
public QueryResponse queryAndCompare(SolrParams params, SolrClient... clients) throws SolrServerException {
|
||||
public QueryResponse queryAndCompare(SolrParams params, SolrClient... clients) throws SolrServerException, IOException {
|
||||
return queryAndCompare(params, Arrays.<SolrClient>asList(clients));
|
||||
}
|
||||
public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients) throws SolrServerException {
|
||||
public QueryResponse queryAndCompare(SolrParams params, Iterable<SolrClient> clients) throws SolrServerException, IOException {
|
||||
QueryResponse first = null;
|
||||
for (SolrClient client : clients) {
|
||||
QueryResponse rsp = client.query(new ModifiableSolrParams(params));
|
||||
|
|
|
@ -1191,11 +1191,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
long num = cjetty.client.solrClient.query(query).getResults()
|
||||
.getNumFound();
|
||||
System.err.println("DOCS:" + num);
|
||||
} catch (SolrServerException e) {
|
||||
System.err.println("error contacting client: " + e.getMessage()
|
||||
+ "\n");
|
||||
continue;
|
||||
} catch (SolrException e) {
|
||||
} catch (SolrServerException | SolrException | IOException e) {
|
||||
System.err.println("error contacting client: " + e.getMessage()
|
||||
+ "\n");
|
||||
continue;
|
||||
|
@ -1401,7 +1397,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
|
||||
@Override
|
||||
protected QueryResponse queryServer(ModifiableSolrParams params)
|
||||
throws SolrServerException {
|
||||
throws SolrServerException, IOException {
|
||||
|
||||
if (r.nextBoolean()) params.set("collection", DEFAULT_COLLECTION);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -161,7 +162,7 @@ public class CloudInspectUtil {
|
|||
* @return true if the compared results are illegal.
|
||||
*/
|
||||
public static boolean compareResults(SolrClient controlClient, SolrClient cloudClient)
|
||||
throws SolrServerException {
|
||||
throws SolrServerException, IOException {
|
||||
return compareResults(controlClient, cloudClient, null, null);
|
||||
}
|
||||
|
||||
|
@ -171,7 +172,7 @@ public class CloudInspectUtil {
|
|||
* @return true if the compared results are illegal.
|
||||
*/
|
||||
public static boolean compareResults(SolrClient controlClient, SolrClient cloudClient, Set<String> addFails, Set<String> deleteFails)
|
||||
throws SolrServerException {
|
||||
throws SolrServerException, IOException {
|
||||
|
||||
SolrParams q = SolrTestCaseJ4.params("q","*:*","rows","0", "tests","checkShardConsistency(vsControl)"); // add a tag to aid in debugging via logs
|
||||
|
||||
|
|
Loading…
Reference in New Issue