From 9b5c2e254b7c2f56387dfcaf8312293e93111722 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Sun, 29 Dec 2013 23:52:58 +0000 Subject: [PATCH] SOLR-5586: All ZkCmdExecutor's should be initialized with the zk client timeout git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1554101 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../src/java/org/apache/solr/cloud/DistributedQueue.java | 2 +- .../src/java/org/apache/solr/cloud/LeaderElector.java | 2 +- .../solr/cloud/OverseerCollectionProcessorTest.java | 9 +++++++++ .../java/org/apache/solr/common/cloud/ZkCmdExecutor.java | 8 ++++++++ 5 files changed, 22 insertions(+), 2 deletions(-) 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) { 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() { + @Override + public Object answer() throws Throwable { + return 30000; + } + }).anyTimes(); + clusterStateMock.hasCollection(anyObject(String.class)); expectLastCall().andAnswer(new IAnswer() { @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 = 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));