diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index a34806e0a917..1d1d946da1fd 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -199,6 +199,9 @@ Other Changes * SOLR-14067: StatelessScriptUpdateProcessorFactory moved to it's own /contrib/scripting/ package instead of shipping as part of Solr due to security concerns. Renamed to ScriptUpdateProcessorFactory for simpler name. (Eric Pugh) +* SOLR-15141: The V2RequestSupport interface has been removed, along with the accompanying `setUseV2Request` SolrRequest + method. v2 APIs will be supported going forward in a way that doesn't require users to request v2-conversion. (Jason Gerlowski) + Bug Fixes --------------------- * SOLR-14546: Fix for a relatively hard to hit issue in OverseerTaskProcessor that could lead to out of order execution diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java index ef718e00bf35..2cbab955ce93 100644 --- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java +++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestCollectionAPI.java @@ -16,14 +16,6 @@ */ package org.apache.solr.cloud.api.collections; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; - import com.google.common.collect.Lists; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrServerException; @@ -31,7 +23,6 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; import org.apache.solr.client.solrj.request.QueryRequest; -import org.apache.solr.client.solrj.request.V2Request; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.cloud.ZkTestServer; import org.apache.solr.common.SolrException; @@ -49,6 +40,13 @@ import org.apache.zookeeper.KeeperException; import org.junit.Test; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + public class TestCollectionAPI extends ReplicaPropertiesBase { public static final String COLLECTION_NAME = "testcollection"; @@ -69,9 +67,7 @@ public void test() throws Exception { } else { req = CollectionAdminRequest.createCollection(COLLECTION_NAME, "conf1",2, 1, 0, 1); } - setV2(req); client.request(req); - assertV2CallsCount(); createCollection(null, COLLECTION_NAME1, 1, 1, client, null, "conf1"); } @@ -414,8 +410,7 @@ private void clusterStatusWithCollection() throws IOException, SolrServerExcepti private void clusterStatusZNodeVersion() throws Exception { String cname = "clusterStatusZNodeVersion"; try (CloudSolrClient client = createCloudClient(null)) { - setV2(CollectionAdminRequest.createCollection(cname, "conf1", 1, 1)).process(client); - assertV2CallsCount(); + CollectionAdminRequest.createCollection(cname, "conf1", 1, 1).process(client); waitForRecoveriesToFinish(cname, true); ModifiableSolrParams params = new ModifiableSolrParams(); @@ -438,9 +433,7 @@ private void clusterStatusZNodeVersion() throws Exception { assertNotNull(znodeVersion); CollectionAdminRequest.AddReplica addReplica = CollectionAdminRequest.addReplicaToShard(cname, "shard1"); - setV2(addReplica); addReplica.process(client); - assertV2CallsCount(); waitForRecoveriesToFinish(cname, true); rsp = client.request(request); @@ -453,24 +446,6 @@ private void clusterStatusZNodeVersion() throws Exception { } } - private static long totalexpectedV2Calls; - - @SuppressWarnings({"rawtypes"}) - public static SolrRequest setV2(SolrRequest req) { - if (V2Request.v2Calls.get() == null) V2Request.v2Calls.set(new AtomicLong()); - totalexpectedV2Calls = V2Request.v2Calls.get().get(); - if (random().nextBoolean()) { - req.setUseV2(true); - req.setUseBinaryV2(random().nextBoolean()); - totalexpectedV2Calls++; - } - return req; - } - - public static void assertV2CallsCount() { - assertEquals(totalexpectedV2Calls, V2Request.v2Calls.get().get()); - } - private void clusterStatusWithRouteKey() throws IOException, SolrServerException { try (CloudSolrClient client = createCloudClient(DEFAULT_COLLECTION)) { SolrInputDocument doc = new SolrInputDocument(); diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java index 22e615f92373..4ccc4916263b 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java @@ -16,6 +16,10 @@ */ package org.apache.solr.client.solrj; +import org.apache.solr.client.solrj.request.RequestWriter; +import org.apache.solr.common.params.SolrParams; +import org.apache.solr.common.util.ContentStream; + import java.io.IOException; import java.io.Serializable; import java.security.Principal; @@ -26,10 +30,6 @@ import java.util.Set; import java.util.concurrent.TimeUnit; -import org.apache.solr.client.solrj.request.RequestWriter; -import org.apache.solr.common.params.SolrParams; -import org.apache.solr.common.util.ContentStream; - /** * * @@ -82,25 +82,6 @@ public enum SolrClientContext { private StreamingResponseCallback callback; private Set queryParams; - protected boolean usev2; - protected boolean useBinaryV2; - - /**If set to true, every request that implements {@link V2RequestSupport} will be converted - * to a V2 API call - */ - @SuppressWarnings({"rawtypes"}) - public SolrRequest setUseV2(boolean flag){ - this.usev2 = flag; - return this; - } - - /**If set to true use javabin instead of json (default) - */ - @SuppressWarnings({"rawtypes"}) - public SolrRequest setUseBinaryV2(boolean flag){ - this.useBinaryV2 = flag; - return this; - } private String basicAuthUser, basicAuthPwd; 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 abed2aa5d750..9218f3b0294d 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 @@ -877,9 +877,6 @@ protected NamedList requestWithRetryOnStaleState(@SuppressWarnings({"raw String stateVerParam = null; List requestedCollections = null; boolean isCollectionRequestOfV2 = false; - if (request instanceof V2RequestSupport) { - request = ((V2RequestSupport) request).getV2Request(); - } if (request instanceof V2Request) { isCollectionRequestOfV2 = ((V2Request) request).isPerCollectionRequest(); } diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java index 1543fbe75b1d..ae0ce2390ff7 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java @@ -518,9 +518,6 @@ private Request createRequest(@SuppressWarnings({"rawtypes"})SolrRequest solrReq if (solrRequest.getBasePath() == null && serverBaseUrl == null) throw new IllegalArgumentException("Destination node is not provided!"); - if (solrRequest instanceof V2RequestSupport) { - solrRequest = ((V2RequestSupport) solrRequest).getV2Request(); - } SolrParams params = solrRequest.getParams(); RequestWriter.ContentWriter contentWriter = requestWriter.getContentWriter(solrRequest); Collection streams = contentWriter == null ? requestWriter.getContentStreams(solrRequest) : null; 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 e95c5d0d3158..373b9700ce4c 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 @@ -346,9 +346,6 @@ static String changeV2RequestEndpoint(String basePath) throws MalformedURLExcept @SuppressWarnings({"unchecked"}) protected HttpRequestBase createMethod(@SuppressWarnings({"rawtypes"})SolrRequest request, String collection) throws IOException, SolrServerException { - if (request instanceof V2RequestSupport) { - request = ((V2RequestSupport) request).getV2Request(); - } SolrParams params = request.getParams(); RequestWriter.ContentWriter contentWriter = requestWriter.getContentWriter(request); Collection streams = contentWriter == null ? requestWriter.getContentStreams(request) : null; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java index e09ebb35a6cc..4037609d8734 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/request/CollectionAdminRequest.java @@ -16,25 +16,11 @@ */ package org.apache.solr.client.solrj.request; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Optional; -import java.util.Properties; -import java.util.Set; -import java.util.TimeZone; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - import org.apache.solr.client.solrj.RoutedAliasTypes; import org.apache.solr.client.solrj.SolrClient; import org.apache.solr.client.solrj.SolrRequest; import org.apache.solr.client.solrj.SolrResponse; import org.apache.solr.client.solrj.SolrServerException; -import org.apache.solr.client.solrj.V2RequestSupport; import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.client.solrj.response.RequestStatusState; import org.apache.solr.client.solrj.util.SolrIdentifierValidator; @@ -54,26 +40,29 @@ import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Optional; +import java.util.Properties; +import java.util.Set; +import java.util.TimeZone; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + import static org.apache.solr.common.cloud.DocCollection.PER_REPLICA_STATE; -import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS; -import static org.apache.solr.common.cloud.ZkStateReader.PULL_REPLICAS; -import static org.apache.solr.common.cloud.ZkStateReader.READ_ONLY; -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR; -import static org.apache.solr.common.cloud.ZkStateReader.TLOG_REPLICAS; -import static org.apache.solr.common.params.CollectionAdminParams.ALIAS; -import static org.apache.solr.common.params.CollectionAdminParams.COLL_CONF; -import static org.apache.solr.common.params.CollectionAdminParams.COUNT_PROP; -import static org.apache.solr.common.params.CollectionAdminParams.CREATE_NODE_SET_PARAM; -import static org.apache.solr.common.params.CollectionAdminParams.CREATE_NODE_SET_SHUFFLE_PARAM; -import static org.apache.solr.common.params.CollectionAdminParams.ROUTER_PREFIX; -import static org.apache.solr.common.params.CollectionAdminParams.SKIP_NODE_ASSIGNMENT; +import static org.apache.solr.common.cloud.ZkStateReader.*; +import static org.apache.solr.common.params.CollectionAdminParams.*; /** * This class is experimental and subject to change. * * @since solr 4.5 */ -public abstract class CollectionAdminRequest extends SolrRequest implements V2RequestSupport, MapWriter { +public abstract class CollectionAdminRequest extends SolrRequest implements MapWriter { /** * The set of modifiable collection properties @@ -97,14 +86,6 @@ public CollectionAdminRequest(String path, CollectionAction action) { this.action = checkNotNull(CoreAdminParams.ACTION, action); } - @Override - @SuppressWarnings({"rawtypes"}) - public SolrRequest getV2Request() { - return usev2 ? - V1toV2ApiMapper.convert(this).useBinary(useBinaryV2).build() : - this; - } - @Override public SolrParams getParams() { ModifiableSolrParams params = new ModifiableSolrParams();