This is an automated email from the ASF dual-hosted git repository. hossman pushed a commit to branch jira/SOLR-6312 in repository https://gitbox.apache.org/repos/asf/solr.git
commit e9c4f80659a110e340db673dd2f2a3ede77b8112 Author: Chris Hostetter <[email protected]> AuthorDate: Fri Jan 6 12:21:15 2023 -0700 Fix Builder method name and update javadocs --- .../client/solrj/impl/CloudHttp2SolrClient.java | 2 +- .../client/solrj/impl/CloudLegacySolrClient.java | 40 +++++++++++++++++++--- .../impl/SendUpdatesToLeadersOverrideTest.java | 4 +-- .../src/java/org/apache/solr/SolrTestCaseJ4.java | 10 +++--- 4 files changed, 42 insertions(+), 14 deletions(-) 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 49200f4ce2f..391a14b16fd 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 @@ -136,7 +136,7 @@ public class CloudHttp2SolrClient extends CloudSolrClient { protected List<String> solrUrls = new ArrayList<>(); protected String zkChroot; protected Http2SolrClient httpClient; - protected boolean shardLeadersOnly = true; + protected boolean shardLeadersOnly = true; // nocommit: use this, add setter protected boolean directUpdatesToLeadersOnly = false; protected boolean parallelUpdates = true; protected ClusterStateProvider stateProvider; diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java index 58da3d71d3f..1d817e109aa 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java @@ -267,9 +267,11 @@ public class CloudLegacySolrClient extends CloudSolrClient { } /** - * Tells {@link Builder} that created clients should send updates only to shard leaders. + * Tells {@link Builder} that created clients should be configured such that {@link + * CloudSolrClient#isUpdatesToLeaders} returns <code>true</code>. * - * <p>WARNING: This method currently has no effect. See SOLR-6312 for more information. + * @see #sendUpdatesToAnyReplica + * @see CloudSolrClient#isUpdatesToLeaders */ public Builder sendUpdatesOnlyToShardLeaders() { shardLeadersOnly = true; @@ -277,20 +279,45 @@ public class CloudLegacySolrClient extends CloudSolrClient { } /** - * Tells {@link Builder} that created clients should send updates to all replicas for a shard. + * Tells {@link Builder} that created clients should be configured such that {@link + * CloudSolrClient#isUpdatesToLeaders} returns <code>false</code>. * - * <p>WARNING: This method currently has no effect. See SOLR-6312 for more information. + * @see #sendUpdatesOnlyToShardLeaders + * @see CloudSolrClient#isUpdatesToLeaders */ - public Builder sendUpdatesToAllReplicasInShard() { + public Builder sendUpdatesToAnyReplica() { shardLeadersOnly = false; return this; } + /** + * This method has no effect. + * + * <p>In older versions of Solr, this method was an incorrectly named equivilent to {@link + * #sendUpdatesToAnyReplica}, which had no effect because that setting was ignored in the + * created clients. When the underlying {@link CloudSolrClient} behavior was fixed, this method + * was modified to be an explicit No-Op, since the implied behavior of sending updates to + * <em>all</em> replicas has never been supported, and was never intended to be supported. + * + * @see #sendUpdatesOnlyToShardLeaders + * @see #sendUpdatesToAnyReplica + * @see CloudSolrClient#isUpdatesToLeaders + * @see <a href="https://issues.apache.org/jira/browse/SOLR-6312">SOLR-6312</a> + * @deprecated Never supported + */ + @Deprecated + public Builder sendUpdatesToAllReplicasInShard() { + return this; + } + /** * Tells {@link Builder} that created clients should send direct updates to shard leaders only. * * <p>UpdateRequests whose leaders cannot be found will "fail fast" on the client side with a * {@link SolrException} + * + * @see #sendDirectUpdatesToAnyShardReplica + * @see CloudSolrClient#isDirectUpdatesToLeadersOnly */ public Builder sendDirectUpdatesToShardLeadersOnly() { directUpdatesToLeadersOnly = true; @@ -303,6 +330,9 @@ public class CloudLegacySolrClient extends CloudSolrClient { * * <p>Shard leaders are still preferred, but the created clients will fallback to using other * replicas if a leader cannot be found. + * + * @see #sendDirectUpdatesToShardLeadersOnly + * @see CloudSolrClient#isDirectUpdatesToLeadersOnly */ public Builder sendDirectUpdatesToAnyShardReplica() { directUpdatesToLeadersOnly = false; diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java index 044c24f339d..c185e1e4d82 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/SendUpdatesToLeadersOverrideTest.java @@ -222,9 +222,7 @@ public class SendUpdatesToLeadersOverrideTest extends SolrCloudTestCase { try (CloudSolrClient client = new CloudLegacySolrClient.Builder( Collections.singletonList(cluster.getZkServer().getZkAddress()), Optional.empty()) - // nocommit: builder name should never have been 'sendUpdatesToAllReplicasInShard' - // nocommit: - should have been 'sendUpdatesToAnyReplicas' - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .build()) { checkUpdatesWithShardsPrefPull(client); checkUpdatesWithSendToLeadersFalse(client); diff --git a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java index 7caa396578b..3c724202e1f 100644 --- a/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java +++ b/solr/test-framework/src/java/org/apache/solr/SolrTestCaseJ4.java @@ -2699,7 +2699,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { .build(); } return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()) - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .build(); } @@ -2721,7 +2721,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { .build(); } return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()) - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .withSocketTimeout(socketTimeoutMillis) .build(); } @@ -2744,7 +2744,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { .build(); } return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()) - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .withConnectionTimeout(connectionTimeoutMillis) .withSocketTimeout(socketTimeoutMillis) .build(); @@ -2765,7 +2765,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()) .withHttpClient(httpClient) - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .build(); } @@ -2790,7 +2790,7 @@ public abstract class SolrTestCaseJ4 extends SolrTestCase { } return new CloudSolrClientBuilder(Collections.singletonList(zkHost), Optional.empty()) .withHttpClient(httpClient) - .sendUpdatesToAllReplicasInShard() + .sendUpdatesToAnyReplica() .withConnectionTimeout(connectionTimeoutMillis) .withSocketTimeout(socketTimeoutMillis) .build();
