Skip to content

Apache Lucene open-source search software

SOLR-5586: All ZkCmdExecutor's should be initialized with the zk client timeout

Mark Robert Miller9b5c2e254b7c
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index be8818be8de..9c5e0973c19 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -318,6 +318,9 @@ Bug Fixes
* SOLR-5583: ConcurrentUpdateSolrServer#blockUntilFinished may wait forever if
the executor service is shutdown. (Mark Miller)
+* SOLR-5586: All ZkCmdExecutor's should be initialized with the zk client
+ timeout. (Mark Miller)
+
Optimizations
----------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
index 2e6d2ef3dcf..f763b027ffe 100644
--- a/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
+++ b/solr/core/src/java/org/apache/solr/cloud/DistributedQueue.java
@@ -56,7 +56,7 @@ public class DistributedQueue {
public DistributedQueue(SolrZkClient zookeeper, String dir, List<ACL> acl) {
this.dir = dir;
- ZkCmdExecutor cmdExecutor = new ZkCmdExecutor(30);
+ ZkCmdExecutor cmdExecutor = new ZkCmdExecutor(zookeeper.getZkClientTimeout());
try {
cmdExecutor.ensureExists(dir, zookeeper);
} catch (KeeperException e) {
diff --git a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
index 0a8bdccf236..4a7768699dc 100644
--- a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
+++ b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
@@ -69,7 +69,7 @@ public class LeaderElector {
public LeaderElector(SolrZkClient zkClient) {
this.zkClient = zkClient;
- zkCmdExecutor = new ZkCmdExecutor((int) (zkClient.getZkClientTimeout()/1000.0 + 3000));
+ zkCmdExecutor = new ZkCmdExecutor(zkClient.getZkClientTimeout());
}
// for tests
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
index c23a2a1903c..e3be35c2e10 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionProcessorTest.java
@@ -218,6 +218,15 @@ public class OverseerCollectionProcessorTest extends SolrTestCaseJ4 {
}).anyTimes();
}
+
+ solrZkClientMock.getZkClientTimeout();
+ expectLastCall().andAnswer(new IAnswer<Object>() {
+ @Override
+ public Object answer() throws Throwable {
+ return 30000;
+ }
+ }).anyTimes();
+
clusterStateMock.hasCollection(anyObject(String.class));
expectLastCall().andAnswer(new IAnswer<Boolean>() {
@Override
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCmdExecutor.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCmdExecutor.java
index ad22877fe61..65d853971a7 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCmdExecutor.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkCmdExecutor.java
@@ -31,6 +31,14 @@ public class ZkCmdExecutor {
private int retryCount;
private List<ACL> acl = ZooDefs.Ids.OPEN_ACL_UNSAFE;
+ /**
+ * TODO: At this point, this should probably take a SolrZkClient in
+ * it's constructor.
+ *
+ * @param timeoutms
+ * the client timeout for the ZooKeeper clients that will be used
+ * with this class.
+ */
public ZkCmdExecutor(int timeoutms) {
double timeouts = timeoutms / 1000.0;
this.retryCount = Math.round(0.5f * ((float)Math.sqrt(8.0f * timeouts + 1.0f) - 1.0f));