lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [lucene-solr] branch jira/solr14089 updated: deprecate ZkStatereader#getLeaderRetry(String, String)
Date Tue, 17 Dec 2019 20:58:57 GMT
This is an automated email from the ASF dual-hosted git repository.

noble pushed a commit to branch jira/solr14089
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/jira/solr14089 by this push:
     new 54fc0eb  deprecate ZkStatereader#getLeaderRetry(String,String)
54fc0eb is described below

commit 54fc0eb6c1f041f580c20d14addb4f55c8ce99ab
Author: noble <noble@apache.org>
AuthorDate: Wed Dec 18 07:58:39 2019 +1100

    deprecate ZkStatereader#getLeaderRetry(String,String)
---
 solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java    | 3 +--
 solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java | 3 +--
 .../solr/update/processor/DistributedZkUpdateProcessor.java       | 2 +-
 .../src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java   | 3 +--
 solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java   | 4 ++--
 .../test/org/apache/solr/cloud/DistributedVersionInfoTest.java    | 2 +-
 .../test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java  | 2 +-
 .../src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java | 6 +++---
 solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java   | 6 +++---
 solr/core/src/test/org/apache/solr/cloud/TestPrepRecovery.java    | 2 +-
 .../org/apache/solr/cloud/api/collections/TestCollectionAPI.java  | 8 ++++----
 .../src/java/org/apache/solr/common/cloud/ZkStateReader.java      | 2 ++
 .../java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java | 2 +-
 .../src/java/org/apache/solr/cloud/ChaosMonkey.java               | 2 +-
 14 files changed, 23 insertions(+), 24 deletions(-)

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 9dd5d58..1148fa9 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -355,8 +355,7 @@ public class RecoveryStrategy implements Runnable, Closeable {
                                                                                         
   // though
       try {
         CloudDescriptor cloudDesc = this.coreDescriptor.getCloudDescriptor();
-        ZkNodeProps leaderprops = zkStateReader.getLeaderRetry(
-            cloudDesc.getCollectionName(), cloudDesc.getShardId());
+        ZkNodeProps leaderprops = core.getShardStateProvider().getLeader(cloudDesc.getCollectionName(),
cloudDesc.getShardId(), -1);
         final String leaderBaseUrl = leaderprops.getStr(ZkStateReader.BASE_URL_PROP);
         final String leaderCoreName = leaderprops.getStr(ZkStateReader.CORE_NAME_PROP);
 
diff --git a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
index e4727da..2cb89e8 100644
--- a/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
+++ b/solr/core/src/java/org/apache/solr/update/SolrCmdDistributor.java
@@ -638,8 +638,7 @@ public class SolrCmdDistributor implements Closeable {
       if (doRetry) {
         ZkCoreNodeProps leaderProps;
         try {
-          leaderProps = new ZkCoreNodeProps(zkStateReader.getLeaderRetry(
-              collection, shardId));
+          leaderProps = new ZkCoreNodeProps(zkStateReader.getShardStateProvider(collection).getLeader(collection,
shardId, -1));
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
           return false;
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
index 98336db..6f90f77 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedZkUpdateProcessor.java
@@ -801,7 +801,7 @@ public class DistributedZkUpdateProcessor extends DistributedUpdateProcessor
{
     Slice mySlice = coll.getSlice(myShardId);
     final Slice.State state = mySlice.getState();
     if (state == Slice.State.CONSTRUCTION || state == Slice.State.RECOVERY) {
-      Replica myLeader = zkController.getZkStateReader().getLeaderRetry(collection, myShardId);
+      Replica myLeader = req.getCore().getShardStateProvider().getLeader(collection, myShardId,
-1);
       boolean amILeader = myLeader.getName().equals(cloudDesc.getCoreNodeName());
       if (amILeader) {
         // Does the document belong to my hash range as well?
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
index 65d1c59..8f8f51d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
@@ -115,8 +115,7 @@ public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase
{
       // TODO: bring this to its own method?
       // try indexing to a leader that has no replicas up
       ZkStateReader zkStateReader = cloudClient.getZkStateReader();
-      ZkNodeProps leaderProps = zkStateReader.getLeaderRetry(
-          DEFAULT_COLLECTION, SHARD2);
+      ZkNodeProps leaderProps = zkStateReader.getShardStateProvider(DEFAULT_COLLECTION).getLeader(DEFAULT_COLLECTION,
SHARD2, -1);
       
       String nodeName = leaderProps.getStr(ZkStateReader.NODE_NAME_PROP);
       chaosMonkey.stopShardExcept(SHARD2, nodeName);
diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
index 5dd6b3e..21019cb 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java
@@ -153,7 +153,7 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
     final String collectionName = "deletereplica_test";
     CollectionAdminRequest.createCollection(collectionName, "conf", 1, 2).process(cluster.getSolrClient());
 
-    Replica leader = cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName,
"shard1");
+    Replica leader = cluster.getSolrClient().getZkStateReader().getShardStateProvider(collectionName).
getLeader(collectionName, "shard1", -1);
 
     //Confirm that the instance and data directory exist
     CoreStatus coreStatus = getCoreStatus(leader);
@@ -163,7 +163,7 @@ public class DeleteReplicaTest extends SolrCloudTestCase {
     CollectionAdminRequest.deleteReplica(collectionName, "shard1",leader.getName())
         .process(cluster.getSolrClient());
 
-    Replica newLeader = cluster.getSolrClient().getZkStateReader().getLeaderRetry(collectionName,
"shard1");
+    Replica newLeader = cluster.getSolrClient().getZkStateReader().getShardStateProvider(collectionName).getLeader(collectionName,
"shard1", -1);
 
     assertFalse(leader.equals(newLeader));
 
diff --git a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
index 644ec9a..20d8c71 100644
--- a/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/DistributedVersionInfoTest.java
@@ -86,7 +86,7 @@ public class DistributedVersionInfoTest extends SolrCloudTestCase {
     stateReader.waitForState(COLLECTION, DEFAULT_TIMEOUT, TimeUnit.SECONDS,
         (n, c, ssp) -> DocCollection.isFullyActive(ssp, c, 1, 3));
 
-    final Replica leader = stateReader.getLeaderRetry(COLLECTION, shardId);
+    final Replica leader = stateReader.getShardStateProvider(COLLECTION).getLeader(COLLECTION,
shardId, -1);
 
     // start by reloading the empty collection so we try to calculate the max from an empty
index
     reloadCollection(leader, COLLECTION);
diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
index d6cbf9b..1d1238e 100644
--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
@@ -404,7 +404,7 @@ public class FullSolrCloudDistribCmdsTest extends AbstractFullDistribZkTestBase
 
   private long testThatCantForwardToLeaderFails(long docId) throws Exception {
     ZkStateReader zkStateReader = cloudClient.getZkStateReader();
-    ZkNodeProps props = zkStateReader.getLeaderRetry(DEFAULT_COLLECTION, "shard1");
+    ZkNodeProps props = zkStateReader.getShardStateProvider(DEFAULT_COLLECTION).getLeader(DEFAULT_COLLECTION,
"shard1", -1);
     
     chaosMonkey.stopShard("shard1");
     
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
index 7a17d6f..39f0778 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionOnCommitTest.java
@@ -90,13 +90,13 @@ public class HttpPartitionOnCommitTest extends BasicDistributedZkTest
{
 
     ShardStateProvider shardStateProvider = cloudClient.getZkStateReader().getShardStateProvider(testCollectionName);
     // let's put the leader in its own partition, no replicas can contact it now
-    Replica leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
+    Replica leader = cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).getLeader(testCollectionName,
"shard1", -1);
     log.info("Creating partition to leader at "+leader.getCoreUrl());
     SocketProxy leaderProxy = getProxyForReplica(leader);
     leaderProxy.close();
 
     // let's find the leader of shard2 and ask him to commit
-    Replica shard2Leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName,
"shard2");
+    Replica shard2Leader = cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).
getLeader(testCollectionName, "shard2", -1);
     sendCommitWithRetry(shard2Leader);
 
     Thread.sleep(sleepMsBeforeHealPartition);
@@ -148,7 +148,7 @@ public class HttpPartitionOnCommitTest extends BasicDistributedZkTest
{
     Thread.sleep(sleepMsBeforeHealPartition);
 
     cloudClient.getZkStateReader().forceUpdateCollection(testCollectionName); // get the
latest state
-    leader = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
+    leader = cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).getLeader(testCollectionName,
"shard1", -1);
     assertSame("Leader was not active", Replica.State.ACTIVE, ssp.getState(leader));
 
     log.info("Healing partitioned replica at "+leader.getCoreUrl());
diff --git a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
index ce38941..526bea7 100644
--- a/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
@@ -399,7 +399,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
         notLeaders.size() == 1);
 
     Replica leader =
-        cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
+        cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).getLeader(testCollectionName,
"shard1", -1);
     String leaderNode = leader.getNodeName();
     assertNotNull("Could not find leader for shard1 of "+
         testCollectionName+"; clusterState: "+printClusterStateInfo(testCollectionName),
leader);
@@ -419,7 +419,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
       String currentLeaderName = null;
       try {
         Replica currentLeader =
-            cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
+            cloudClient.getZkStateReader().getShardStateProvider(testCollectionName). getLeader(testCollectionName,
"shard1", -1);
         currentLeaderName = currentLeader.getName();
       } catch (Exception exc) {}
 
@@ -430,7 +430,7 @@ public class HttpPartitionTest extends AbstractFullDistribZkTestBase {
     }
 
     Replica currentLeader =
-        cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
+        cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).getLeader(testCollectionName,
"shard1", -1);
     assertEquals(expectedNewLeaderCoreNodeName, currentLeader.getName());
 
     // TODO: This test logic seems to be timing dependent and fails on Jenkins
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPrepRecovery.java b/solr/core/src/test/org/apache/solr/cloud/TestPrepRecovery.java
index e593c63..d648b78 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPrepRecovery.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPrepRecovery.java
@@ -73,7 +73,7 @@ public class TestPrepRecovery extends SolrCloudTestCase {
         .process(solrClient);
 
     // now delete the leader
-    Replica leader = solrClient.getZkStateReader().getLeaderRetry(collectionName, "shard1");
+    Replica leader = solrClient.getZkStateReader().getShardStateProvider(collectionName).
getLeader(collectionName, "shard1", -1);
     CollectionAdminRequest.deleteReplica(collectionName, "shard1", leader.getName())
         .process(solrClient);
 
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 39dd068..ec4fd00 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
@@ -25,18 +25,18 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
 
 import com.google.common.collect.Lists;
-import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
-import org.apache.solr.cloud.ZkTestServer;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.BaseHttpSolrClient.RemoteSolrException;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.impl.HttpSolrClient;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
 import org.apache.solr.client.solrj.request.QueryRequest;
-import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.apache.solr.client.solrj.request.V2Request;
+import org.apache.solr.client.solrj.response.CollectionAdminResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.cloud.ZkTestServer;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.cloud.ClusterState;
@@ -541,7 +541,7 @@ public class TestCollectionAPI extends ReplicaPropertiesBase {
   private void clusterStatusRolesTest() throws Exception  {
     try (CloudSolrClient client = createCloudClient(null)) {
       client.connect();
-      Replica replica = client.getZkStateReader().getLeaderRetry(DEFAULT_COLLECTION, SHARD1);
+      Replica replica = client.getZkStateReader().getShardStateProvider(DEFAULT_COLLECTION).
getLeader(DEFAULT_COLLECTION, SHARD1, -1);
 
       ModifiableSolrParams params = new ModifiableSolrParams();
       params.set("action", CollectionParams.CollectionAction.ADDROLE.toString());
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 9c0c739..47dd66f 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -978,7 +978,9 @@ public class ZkStateReader implements SolrCloseable {
 
   /**
    * Get shard leader properties, with retry if none exist.
+   * use {@link ShardStateProvider#getLeader(String, String, int)} instead
    */
+  @Deprecated
   public Replica getLeaderRetry(String collection, String shard) throws InterruptedException
{
     return getLeaderRetry(collection, shard, GET_LEADER_RETRY_DEFAULT_TIMEOUT);
   }
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
index a552aaf..fb9c6b6 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
@@ -2083,7 +2083,7 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
     while (System.nanoTime() < timeout) {
       Replica tmp = null;
       try {
-        tmp = cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, shardId);
+        tmp = cloudClient.getZkStateReader().getShardStateProvider(testCollectionName).getLeader(testCollectionName,
shardId, -1);
       } catch (Exception exc) {}
       if (tmp != null && "active".equals(tmp.getStr(ZkStateReader.STATE_PROP))) {
         leader = tmp;
diff --git a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
index bffcd46..138346d 100644
--- a/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
+++ b/solr/test-framework/src/java/org/apache/solr/cloud/ChaosMonkey.java
@@ -354,7 +354,7 @@ public class ChaosMonkey {
       
       ZkNodeProps leader = null;
       try {
-        leader = zkStateReader.getLeaderRetry(collection, slice);
+        leader = zkStateReader.getShardStateProvider(collection).getLeader(collection, slice,
-1);
       } catch (Throwable t) {
         log.error("Could not get leader", t);
         return null;


Mime
View raw message