Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16601: Remove Deprecated Methods from SolrClients (#1496)

Eric Pughdbab7359479c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index dc71eea41d7..8e89a1f8b34 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -27,7 +27,9 @@ Deprecation Removals
* SOLR-16535: The 'jaegertracer-configurator' module is removed. Please use 'opentelemetry' (janhoy)
-Dependency Upgrades
+* SOLR-16601: Removed deprecated methods on the various Solr Clients. (Eric Pugh, Kevin Risden)
+
+
---------------------
(No changes)
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
index 201747dbfd9..6bc3361a4cc 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
@@ -53,7 +54,9 @@ import org.apache.solr.common.cloud.ZkStateReader;
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.IOUtils;
import org.apache.solr.common.util.NamedList;
+import org.apache.solr.common.util.Pair;
import org.apache.solr.embedded.JettySolrRunner;
import org.apache.solr.response.transform.DocTransformer;
import org.apache.solr.response.transform.RawValueTransformerFactory;
@@ -76,8 +79,8 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
/** A collection specific client for operations at the cloud level */
private static CloudSolrClient COLLECTION_CLIENT;
- /** One client per node */
- private static final List<SolrClient> CLIENTS = Collections.synchronizedList(new ArrayList<>(5));
+ /** We have a map of clients using specific writerTypes, keyed by pair of baseurl and wt */
+ private static final Map<Pair<String, String>, SolrClient> CLIENTS = new ConcurrentHashMap<>();
/** Always included in fl, so we can check what doc we're looking at */
private static final FlValidator ID_VALIDATOR = new SimpleFieldValueValidator("id");
@@ -174,10 +177,6 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
.process(COLLECTION_CLIENT);
cluster.waitForActiveCollection(COLLECTION_NAME, numShards, repFactor * numShards);
-
- for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
- CLIENTS.add(getHttpSolrClient(jetty.getBaseUrl() + "/" + COLLECTION_NAME + "/"));
- }
}
@AfterClass
@@ -186,8 +185,8 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
COLLECTION_CLIENT.close();
COLLECTION_CLIENT = null;
}
- for (SolrClient client : CLIENTS) {
- client.close();
+ for (SolrClient client : CLIENTS.values()) {
+ IOUtils.closeQuietly(client);
}
CLIENTS.clear();
}
@@ -276,7 +275,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
final float threshold = (float) itersSinceLastCommit / numIters;
if (rand.nextFloat() < threshold) {
log.info("COMMIT");
- assertEquals(0, getRandClient(rand).commit().getStatus());
+ assertEquals(0, getRandomClient(rand).commit().getStatus());
return 0;
}
return itersSinceLastCommit + 1;
@@ -352,7 +351,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
assertEquals(
"Failed delete: " + Arrays.toString(docIds),
0,
- getRandClient(random()).deleteById(ids).getStatus());
+ getRandomClient(random()).deleteById(ids).getStatus());
}
/**
@@ -361,7 +360,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
*/
private SolrInputDocument addRandomDocument(final int docId)
throws IOException, SolrServerException {
- final SolrClient client = getRandClient(random());
+ final SolrClient client = getRandomClient(random());
final SolrInputDocument doc =
sdoc(
@@ -432,18 +431,21 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
}
};
- private static ResponseParser modifyParser(HttpSolrClient client, final String wt) {
- final ResponseParser ret = client.getParser();
+ /** Helper to convert from wt string parameter to actual SolrClient. */
+ private static SolrClient getSolrClient(final String jettyBaseUrl, final String wt) {
+ HttpSolrClient.Builder builder =
+ new HttpSolrClient.Builder(jettyBaseUrl + "/" + COLLECTION_NAME + "/");
switch (wt) {
case "xml":
- client.setParser(RAW_XML_RESPONSE_PARSER);
- return ret;
+ builder.withResponseParser(RAW_XML_RESPONSE_PARSER);
+ break;
case "json":
- client.setParser(RAW_JSON_RESPONSE_PARSER);
- return ret;
+ builder.withResponseParser(RAW_JSON_RESPONSE_PARSER);
+ break;
default:
- return null;
+ break;
}
+ return builder.build();
}
/**
@@ -452,7 +454,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
*/
private void assertRTG(final SolrInputDocument[] knownDocs, final int[] docIds)
throws IOException, SolrServerException {
- final SolrClient client = getRandClient(random());
+
// NOTE: not using SolrClient.getById or getByIds because we want to force choice of "id" vs
// "ids" params
final ModifiableSolrParams params = params("qt", "/get");
@@ -509,13 +511,12 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
}
String wt = params.get(CommonParams.WT, "javabin");
- final ResponseParser restoreResponseParser;
- if (client instanceof HttpSolrClient) {
- restoreResponseParser = modifyParser((HttpSolrClient) client, wt);
- } else {
- // unless HttpSolrClient, `wt` doesn't matter -- it'll always be binary.
+ final SolrClient client = getRandomClient(random(), wt);
+
+ // If we have chosen a CloudSolrClient, then override wt parameter back to javabin format,
+ // regardless of what was randomly picked.
+ if (client instanceof CloudSolrClient) {
wt = "javabin";
- restoreResponseParser = null;
}
final Object rsp;
@@ -528,8 +529,6 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
docs = getDocsFromRTGResponse(askForList, qRsp);
} else {
final NamedList<Object> nlRsp = client.request(new QueryRequest(params));
- assertNotNull(restoreResponseParser);
- ((HttpSolrClient) client).setParser(restoreResponseParser);
assertNotNull(params.toString(), nlRsp);
rsp = nlRsp;
final String textResult = (String) nlRsp.get("response");
@@ -635,12 +634,30 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
/**
* returns a random SolrClient -- either a CloudSolrClient, or an HttpSolrClient pointed at a node
- * in our cluster
+ * in our cluster. This method doesn't care which wt is defined.
*/
- public static SolrClient getRandClient(Random rand) {
- int numClients = CLIENTS.size();
+ public static SolrClient getRandomClient(Random rand) {
+ List<String> writerTypes = List.of("javabin", "json", "xml");
+ int writerTypeIdx = TestUtil.nextInt(rand, 0, writerTypes.size() - 1);
+ return getRandomClient(rand, writerTypes.get(writerTypeIdx));
+ }
+ /**
+ * returns a random SolrClient -- either a CloudSolrClient, or an HttpSolrClient pointed at a node
+ * in our cluster. We have different CLIENTS created for each node based on their wt setting.
+ */
+ public static SolrClient getRandomClient(Random rand, String wt) {
+ List<JettySolrRunner> jettySolrRunners = cluster.getJettySolrRunners();
+ int numClients = jettySolrRunners.size();
int idx = TestUtil.nextInt(rand, 0, numClients);
- return (idx == numClients) ? COLLECTION_CLIENT : CLIENTS.get(idx);
+ if (idx == numClients) {
+ // Return the CloudSolrClient, it only uses javabin writerType.
+ return COLLECTION_CLIENT;
+ } else {
+ JettySolrRunner jetty = jettySolrRunners.get(idx);
+ String jettyBaseUrl = jetty.getBaseUrl().toString();
+ return CLIENTS.computeIfAbsent(
+ new Pair<>(jettyBaseUrl, wt), k -> getSolrClient(k.first(), k.second()));
+ }
}
public static void waitForRecoveriesToFinish(CloudSolrClient client) throws Exception {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index 3308aa70dea..0af8df80a68 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -224,18 +224,6 @@ public abstract class CloudSolrClient extends SolrClient {
}
}
- /**
- * This is the time to wait to refetch the state after getting the same state version from ZK
- *
- * <p>secs
- *
- * @deprecated use {@link CloudSolrClient.Builder#setRetryExpiryTime(int)} instead
- */
- @Deprecated
- public void setRetryExpiryTime(int secs) {
- this.retryExpiryTimeNano = TimeUnit.NANOSECONDS.convert(secs, TimeUnit.SECONDS);
- }
-
protected final StateCache collectionStateCache = new StateCache();
class ExpiringCachedDocCollection {
@@ -279,18 +267,6 @@ public abstract class CloudSolrClient extends SolrClient {
this.requestRLTGenerator = new RequestReplicaListTransformerGenerator();
}
- /**
- * Sets the cache ttl for DocCollection Objects cached.
- *
- * @param seconds ttl value in seconds
- * @deprecated use {@link CloudSolrClient.Builder#withCollectionCacheTtl(int)} instead
- */
- @Deprecated
- public void setCollectionCacheTTl(int seconds) {
- assert seconds > 0;
- this.collectionStateCache.timeToLiveMs = seconds * 1000L;
- }
-
protected abstract LBSolrClient getLbClient();
public abstract ClusterStateProvider getClusterStateProvider();
@@ -313,45 +289,10 @@ public abstract class CloudSolrClient extends SolrClient {
return getLbClient().getParser();
}
- /**
- * Note: This setter method is <b>not thread-safe</b>.
- *
- * @param processor Default Response Parser chosen to parse the response if the parser were not
- * specified as part of the request.
- * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
- * @deprecated use {@link CloudHttp2SolrClient.Builder} instead
- */
- @Deprecated
- public void setParser(ResponseParser processor) {
- getLbClient().setParser(processor);
- }
-
public RequestWriter getRequestWriter() {
return getLbClient().getRequestWriter();
}
- /**
- * Choose the {@link RequestWriter} to use.
- *
- * <p>Note: This setter method is <b>not thread-safe</b>.
- *
- * @deprecated use {@link CloudHttp2SolrClient.Builder} instead
- */
- @Deprecated
- public void setRequestWriter(RequestWriter requestWriter) {
- getLbClient().setRequestWriter(requestWriter);
- }
-
- /**
- * Sets the default collection for request.
- *
- * @deprecated use {@link CloudHttp2SolrClient.Builder#withDefaultCollection(String)} instead
- */
- @Deprecated
- public void setDefaultCollection(String collection) {
- this.defaultCollection = collection;
- }
-
/** Gets the default collection for request */
public String getDefaultCollection() {
return defaultCollection;
@@ -1244,17 +1185,6 @@ public abstract class CloudSolrClient extends SolrClient {
return directUpdatesToLeadersOnly;
}
- /**
- * If caches are expired they are refreshed after acquiring a lock. use this to set the number of
- * locks
- *
- * @deprecated use {@link CloudHttp2SolrClient.Builder#setParallelCacheRefreshes(int)} instead
- */
- @Deprecated
- public void setParallelCacheRefreshes(int n) {
- locks = objectList(n);
- }
-
protected static Object[] objectList(int n) {
Object[] l = new Object[n];
for (int i = 0; i < n; i++) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
index ad9f50e54e7..69c54ba693a 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateHttp2SolrClient.java
@@ -159,14 +159,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
this.stallTimeMillis = minimalStallTimeMillis;
}
- if (stallTimeMillis < pollQueueTimeMillis * 2) {
- throw new RuntimeException(
- "Invalid stallTime: "
- + stallTimeMillis
- + "ms, must be 2x > pollQueueTime "
- + pollQueueTimeMillis);
- }
-
if (builder.executorService != null) {
this.scheduler = builder.executorService;
this.shutdownExecutor = false;
@@ -701,22 +693,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
}
}
- /**
- * @param pollQueueTimeMillis time for an open connection to wait for updates when the queue is
- * empty.
- * @deprecated use {@link ConcurrentUpdateHttp2SolrClient.Builder#setPollQueueTime(int)} instead
- */
- @Deprecated
- public void setPollQueueTime(int pollQueueTimeMillis) {
- this.pollQueueTimeMillis = pollQueueTimeMillis;
- // make sure the stall time is larger than the polling time
- // to give a chance for the queue to change
- int minimalStallTime = pollQueueTimeMillis * 2;
- if (minimalStallTime > this.stallTimeMillis) {
- this.stallTimeMillis = minimalStallTime;
- }
- }
-
/** Constructs {@link ConcurrentUpdateHttp2SolrClient} instances from provided configuration. */
public static class Builder {
protected Http2SolrClient client;
@@ -811,17 +787,6 @@ public class ConcurrentUpdateHttp2SolrClient extends SolrClient {
return this;
}
- /**
- * @param pollQueueTimeMillis time for an open connection to wait for updates when the queue is
- * empty.
- * @deprecated Please use {@link #setPollQueueTime(long, TimeUnit)}
- */
- @Deprecated(since = "9.2")
- public Builder setPollQueueTime(int pollQueueTimeMillis) {
- setPollQueueTime(pollQueueTimeMillis, TimeUnit.MILLISECONDS);
- return this;
- }
-
/**
* @param pollQueueTime time for an open connection to wait for updates when the queue is empty.
*/
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
index 8b8f908b4dc..fe7a5615d38 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ConcurrentUpdateSolrClient.java
@@ -37,11 +37,9 @@ import org.apache.http.NameValuePair;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentProducer;
import org.apache.http.entity.EntityTemplate;
-import org.apache.solr.client.solrj.ResponseParser;
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.request.RequestWriter;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.SolrException;
@@ -83,8 +81,8 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
volatile CountDownLatch lock = null; // used to block everything
final int threadCount;
boolean shutdownExecutor = false;
- int pollQueueTime = 250;
- int stallTime;
+ int pollQueueTimeMillis = 250;
+ int stallTimeMillis;
private final boolean streamDeletes;
private boolean internalHttpClient;
private volatile Integer connectionTimeout;
@@ -116,12 +114,15 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
this.streamDeletes = builder.streamDeletes;
this.connectionTimeout = Math.toIntExact(builder.connectionTimeoutMillis);
this.soTimeout = Math.toIntExact(builder.socketTimeoutMillis);
- this.stallTime = Integer.getInteger("solr.cloud.client.stallTime", 15000);
- if (stallTime < pollQueueTime * 2) {
- throw new RuntimeException(
- "Invalid stallTime: " + stallTime + "ms, must be 2x > pollQueueTime " + pollQueueTime);
+ this.pollQueueTimeMillis = builder.pollQueueTime;
+ this.stallTimeMillis = Integer.getInteger("solr.cloud.client.stallTime", 15000);
+
+ // make sure the stall time is larger than the polling time
+ // to give a chance for the queue to change
+ int minimalStallTime = pollQueueTimeMillis * 2;
+ if (minimalStallTime > this.stallTimeMillis) {
+ this.stallTimeMillis = minimalStallTime;
}
- this.setPollQueueTime(builder.pollQueueTime);
if (builder.executorService != null) {
this.scheduler = builder.executorService;
@@ -141,30 +142,10 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
- /**
- * @deprecated use {@link #getUrlParamNames()}
- */
- @Deprecated
- public Set<String> getQueryParams() {
- return getUrlParamNames();
- }
-
public Set<String> getUrlParamNames() {
return this.client.getUrlParamNames();
}
- /**
- * Expert Method.
- *
- * @param queryParams set of param keys to only send via the query string
- * @deprecated use {@link ConcurrentUpdateSolrClient.Builder#withTheseParamNamesInTheUrl(Set)}
- * instead
- */
- @Deprecated
- public void setQueryParams(Set<String> queryParams) {
- this.client.setQueryParams(queryParams);
- }
-
/** Opens a connection and sends everything... */
@SuppressWarnings({"unchecked"})
class Runner implements Runnable {
@@ -236,7 +217,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
notifyQueueAndRunnersIfEmptyQueue();
try {
inPoll = true;
- update = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
+ update = queue.poll(pollQueueTimeMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
if (log.isDebugEnabled()) pollInterrupts.incrementAndGet();
continue;
@@ -303,7 +284,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
try {
while (true) {
try {
- upd = queue.poll(pollQueueTime, TimeUnit.MILLISECONDS);
+ upd = queue.poll(pollQueueTimeMillis, TimeUnit.MILLISECONDS);
break;
} catch (InterruptedException e) {
if (log.isDebugEnabled()) pollInterrupts.incrementAndGet();
@@ -584,7 +565,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} else {
long currentStallTime =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
- if (currentStallTime > stallTime) {
+ if (currentStallTime > stallTimeMillis) {
throw new IOException(
"Request processing has stalled for "
+ currentStallTime
@@ -645,7 +626,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
} else {
long currentStallTime =
TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
- if (currentStallTime > stallTime) {
+ if (currentStallTime > stallTimeMillis) {
throw new IOException(
"Task queue processing has stalled for "
+ currentStallTime
@@ -740,7 +721,7 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
lastStallTime = System.nanoTime();
} else {
long currentStallTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - lastStallTime);
- if (currentStallTime > stallTime) {
+ if (currentStallTime > stallTimeMillis) {
throw new IOException(
"Task queue processing has stalled for "
+ currentStallTime
@@ -841,30 +822,6 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
- @Deprecated
- public void setParser(ResponseParser responseParser) {
- client.setParser(responseParser);
- }
-
- /**
- * @param pollQueueTime time for an open connection to wait for updates when the queue is empty.
- */
- @Deprecated
- public void setPollQueueTime(int pollQueueTime) {
- this.pollQueueTime = pollQueueTime;
- // make sure the stall time is larger than the polling time
- // to give a chance for the queue to change
- int minimalStallTime = pollQueueTime * 2;
- if (minimalStallTime > this.stallTime) {
- this.stallTime = minimalStallTime;
- }
- }
-
- @Deprecated
- public void setRequestWriter(RequestWriter requestWriter) {
- client.setRequestWriter(requestWriter);
- }
-
/** Constructs {@link ConcurrentUpdateSolrClient} instances from provided configuration. */
public static class Builder extends SolrClientBuilder<Builder> {
protected String baseSolrUrl;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
index 02f5ba2ece8..8aad9ee6ef8 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/DelegationTokenHttpSolrClient.java
@@ -17,9 +17,6 @@
package org.apache.solr.client.solrj.impl;
import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.solr.client.solrj.SolrRequest;
import org.apache.solr.client.solrj.SolrServerException;
@@ -46,16 +43,4 @@ public class DelegationTokenHttpSolrClient extends HttpSolrClient {
}
return super.createMethod(request, collection);
}
-
- @Deprecated
- @Override
- public void setQueryParams(Set<String> urlParamNames) {
- urlParamNames = urlParamNames == null ? Set.of(DELEGATION_TOKEN_PARAM) : urlParamNames;
- if (!urlParamNames.contains(DELEGATION_TOKEN_PARAM)) {
- urlParamNames = new HashSet<>(urlParamNames);
- urlParamNames.add(DELEGATION_TOKEN_PARAM);
- urlParamNames = Collections.unmodifiableSet(urlParamNames);
- }
- super.setQueryParams(urlParamNames);
- }
}
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
index 328ab695a22..0e0b81f3dc9 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpSolrClient.java
@@ -74,7 +74,6 @@ import org.apache.http.entity.mime.content.StringBody;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;
import org.apache.solr.client.solrj.ResponseParser;
-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.V2RequestSupport;
@@ -191,35 +190,10 @@ public class HttpSolrClient extends BaseHttpSolrClient {
this.urlParamNames = builder.urlParamNames;
}
- /**
- * @deprecated use {@link #getUrlParamNames()}
- */
- @Deprecated
- public Set<String> getQueryParams() {
- return getUrlParamNames();
- }
-
public Set<String> getUrlParamNames() {
return urlParamNames;
}
- /**
- * Expert Method
- *
- * @param urlParamNames set of param keys to only send via the query string Note that the param
- * will be sent as a query string if the key is part of this Set or the SolrRequest's query
- * params.
- * <p>{@link SolrClient} setters can be unsafe when the involved {@link SolrClient} is used in
- * multiple threads simultaneously. To avoid this, use {@link
- * Builder#withTheseParamNamesInTheUrl(Set)}.
- * @see org.apache.solr.client.solrj.SolrRequest#getQueryParams
- * @deprecated use {@link Builder#withTheseParamNamesInTheUrl(Set)} instead
- */
- @Deprecated
- public void setQueryParams(Set<String> urlParamNames) {
- this.urlParamNames = urlParamNames;
- }
-
/**
* Process the request. If {@link org.apache.solr.client.solrj.SolrRequest#getResponseParser()} is
* null, then use {@link #getParser()}
@@ -812,91 +786,15 @@ public class HttpSolrClient extends BaseHttpSolrClient {
return baseUrl;
}
- /**
- * Change the base-url used when sending requests to Solr.
- *
- * <p>Two different paths can be specified as a part of this URL:
- *
- * <p>1) A path pointing directly at a particular core
- *
- * <pre>
- * httpSolrClient.setBaseURL("http://my-solr-server:8983/solr/core1");
- * QueryResponse resp = httpSolrClient.query(new SolrQuery("*:*"));
- * </pre>
- *
- * Note that when a core is provided in the base URL, queries and other requests can be made
- * without mentioning the core explicitly. However, the client can only send requests to that
- * core.
- *
- * <p>2) The path of the root Solr path ("/solr")
- *
- * <pre>
- * httpSolrClient.setBaseURL("http://my-solr-server:8983/solr");
- * QueryResponse resp = httpSolrClient.query("core1", new SolrQuery("*:*"));
- * </pre>
- *
- * In this case the client is more flexible and can be used to send requests to any cores. The
- * cost of this is that the core must be specified on each request.
- *
- * <p>{@link SolrClient} setters can be unsafe when the involved {@link SolrClient} is used in
- * multiple threads simultaneously.
- *
- * @deprecated use {@link Builder} instead
- */
- @Deprecated
- public void setBaseURL(String baseUrl) {
- this.baseUrl = baseUrl;
- }
-
public ResponseParser getParser() {
return parser;
}
- /**
- * Note: This setter method is <b>not thread-safe</b>.
- *
- * @param parser Default Response Parser chosen to parse the response if the parser were not
- * specified as part of the request.
- * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
- * @deprecated use {@link Builder#withResponseParser(ResponseParser)} instead
- */
- @Deprecated
- public void setParser(ResponseParser parser) {
- this.parser = parser;
- }
-
/** Return the HttpClient this instance uses. */
public HttpClient getHttpClient() {
return httpClient;
}
- /**
- * Configure whether the client should follow redirects or not.
- *
- * <p>This defaults to false under the assumption that if you are following a redirect to get to a
- * Solr installation, something is configured wrong somewhere.
- *
- * @deprecated use {@link Builder#withFollowRedirects(boolean)} Redirects(boolean)} instead
- */
- @Deprecated
- public void setFollowRedirects(boolean followRedirects) {
- this.followRedirects = followRedirects;
- }
-
- /**
- * Choose the {@link RequestWriter} to use.
- *
- * <p>By default, {@link BinaryRequestWriter} is used.
- *
- * <p>Note: This setter method is <b>not thread-safe</b>.
- *
- * @deprecated use {@link Builder#withRequestWriter(RequestWriter)} instead
- */
- @Deprecated
- public void setRequestWriter(RequestWriter requestWriter) {
- this.requestWriter = requestWriter;
- }
-
/** Close the {@link HttpClientConnectionManager} from the internal client. */
@Override
public void close() throws IOException {
@@ -909,18 +807,6 @@ public class HttpSolrClient extends BaseHttpSolrClient {
return useMultiPartPost;
}
- /**
- * Set the multipart connection properties
- *
- * <p>Note: This setter method is <b>not thread-safe</b>.
- *
- * @deprecated use {@link Builder#allowMultiPartPost(Boolean)} instead
- */
- @Deprecated
- public void setUseMultiPartPost(boolean useMultiPartPost) {
- this.useMultiPartPost = useMultiPartPost;
- }
-
/**
* Constructs {@link HttpSolrClient} instances from provided configuration.
*
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
index c652dd9761b..18b89440568 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java
@@ -23,7 +23,6 @@ import java.net.ConnectException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -72,7 +71,8 @@ import org.slf4j.MDC;
*
* This detects if a dead server comes alive automatically. The check is done in fixed intervals in
* a dedicated thread. This interval can be set using {@link
- * LBHttp2SolrClient.Builder#setAliveCheckInterval(int)} , the default is set to one minute.
+ * LBHttp2SolrClient.Builder#setAliveCheckInterval(int, TimeUnit)} , the default is set to one
+ * minute.
*
* <p><b>When to use this?</b><br>
* This can be used as a software load balancer when you do not wish to set up an external load
@@ -86,15 +86,6 @@ import org.slf4j.MDC;
public class LBHttp2SolrClient extends LBSolrClient {
private final Http2SolrClient solrClient;
- /**
- * @deprecated Use {@link LBHttp2SolrClient.Builder} instead
- */
- @Deprecated
- public LBHttp2SolrClient(Http2SolrClient solrClient, String... baseSolrUrls) {
- super(Arrays.asList(baseSolrUrls));
- this.solrClient = solrClient;
- }
-
private LBHttp2SolrClient(Http2SolrClient solrClient, List<String> baseSolrUrls) {
super(baseSolrUrls);
this.solrClient = solrClient;
@@ -105,42 +96,11 @@ public class LBHttp2SolrClient extends LBSolrClient {
return solrClient;
}
- /**
- * Note: This setter method is <b>not thread-safe</b>.
- *
- * @param parser Default Response Parser chosen to parse the response if the parser were not
- * specified as part of the request.
- * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
- * @deprecated Pass in a configured {@link Http2SolrClient} instead
- */
- @Deprecated
- @Override
- public void setParser(ResponseParser parser) {
- super.setParser(parser);
- this.solrClient.setParser(parser);
- }
-
@Override
public ResponseParser getParser() {
return solrClient.getParser();
}
- /**
- * Choose the {@link RequestWriter} to use.
- *
- * <p>By default, {@link BinaryRequestWriter} is used.
- *
- * <p>Note: This setter method is <b>not thread-safe</b>.
- *
- * @deprecated Pass in a configured {@link Http2SolrClient} instead
- */
- @Deprecated
- @Override
- public void setRequestWriter(RequestWriter writer) {
- super.setRequestWriter(writer);
- this.solrClient.setRequestWriter(writer);
- }
-
@Override
public RequestWriter getRequestWriter() {
return solrClient.getRequestWriter();
@@ -150,27 +110,6 @@ public class LBHttp2SolrClient extends LBSolrClient {
return solrClient.getUrlParamNames();
}
- /**
- * @deprecated You should instead set this on the passed in Http2SolrClient used by the Builder.
- */
- @Deprecated
- public void setQueryParams(Set<String> queryParams) {
- this.solrClient.setUrlParamNames(queryParams);
- }
-
- /**
- * This method should be removed as being able to add a query parameter isn't compatible with the
- * idea that query params are an immutable property of a solr client.
- *
- * @deprecated you should instead set this on the passed in Http2SolrClient used by the Builder.
- */
- @Deprecated
- public void addQueryParams(String queryOnlyParam) {
- Set<String> urlParamNames = new HashSet<>(this.solrClient.getUrlParamNames());
- urlParamNames.add(queryOnlyParam);
- this.solrClient.setUrlParamNames(urlParamNames);
- }
-
public Cancellable asyncReq(Req req, AsyncListener<Rsp> asyncListener) {
Rsp rsp = new Rsp();
boolean isNonRetryable =
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
index a7553f3fc5d..f1e6d6ace0e 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java
@@ -183,26 +183,6 @@ public class LBHttpSolrClient extends LBSolrClient {
return httpClient;
}
- @Deprecated
- public Set<String> getQueryParams() {
- return urlParamNames;
- }
-
- /**
- * Expert Method.
- *
- * @param urlParamNames set of param keys to only send via the query string
- */
- @Deprecated
- public void setQueryParams(Set<String> urlParamNames) {
- this.urlParamNames = urlParamNames;
- }
-
- @Deprecated
- public void addQueryParams(String urlParamNames) {
- this.urlParamNames.add(urlParamNames);
- }
-
/** Constructs {@link LBHttpSolrClient} instances from provided configuration. */
public static class Builder extends SolrClientBuilder<Builder> {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
index d3db7429f44..d3b5b31412f 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBSolrClient.java
@@ -439,24 +439,6 @@ public abstract class LBSolrClient extends SolrClient {
return e;
}
- /**
- * LBHttpSolrServer keeps pinging the dead servers at fixed interval to find if it is alive. Use
- * this to set that interval
- *
- * @param aliveCheckIntervalMillis time in milliseconds
- * @deprecated use {@link LBHttpSolrClient.Builder#setAliveCheckInterval(int)} instead
- */
- @Deprecated
- public void setAliveCheckInterval(int aliveCheckIntervalMillis) {
- if (aliveCheckIntervalMillis <= 0) {
- throw new IllegalArgumentException(
- "Alive check interval must be "
- + "positive, specified value = "
- + aliveCheckIntervalMillis);
- }
- this.aliveCheckIntervalMillis = aliveCheckIntervalMillis;
- }
-
private void startAliveCheckExecutor() {
// double-checked locking, but it's OK because we don't *do* anything with aliveCheckExecutor
// if it's not null.
@@ -491,30 +473,6 @@ public abstract class LBSolrClient extends SolrClient {
return parser;
}
- /**
- * Changes the {@link ResponseParser} that will be used for the internal SolrServer objects.
- *
- * @param parser Default Response Parser chosen to parse the response if the parser were not
- * specified as part of the request.
- * @see org.apache.solr.client.solrj.SolrRequest#getResponseParser()
- * @deprecated Pass in a configured {@link SolrClient} instead
- */
- @Deprecated
- public void setParser(ResponseParser parser) {
- this.parser = parser;
- }
-
- /**
- * Changes the {@link RequestWriter} that will be used for the internal SolrServer objects.
- *
- * @param requestWriter Default RequestWriter, used to encode requests sent to the server.
- * @deprecated Pass in a configured {@link SolrClient} instead
- */
- @Deprecated
- public void setRequestWriter(RequestWriter requestWriter) {
- this.requestWriter = requestWriter;
- }
-
public RequestWriter getRequestWriter() {
return requestWriter;
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
index 79a22c29e6c..0d5c4441ecb 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/BasicHttpSolrClientTest.java
@@ -763,7 +763,7 @@ public class BasicHttpSolrClientTest extends SolrJettyTestBase {
if (values != null) {
for (String value : values) {
boolean shouldBeInQueryString =
- client.getQueryParams().contains(name)
+ client.getUrlParamNames().contains(name)
|| (request.getQueryParams() != null && request.getQueryParams().contains(name));
assertEquals(
shouldBeInQueryString, DebugServlet.queryString.contains(name + "=" + value));
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java
index 8e1018a66b6..78f3251ff62 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttp2SolrClientTest.java
@@ -28,12 +28,9 @@ public class LBHttp2SolrClientTest extends SolrTestCase {
* Test method for {@link LBHttp2SolrClient.Builder} that validates that the query param keys
* passed in by the base <code>Http2SolrClient
* </code> instance are used by the LBHttp2SolrClient.
- *
- * <p>TODO: Eliminate the addQueryParams aspect of test as it is not compatible with goal of
- * immutable SolrClient
*/
@Test
- public void testLBHttp2SolrClientSetQueryParams() {
+ public void testLBHttp2SolrClientWithTheseParamNamesInTheUrl() {
String url = "http://127.0.0.1:8080";
Set<String> urlParamNames = new HashSet<>(2);
urlParamNames.add("param1");
@@ -51,17 +48,6 @@ public class LBHttp2SolrClientTest extends SolrTestCase {
"Wrong urlParamNames found in base client.",
urlParamNames.toArray(),
http2SolrClient.getUrlParamNames().toArray());
-
- testClient.addQueryParams("param2");
- urlParamNames.add("param2");
- assertArrayEquals(
- "Wrong urlParamNames found in lb client.",
- urlParamNames.toArray(),
- testClient.getUrlParamNames().toArray());
- assertArrayEquals(
- "Wrong urlParamNames found in base client.",
- urlParamNames.toArray(),
- http2SolrClient.getUrlParamNames().toArray());
}
}
}