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
This commit is contained in:
Mark Robert Miller 2013-12-29 23:52:58 +00:00
parent 54c0b2e946
commit 9b5c2e254b
5 changed files with 22 additions and 2 deletions

View File

@ -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
----------------------

View File

@ -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) {

View File

@ -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

View File

@ -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

View File

@ -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));