Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15608: Remove deprecated methods, classes and constructors from SolrJ (#369)

Jan Høydahl291068d18a93
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 1ab2c0ec22e..0d07c98214a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -162,6 +162,8 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)
* SOLR-15278: Add V2 equivalent to allow deleting async collection list of statuses. (Eric Pugh)
+* SOLR-15608: Remove deprecated methods, classes and constructors from solrj clients (janhoy)
+
Build
---------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index cd5b1548bf6..432739c207a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -36,7 +36,6 @@ import org.apache.solr.client.solrj.impl.HttpSolrClient.HttpUriRequestResponse;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.CoreAdminRequest.WaitForState;
import org.apache.solr.client.solrj.request.UpdateRequest;
-import org.apache.solr.client.solrj.response.SolrPingResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.cloud.DocCollection;
@@ -174,7 +173,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
}
/** Builds a new HttpSolrClient for use in recovery. Caller must close */
- private final HttpSolrClient buildRecoverySolrClient(final String leaderUrl) {
+ private final HttpSolrClient.Builder recoverySolrClientBuilder(final String leaderUrl) {
// workaround for SOLR-13605: get the configured timeouts & set them directly
// (even though getRecoveryOnlyHttpClient() already has them set)
final UpdateShardHandlerConfig cfg = cc.getConfig().getUpdateShardHandlerConfig();
@@ -182,7 +181,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
.withConnectionTimeout(cfg.getDistributedConnectionTimeout())
.withSocketTimeout(cfg.getDistributedSocketTimeout())
.withHttpClient(cc.getUpdateShardHandler().getRecoveryOnlyHttpClient())
- ).build();
+ );
}
// make sure any threads stop retrying
@@ -279,7 +278,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
final private void commitOnLeader(String leaderUrl) throws SolrServerException,
IOException {
- try (HttpSolrClient client = buildRecoverySolrClient(leaderUrl)) {
+ try (HttpSolrClient client = recoverySolrClientBuilder(leaderUrl).build()) {
UpdateRequest ureq = new UpdateRequest();
ureq.setParams(new ModifiableSolrParams());
// ureq.getParams().set(DistributedUpdateProcessor.COMMIT_END_POINT, true);
@@ -768,8 +767,8 @@ public class RecoveryStrategy implements Runnable, Closeable {
return leaderReplica;
}
- try (HttpSolrClient httpSolrClient = buildRecoverySolrClient(leaderReplica.getCoreUrl())) {
- SolrPingResponse resp = httpSolrClient.ping();
+ try (HttpSolrClient httpSolrClient = recoverySolrClientBuilder(leaderReplica.getCoreUrl()).build()) {
+ httpSolrClient.ping();
return leaderReplica;
} catch (IOException e) {
log.error("Failed to connect leader {} on recovery, try again", leaderReplica.getBaseUrl());
@@ -864,8 +863,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
int conflictWaitMs = zkController.getLeaderConflictResolveWait();
// timeout after 5 seconds more than the max timeout (conflictWait + 3 seconds) on the server side
int readTimeout = conflictWaitMs + Integer.parseInt(System.getProperty("prepRecoveryReadTimeoutExtraWait", "8000"));
- try (HttpSolrClient client = buildRecoverySolrClient(leaderBaseUrl)) {
- client.setSoTimeout(readTimeout);
+ try (HttpSolrClient client = recoverySolrClientBuilder(leaderBaseUrl).withSocketTimeout(readTimeout).build()) {
HttpUriRequestResponse mrr = client.httpUriRequest(prepCmd);
prevSendPreRecoveryHttpUriRequest = mrr.httpUriRequest;
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
index f19928b7de4..3a5049b3c4b 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/BaseCloudSolrClient.java
@@ -108,10 +108,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory(
"CloudSolrClient ThreadPool"));
- // We can figure this out from the collection,
- // there's no need to let this get out of sync.
- @Deprecated(since = "8.7")
- private String routeFieldDeprecated = null;
public static final String STATE_VERSION = "_stateVer_";
private long retryExpiryTime = TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS);//3 seconds or 3 million nanos
private final Set<String> NON_ROUTABLE_PARAMS;
@@ -293,28 +289,6 @@ public abstract class BaseCloudSolrClient extends SolrClient {
throw new IllegalStateException("This has no Zk stateReader");
}
- /**
- * @param routeField the field to route documents on.
- * <p>
- * deprecated, the field is automatically determined from Zookeeper
- */
- @Deprecated(since = "8.7")
- public void setIdField(String routeField) {
- log.warn("setIdField is deprecated, route field inferred from cluster state");
- this.routeFieldDeprecated = routeField;
- }
-
- /**
- * @return the field that updates are routed on.
- *
- * deprecated, the field is automatically determined from Zookeeper
- */
- @Deprecated (since = "8.7")
- public String getIdField() {
- log.warn("getIdField is deprecated, route field is in cluster state");
- return routeFieldDeprecated;
- }
-
/** Sets the default collection for request */
public void setDefaultCollection(String collection) {
this.defaultCollection = collection;
@@ -522,8 +496,7 @@ public abstract class BaseCloudSolrClient extends SolrClient {
//The value is a list of URLs for each replica in the slice.
//The first value in the list is the leader for the slice.
final Map<String, List<String>> urlMap = buildUrlMap(col, replicaListTransformer);
- String routeField = (routeFieldDeprecated != null) ? routeFieldDeprecated :
- (col.getRouter().getRouteField(col) == null) ? ID : col.getRouter().getRouteField(col);
+ String routeField = (col.getRouter().getRouteField(col) == null) ? ID : col.getRouter().getRouteField(col);
final Map<String, ? extends LBSolrClient.Req> routes = createRoutes(updateRequest, routableParams, col, router, urlMap, routeField);
if (routes == null) {
if (directUpdatesToLeadersOnly && hasInfoToFindLeaders(updateRequest, routeField)) {
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
index 3de79ca9e39..7214956b732 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
@@ -32,10 +32,6 @@ import org.apache.solr.common.SolrException;
* Solr endpoints for SolrCloud collections, and then use the
* {@link LBHttp2SolrClient} to issue requests.
*
- * This class assumes the id field for your documents is called
- * 'id' - if this is not the case, you must set the right name
- * with {@link #setIdField(String)}.
- *
* @lucene.experimental
* @since solr 8.0
*/
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 e5d1a342d30..ab51b8d2692 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
@@ -38,10 +38,6 @@ import org.apache.solr.common.util.NamedList;
* Instances of this class communicate with Zookeeper to discover
* Solr endpoints for SolrCloud collections, and then use the
* {@link LBHttpSolrClient} to issue requests.
- *
- * This class assumes the id field for your documents is called
- * 'id' - if this is not the case, you must set the right name
- * with {@link #setIdField(String)}.
*/
public class CloudSolrClient extends BaseCloudSolrClient {
@@ -53,14 +49,6 @@ public class CloudSolrClient extends BaseCloudSolrClient {
public static final String STATE_VERSION = BaseCloudSolrClient.STATE_VERSION;
- /**
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setSoTimeout(int timeout) {
- lbClient.setSoTimeout(timeout);
- }
-
/**
* Create a new client object that connects to Zookeeper and is always aware
* of the SolrCloud state. If there is a fully redundant Zookeeper quorum and
@@ -114,49 +102,16 @@ public class CloudSolrClient extends BaseCloudSolrClient {
}
}
- protected Map<String, LBHttpSolrClient.Req> createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams,
+ protected Map<String, LBSolrClient.Req> createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams,
DocCollection col, DocRouter router, Map<String, List<String>> urlMap,
String idField) {
- return urlMap == null ? null : updateRequest.getRoutes(router, col, urlMap, routableParams, idField);
+ return urlMap == null ? null : updateRequest.getRoutesToCollection(router, col, urlMap, routableParams, idField);
}
protected RouteException getRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String, ? extends LBSolrClient.Req> routes) {
return new RouteException(serverError, exceptions, routes);
}
- /** @deprecated since 7.2 Use {@link Builder} methods instead. */
- @Deprecated
- public void setParallelUpdates(boolean parallelUpdates) {
- this.parallelUpdates = parallelUpdates;
- }
-
- /**
- * @deprecated since Solr 8.0
- */
- @Deprecated
- public RouteResponse condenseResponse(NamedList<?> response, int timeMillis) {
- return condenseResponse(response, timeMillis, RouteResponse::new);
- }
-
- /**
- * @deprecated since Solr 8.0
- */
- @Deprecated
- public static class RouteResponse extends BaseCloudSolrClient.RouteResponse<LBHttpSolrClient.Req> {
-
- }
-
- /**
- * @deprecated since Solr 8.0
- */
- @Deprecated
- public static class RouteException extends BaseCloudSolrClient.RouteException {
-
- public RouteException(ErrorCode errorCode, NamedList<Throwable> throwables, Map<String, ? extends LBSolrClient.Req> routes) {
- super(errorCode, throwables, routes);
- }
- }
-
@Override
public void close() throws IOException {
stateProvider.close();
@@ -180,14 +135,6 @@ public class CloudSolrClient extends BaseCloudSolrClient {
return myClient;
}
- /**
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setConnectionTimeout(int timeout) {
- this.lbClient.setConnectionTimeout(timeout);
- }
-
public ClusterStateProvider getClusterStateProvider(){
return stateProvider;
}
@@ -229,11 +176,10 @@ public class CloudSolrClient extends BaseCloudSolrClient {
protected ClusterStateProvider stateProvider;
/**
- * @deprecated use other constructors instead. This constructor will be changing visibility in an upcoming release.
+ * Constructor for use by subclasses. This constructor was public prior to version 9.0
*/
- @Deprecated
- public Builder() {}
-
+ protected Builder() {}
+
/**
* Provide a series of Solr URLs to be used when configuring {@link CloudSolrClient} instances.
* The solr client will use these urls to understand the cluster topology, which solr nodes are active etc.
@@ -287,56 +233,6 @@ public class CloudSolrClient extends BaseCloudSolrClient {
if (zkChroot.isPresent()) this.zkChroot = zkChroot.get();
}
- /**
- * Provide a ZooKeeper client endpoint to be used when configuring {@link CloudSolrClient} instances.
- *
- * Method may be called multiple times. All provided values will be used.
- *
- * @param zkHost
- * The client endpoint of the ZooKeeper quorum containing the cloud
- * state.
- *
- * @deprecated use Zk-host constructor instead
- */
- @Deprecated
- public Builder withZkHost(String zkHost) {
- this.zkHosts.add(zkHost);
- return this;
- }
-
- /**
- * Provide a Solr URL to be used when configuring {@link CloudSolrClient} instances.
- *
- * Method may be called multiple times. One of the provided values will be used to fetch
- * the list of live Solr nodes that the underlying {@link HttpClusterStateProvider} would be maintaining.
- *
- * Provided Solr URL is expected to point to the root Solr path ("http://hostname:8983/solr"); it should not
- * include any collections, cores, or other path components.
- *
- * @deprecated use Solr-URL constructor instead
- */
- @Deprecated
- public Builder withSolrUrl(String solrUrl) {
- this.solrUrls.add(solrUrl);
- return this;
- }
-
- /**
- * Provide a list of Solr URL to be used when configuring {@link CloudSolrClient} instances.
- * One of the provided values will be used to fetch the list of live Solr
- * nodes that the underlying {@link HttpClusterStateProvider} would be maintaining.
- *
- * Provided Solr URLs are expected to point to the root Solr path ("http://hostname:8983/solr"); they should not
- * include any collections, cores, or other path components.
- *
- * @deprecated use Solr URL constructors instead
- */
- @Deprecated
- public Builder withSolrUrl(Collection<String> solrUrls) {
- this.solrUrls.addAll(solrUrls);
- return this;
- }
-
/**
* Provides a {@link HttpClient} for the builder to use when creating clients.
*/
@@ -345,36 +241,6 @@ public class CloudSolrClient extends BaseCloudSolrClient {
return this;
}
- /**
- * Provide a series of ZooKeeper client endpoints for the builder to use when creating clients.
- *
- * Method may be called multiple times. All provided values will be used.
- *
- * @param zkHosts
- * A Java Collection (List, Set, etc) of HOST:PORT strings, one for
- * each host in the ZooKeeper ensemble. Note that with certain
- * Collection types like HashSet, the order of hosts in the final
- * connect string may not be in the same order you added them.
- *
- * @deprecated use Zk-host constructor instead
- */
- @Deprecated
- public Builder withZkHost(Collection<String> zkHosts) {
- this.zkHosts.addAll(zkHosts);
- return this;
- }
-
- /**
- * Provides a ZooKeeper chroot for the builder to use when creating clients.
- *
- * @deprecated use Zk-host constructor instead
- */
- @Deprecated
- public Builder withZkChroot(String zkChroot) {
- this.zkChroot = zkChroot;
- return this;
- }
-
/**
* Provides a {@link LBHttpSolrClient} for the builder to use when creating clients.
*/
@@ -437,19 +303,6 @@ public class CloudSolrClient extends BaseCloudSolrClient {
return this;
}
- /**
- * Expert feature where you want to implement a custom cluster discovery mechanism of the solr nodes as part of the
- * cluster.
- *
- * @deprecated since this is an expert feature we don't want to expose this to regular users. To use this feature
- * extend CloudSolrClient.Builder and pass your custom ClusterStateProvider
- */
- @Deprecated
- public Builder withClusterStateProvider(ClusterStateProvider stateProvider) {
- this.stateProvider = stateProvider;
- return this;
- }
-
/**
* Create a {@link CloudSolrClient} based on the provided configuration.
*/
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 94bd8671074..b9ac1d5e534 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
@@ -16,26 +16,9 @@
*/
package org.apache.solr.client.solrj.impl;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.invoke.MethodHandles;
-import java.nio.charset.StandardCharsets;
-import java.util.LinkedList;
-import java.util.Locale;
-import java.util.Queue;
-import java.util.Set;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentProducer;
import org.apache.http.entity.EntityTemplate;
@@ -61,6 +44,22 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.invoke.MethodHandles;
+import java.nio.charset.StandardCharsets;
+import java.util.LinkedList;
+import java.util.Locale;
+import java.util.Queue;
+import java.util.Set;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
/**
* ConcurrentUpdateSolrClient buffers all added documents and writes
* them into open HTTP connections. This class is thread safe.
@@ -98,29 +97,9 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
AtomicInteger emptyQueueLoops;
/**
+ * Use builder to construct this class.
* Uses the supplied HttpClient to send documents to the Solr server.
- *
- * @deprecated use {@link ConcurrentUpdateSolrClient#ConcurrentUpdateSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative
*/
- @Deprecated
- protected ConcurrentUpdateSolrClient(String solrServerUrl,
- HttpClient client, int queueSize, int threadCount,
- ExecutorService es, boolean streamDeletes) {
- this((streamDeletes) ?
- new Builder(solrServerUrl)
- .withHttpClient(client)
- .withQueueSize(queueSize)
- .withThreadCount(threadCount)
- .withExecutorService(es)
- .alwaysStreamDeletes() :
- new Builder(solrServerUrl)
- .withHttpClient(client)
- .withQueueSize(queueSize)
- .withThreadCount(threadCount)
- .withExecutorService(es)
- .neverStreamDeletes());
- }
-
protected ConcurrentUpdateSolrClient(Builder builder) {
this.internalHttpClient = (builder.httpClient == null);
this.client = new HttpSolrClient.Builder(builder.baseSolrUrl)
@@ -777,25 +756,6 @@ public class ConcurrentUpdateSolrClient extends SolrClient {
}
}
- /**
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setConnectionTimeout(int timeout) {
- this.connectionTimeout = timeout;
- }
-
- /**
- * set soTimeout (read timeout) on the underlying HttpConnectionManager. This is desirable for queries, but probably
- * not for indexing.
- *
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setSoTimeout(int timeout) {
- this.soTimeout = timeout;
- }
-
public void shutdownNow() {
if (closed) {
return;
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 91021fc1653..b082810a4b3 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
@@ -16,6 +16,11 @@
*/
package org.apache.solr.client.solrj.impl;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.solr.client.solrj.SolrRequest;
+import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.common.params.SolrParams;
+
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
@@ -23,70 +28,19 @@ import java.util.HashSet;
import java.util.Set;
import java.util.TreeSet;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.solr.client.solrj.ResponseParser;
-import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.params.SolrParams;
-
public class DelegationTokenHttpSolrClient extends HttpSolrClient {
public final static String DELEGATION_TOKEN_PARAM = "delegation";
/**
- * Package protected constructor for use by
+ * Constructor for use by
* {@linkplain org.apache.solr.client.solrj.impl.HttpSolrClient.Builder}.
* @lucene.internal
- *
- * @deprecated use {@link DelegationTokenHttpSolrClient#DelegationTokenHttpSolrClient(HttpSolrClient.Builder)} instead, as it is a more
- * extension/subclassing-friendly alternative
*/
- @Deprecated
- DelegationTokenHttpSolrClient(String baseURL,
- HttpClient client,
- ResponseParser parser,
- boolean allowCompression,
- String delegationToken) {
- super(baseURL, client, parser, allowCompression);
- if (delegationToken == null) {
- throw new IllegalArgumentException("Delegation token cannot be null");
- }
- setQueryParams(new TreeSet<>(Arrays.asList(DELEGATION_TOKEN_PARAM)));
- invariantParams = new ModifiableSolrParams();
- invariantParams.set(DELEGATION_TOKEN_PARAM, delegationToken);
- }
-
protected DelegationTokenHttpSolrClient(Builder builder) {
super(builder);
setQueryParams(new TreeSet<>(Arrays.asList(DELEGATION_TOKEN_PARAM)));
}
- /**
- * This constructor is defined at "protected" scope. Ideally applications should
- * use {@linkplain org.apache.solr.client.solrj.impl.HttpSolrClient.Builder} instance
- * to configure this Solr client instance.
- *
- * @param baseURL The base url to communicate with the Solr server
- * @param client Http client instance to use for communication
- * @param parser Response parser instance to use to decode response from Solr server
- * @param allowCompression Should compression be allowed ?
- * @param invariantParams The parameters which should be passed with every request.
- *
- * @deprecated use {@link DelegationTokenHttpSolrClient#DelegationTokenHttpSolrClient(HttpSolrClient.Builder)} instead, as it is a more
- * extension/subclassing-friendly alternative
- */
- @Deprecated
- protected DelegationTokenHttpSolrClient(String baseURL,
- HttpClient client,
- ResponseParser parser,
- boolean allowCompression,
- ModifiableSolrParams invariantParams) {
- super(baseURL, client, parser, allowCompression, invariantParams);
-
- setQueryParams(new TreeSet<>(Arrays.asList(DELEGATION_TOKEN_PARAM)));
- }
-
@Override
protected HttpRequestBase createMethod(final SolrRequest<?> request, String collection) throws IOException, SolrServerException {
SolrParams params = request.getParams();
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java
index 07fd8f826ba..1d7c57ffa44 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/HttpClusterStateProvider.java
@@ -22,6 +22,9 @@ import java.util.List;
import org.apache.http.client.HttpClient;
import org.apache.solr.client.solrj.SolrClient;
+/**
+ * Retrieves cluster state via Solr HTTP APIs
+ */
public class HttpClusterStateProvider extends BaseHttpClusterStateProvider {
private final HttpClient httpClient;
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 93bb8bb7796..fae16bf2873 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
@@ -16,32 +16,6 @@
*/
package org.apache.solr.client.solrj.impl;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.lang.invoke.MethodHandles;
-import java.net.ConnectException;
-import java.net.MalformedURLException;
-import java.net.SocketTimeoutException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Base64;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
@@ -89,6 +63,32 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.lang.invoke.MethodHandles;
+import java.net.ConnectException;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
import static org.apache.solr.common.util.Utils.getObjectByPath;
/**
@@ -151,39 +151,10 @@ public class HttpSolrClient extends BaseHttpSolrClient {
private volatile Set<String> queryParams = Collections.emptySet();
private volatile Integer connectionTimeout;
private volatile Integer soTimeout;
-
- /**
- * @deprecated use {@link HttpSolrClient#HttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative
- */
- @Deprecated
- protected HttpSolrClient(String baseURL, HttpClient client, ResponseParser parser, boolean allowCompression) {
- this(new Builder(baseURL)
- .withHttpClient(client)
- .withResponseParser(parser)
- .allowCompression(allowCompression));
- }
/**
- * The constructor.
- *
- * @param baseURL The base url to communicate with the Solr server
- * @param client Http client instance to use for communication
- * @param parser Response parser instance to use to decode response from Solr server
- * @param allowCompression Should compression be allowed ?
- * @param invariantParams The parameters which should be included with every request.
- *
- * @deprecated use {@link HttpSolrClient#HttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative
+ * Use the builder to create this client
*/
- @Deprecated
- protected HttpSolrClient(String baseURL, HttpClient client, ResponseParser parser, boolean allowCompression,
- ModifiableSolrParams invariantParams) {
- this(new Builder(baseURL)
- .withHttpClient(client)
- .withResponseParser(parser)
- .allowCompression(allowCompression)
- .withInvariantParams(invariantParams));
- }
-
protected HttpSolrClient(Builder builder) {
this.baseUrl = builder.baseSolrUrl;
if (baseUrl.endsWith("/")) {
@@ -810,34 +781,7 @@ public class HttpSolrClient extends BaseHttpSolrClient {
public HttpClient getHttpClient() {
return httpClient;
}
-
- /**
- * HttpConnectionParams.setConnectionTimeout
- *
- * @param timeout
- * Timeout in milliseconds
- *
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setConnectionTimeout(int timeout) {
- this.connectionTimeout = timeout;
- }
-
- /**
- * Set SoTimeout (read timeout). This is desirable
- * for queries, but probably not for indexing.
- *
- * @param timeout
- * Timeout in milliseconds
- *
-s * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setSoTimeout(int timeout) {
- this.soTimeout = timeout;
- }
-
+
/**
* Configure whether the client should follow redirects or not.
* <p>
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 5ffc70cf537..cdb30ff5d72 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
@@ -16,18 +16,14 @@
*/
package org.apache.solr.client.solrj.impl;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
import org.apache.http.client.HttpClient;
-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.common.params.ModifiableSolrParams;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+
/**
* LBHttpSolrClient or "LoadBalanced HttpSolrClient" is a load balancing wrapper around
* {@link HttpSolrClient}. This is useful when you
@@ -75,55 +71,9 @@ public class LBHttpSolrClient extends LBSolrClient {
private Integer connectionTimeout;
private volatile Integer soTimeout;
- /**
- * @deprecated use {@link LBSolrClient.Req} instead
- */
- @Deprecated
- public static class Req extends LBSolrClient.Req {
- public Req(SolrRequest<?> request, List<String> servers) {
- super(request, servers);
- }
-
- public Req(SolrRequest<?> request, List<String> servers, Integer numServersToTry) {
- super(request, servers, numServersToTry);
- }
- }
-
- /**
- * @deprecated use {@link LBSolrClient.Rsp} instead
- */
- @Deprecated
- public static class Rsp extends LBSolrClient.Rsp {
-
- }
-
/**
* The provided httpClient should use a multi-threaded connection manager
- *
- * @deprecated use {@link LBHttpSolrClient#LBHttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative
*/
- @Deprecated
- protected LBHttpSolrClient(HttpSolrClient.Builder httpSolrClientBuilder,
- HttpClient httpClient, String... solrServerUrl) {
- this(new Builder()
- .withHttpSolrClientBuilder(httpSolrClientBuilder)
- .withHttpClient(httpClient)
- .withBaseSolrUrls(solrServerUrl));
- }
-
- /**
- * The provided httpClient should use a multi-threaded connection manager
- *
- * @deprecated use {@link LBHttpSolrClient#LBHttpSolrClient(Builder)} instead, as it is a more extension/subclassing-friendly alternative
- */
- @Deprecated
- protected LBHttpSolrClient(HttpClient httpClient, ResponseParser parser, String... solrServerUrl) {
- this(new Builder()
- .withBaseSolrUrls(solrServerUrl)
- .withResponseParser(parser)
- .withHttpClient(httpClient));
- }
-
protected LBHttpSolrClient(Builder builder) {
super(builder.baseSolrUrls);
this.clientIsInternal = builder.httpClient == null;
@@ -184,40 +134,6 @@ public class LBHttpSolrClient extends LBSolrClient {
return client;
}
- /**
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setConnectionTimeout(int timeout) {
- this.connectionTimeout = timeout;
- this.urlToClient.values().forEach(client -> client.setConnectionTimeout(timeout));
- }
-
- /**
- * set soTimeout (read timeout) on the underlying HttpConnectionManager. This is desirable for queries, but probably
- * not for indexing.
- *
- * @deprecated since 7.0 Use {@link Builder} methods instead.
- */
- @Deprecated
- public void setSoTimeout(int timeout) {
- this.soTimeout = timeout;
- this.urlToClient.values().forEach(client -> client.setSoTimeout(timeout));
- }
-
- /**
- * @deprecated use {@link LBSolrClient#request(LBSolrClient.Req)} instead
- */
- @Deprecated
- public Rsp request(Req req) throws SolrServerException, IOException {
- LBSolrClient.Rsp rsp = super.request(req);
- // for backward-compatibility support
- Rsp result = new Rsp();
- result.rsp = rsp.rsp;
- result.server = rsp.server;
- return result;
- }
-
@Override
protected SolrClient getClient(String baseUrl) {
HttpSolrClient client = urlToClient.get(baseUrl);
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
index 3e624165268..e4d0e8bfbed 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/ZkClientClusterStateProvider.java
@@ -34,7 +34,9 @@ import org.apache.zookeeper.KeeperException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+/**
+ * Retrieves cluster state from Zookeeper
+ */
public class ZkClientClusterStateProvider implements ClusterStateProvider {
private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
index e60bc39b6e5..5c76e4167e3 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
@@ -32,7 +32,6 @@ import java.util.Set;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.SolrServerException;
-import org.apache.solr.client.solrj.impl.LBHttpSolrClient;
import org.apache.solr.client.solrj.impl.LBSolrClient;
import org.apache.solr.client.solrj.response.UpdateResponse;
import org.apache.solr.client.solrj.util.ClientUtils;
@@ -48,8 +47,8 @@ import org.apache.solr.common.util.XML;
import static org.apache.solr.common.params.ShardParams._ROUTE_;
/**
- *
- *
+ *
+ *
* @since solr 1.3
*/
public class UpdateRequest extends AbstractUpdateRequest {
@@ -352,22 +351,6 @@ public class UpdateRequest extends AbstractUpdateRequest {
return getRoutes(router, col, urlMap, params, idField, LBSolrClient.Req::new);
}
- /**
- * @param router to route updates with
- * @param col DocCollection for the updates
- * @param urlMap of the cluster
- * @param params params to use
- * @param idField the id field
- * @return a Map of urls to requests
- * @deprecated since 8.0, uses {@link #getRoutesToCollection(DocRouter, DocCollection, Map, ModifiableSolrParams, String)} instead
- */
- @Deprecated
- public Map<String,LBHttpSolrClient.Req> getRoutes(DocRouter router,
- DocCollection col, Map<String,List<String>> urlMap,
- ModifiableSolrParams params, String idField) {
- return getRoutes(router, col, urlMap, params, idField, LBHttpSolrClient.Req::new);
- }
-
public void setDocIterator(Iterator<SolrInputDocument> docIterator) {
this.docIterator = docIterator;
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
index 3be5d83100a..16a435cf2ff 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
@@ -32,13 +32,6 @@ public class CloudSolrClientBuilderTest extends SolrTestCase {
private static final String ANY_ZK_HOST = "ANY_ZK_HOST";
private static final String ANY_OTHER_ZK_HOST = "ANY_OTHER_ZK_HOST";
- @Test(expected = IllegalArgumentException.class)
- public void testNoZkHostSpecified() {
- new Builder()
- .withZkChroot(ANY_CHROOT)
- .build();
- }
-
@Test
// commented out on: 24-Dec-2018 @BadApple(bugUrl="https://issues.apache.org/jira/browse/SOLR-12028") // added 20-Sep-2018
public void testSingleZkHostSpecified() throws IOException {
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
index caf9c329ca2..4fe5095e15d 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientCacheTest.java
@@ -110,12 +110,12 @@ public class CloudSolrClientCacheTest extends SolrTestCaseJ4 {
LBHttpSolrClient mockLbclient = mock(LBHttpSolrClient.class);
when(mockLbclient.request(any(LBSolrClient.Req.class))).then(invocationOnMock -> {
- LBHttpSolrClient.Req req = invocationOnMock.getArgument(0);
+ LBSolrClient.Req req = invocationOnMock.getArgument(0);
Function<?,?> f = responses.get("request");
if (f == null) return null;
Object res = f.apply(null);
if (res instanceof Exception) throw (Throwable) res;
- LBHttpSolrClient.Rsp rsp = new LBHttpSolrClient.Rsp();
+ LBSolrClient.Rsp rsp = new LBSolrClient.Rsp();
rsp.rsp = (NamedList<Object>) res;
rsp.server = req.servers.get(0);
return rsp;
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java
index eee514d86c4..07582c3d703 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientMultiConstructorTest.java
@@ -70,7 +70,8 @@ public class CloudSolrClientMultiConstructorTest extends SolrTestCase {
clientChroot = "/mychroot";
}
- try (CloudSolrClient client = (new CloudSolrClient.Builder()).withZkHost(hosts).withZkChroot(clientChroot).build()) {
+ try (CloudSolrClient client = (new CloudSolrClient.Builder(new ArrayList<>(hosts),
+ Optional.ofNullable(clientChroot)).build())) {
assertEquals(sb.toString(), client.getZkHost());
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 2916bebc220..a353d74fb46 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -232,6 +232,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
assertEquals(2, client.query(null, paramsWithMixedCollectionAndAlias).getResults().getNumFound());
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testRouting() throws Exception {
CollectionAdminRequest.createCollection("routing_collection", "conf", 2, 1)
@@ -250,11 +251,11 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
checkSingleServer(response);
}
CloudSolrClient.RouteResponse rr = (CloudSolrClient.RouteResponse) response;
- Map<String,LBHttpSolrClient.Req> routes = rr.getRoutes();
- Iterator<Map.Entry<String,LBHttpSolrClient.Req>> it = routes.entrySet()
+ Map<String,LBSolrClient.Req> routes = rr.getRoutes();
+ Iterator<Map.Entry<String,LBSolrClient.Req>> it = routes.entrySet()
.iterator();
while (it.hasNext()) {
- Map.Entry<String,LBHttpSolrClient.Req> entry = it.next();
+ Map.Entry<String,LBSolrClient.Req> entry = it.next();
String url = entry.getKey();
UpdateRequest updateRequest = (UpdateRequest) entry.getValue()
.getRequest();
@@ -300,7 +301,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
it = routes.entrySet()
.iterator();
while (it.hasNext()) {
- Map.Entry<String,LBHttpSolrClient.Req> entry = it.next();
+ Map.Entry<String,LBSolrClient.Req> entry = it.next();
String url = entry.getKey();
UpdateRequest updateRequest = (UpdateRequest) entry.getValue()
.getRequest();
@@ -918,15 +919,15 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
}
}
-
+ @SuppressWarnings({"rawtypes", "unchecked"})
private static void checkSingleServer(NamedList<Object> response) {
final CloudSolrClient.RouteResponse rr = (CloudSolrClient.RouteResponse) response;
- final Map<String,LBHttpSolrClient.Req> routes = rr.getRoutes();
- final Iterator<Map.Entry<String,LBHttpSolrClient.Req>> it =
+ final Map<String,LBSolrClient.Req> routes = rr.getRoutes();
+ final Iterator<Map.Entry<String,LBSolrClient.Req>> it =
routes.entrySet().iterator();
while (it.hasNext()) {
- Map.Entry<String,LBHttpSolrClient.Req> entry = it.next();
+ Map.Entry<String,LBSolrClient.Req> entry = it.next();
assertEquals("wrong number of servers: "+entry.getValue().getServers(),
1, entry.getValue().getServers().size());
}
@@ -1000,7 +1001,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
Object shardsInfo = qResponse.getResponse().get(ShardParams.SHARDS_INFO);
assertNotNull("Unable to obtain "+ShardParams.SHARDS_INFO, shardsInfo);
- Map<String, String> replicaTypeMap = new HashMap<String, String>();
+ Map<String, String> replicaTypeMap = new HashMap<>();
DocCollection collection = getCollectionState(collectionName);
for (Slice slice : collection.getSlices()) {
for (Replica replica : slice.getReplicas()) {
@@ -1018,7 +1019,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
SimpleOrderedMap<?> shardsInfoMap = (SimpleOrderedMap<?>)shardsInfo;
@SuppressWarnings({"unchecked"})
Iterator<Map.Entry<String, ?>> itr = shardsInfoMap.asMap(100).entrySet().iterator();
- List<String> shardAddresses = new ArrayList<String>();
+ List<String> shardAddresses = new ArrayList<>();
while (itr.hasNext()) {
Map.Entry<String, ?> e = itr.next();
assertTrue("Did not find map-type value in "+ShardParams.SHARDS_INFO, e.getValue() instanceof Map);
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java
index 627558a6c48..bd573e81e2d 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/HttpSolrClientConPoolTest.java
@@ -163,9 +163,8 @@ public class HttpSolrClientConPoolTest extends SolrJettyTestBase {
updateRequest.add(doc); // here we mimic CloudSolrClient impl
final List<String> urls = Arrays.asList(fooUrl, barUrl);
Collections.shuffle(urls, random());
- LBHttpSolrClient.Req req = new LBHttpSolrClient.Req(updateRequest,
- urls);
- roundRobin.request(req);
+ LBSolrClient.Req req = new LBSolrClient.Req(updateRequest, urls);
+ roundRobin.request(req);
}
}
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java
index e6c02f8c2a5..860cef5b734 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/LBHttpSolrClientTest.java
@@ -32,7 +32,7 @@ import static org.junit.Assert.assertNull;
public class LBHttpSolrClientTest {
/**
- * Test method for {@link LBHttpSolrClient#LBHttpSolrClient(org.apache.http.client.HttpClient, org.apache.solr.client.solrj.ResponseParser, java.lang.String[])}.
+ * Test method for {@link LBHttpSolrClient.Builder}.
*
* Validate that the parser passed in is used in the <code>HttpSolrClient</code> instances created.
*/
@@ -51,7 +51,10 @@ public class LBHttpSolrClientTest {
ResponseParser parser = new BinaryResponseParser();
httpClient = HttpClientUtil.createClient(new ModifiableSolrParams());
try {
- try ( LBHttpSolrClient testClient = new LBHttpSolrClient(httpClient, parser); HttpSolrClient httpSolrClient = testClient.makeSolrClient("http://127.0.0.1:8080")) {
+ try ( LBHttpSolrClient testClient = new LBHttpSolrClient.Builder()
+ .withHttpClient(httpClient)
+ .withResponseParser(parser).build();
+ HttpSolrClient httpSolrClient = testClient.makeSolrClient("http://127.0.0.1:8080")) {
assertEquals("Invalid parser passed to generated server.", parser, httpSolrClient.getParser());
}
} finally {