HBASE-18058 Zookeeper retry sleep time should have an upper limit (Allan Yang)

This commit is contained in:
tedyu 2017-05-18 15:50:59 -07:00
parent 6dc4190c07
commit d137991ccc
3 changed files with 13 additions and 5 deletions

View File

@ -100,20 +100,20 @@ public class RecoverableZooKeeper {
private static final int ID_LENGTH_SIZE = Bytes.SIZEOF_INT; private static final int ID_LENGTH_SIZE = Bytes.SIZEOF_INT;
public RecoverableZooKeeper(String quorumServers, int sessionTimeout, public RecoverableZooKeeper(String quorumServers, int sessionTimeout,
Watcher watcher, int maxRetries, int retryIntervalMillis) Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime)
throws IOException { throws IOException {
this(quorumServers, sessionTimeout, watcher, maxRetries, retryIntervalMillis, this(quorumServers, sessionTimeout, watcher, maxRetries, retryIntervalMillis, maxSleepTime,
null); null);
} }
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DE_MIGHT_IGNORE", @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="DE_MIGHT_IGNORE",
justification="None. Its always been this way.") justification="None. Its always been this way.")
public RecoverableZooKeeper(String quorumServers, int sessionTimeout, public RecoverableZooKeeper(String quorumServers, int sessionTimeout,
Watcher watcher, int maxRetries, int retryIntervalMillis, String identifier) Watcher watcher, int maxRetries, int retryIntervalMillis, int maxSleepTime, String identifier)
throws IOException { throws IOException {
// TODO: Add support for zk 'chroot'; we don't add it to the quorumServers String as we should. // TODO: Add support for zk 'chroot'; we don't add it to the quorumServers String as we should.
this.retryCounterFactory = this.retryCounterFactory =
new RetryCounterFactory(maxRetries+1, retryIntervalMillis); new RetryCounterFactory(maxRetries+1, retryIntervalMillis, maxSleepTime);
if (identifier == null || identifier.length() == 0) { if (identifier == null || identifier.length() == 0) {
// the identifier = processID@hostName // the identifier = processID@hostName

View File

@ -131,10 +131,11 @@ public class ZKUtil {
int retry = conf.getInt("zookeeper.recovery.retry", 3); int retry = conf.getInt("zookeeper.recovery.retry", 3);
int retryIntervalMillis = int retryIntervalMillis =
conf.getInt("zookeeper.recovery.retry.intervalmill", 1000); conf.getInt("zookeeper.recovery.retry.intervalmill", 1000);
int maxSleepTime = conf.getInt("zookeeper.recovery.retry.maxsleeptime", 60000);
zkDumpConnectionTimeOut = conf.getInt("zookeeper.dump.connection.timeout", zkDumpConnectionTimeOut = conf.getInt("zookeeper.dump.connection.timeout",
1000); 1000);
return new RecoverableZooKeeper(ensemble, timeout, watcher, return new RecoverableZooKeeper(ensemble, timeout, watcher,
retry, retryIntervalMillis, identifier); retry, retryIntervalMillis, maxSleepTime, identifier);
} }
/** /**

View File

@ -95,6 +95,13 @@ possible configurations would overwhelm and obscure the important.
<!--The above are the important configurations for getting hbase up <!--The above are the important configurations for getting hbase up
and running --> and running -->
<property>
<name>zookeeper.recovery.retry.maxsleeptime</name>
<value>60000</value>
<description>Max sleep time before retry zookeeper operations in milliseconds,
a max time is needed here so that sleep time won't grow unboundedly
</description>
</property>
<property> <property>
<name>hbase.local.dir</name> <name>hbase.local.dir</name>
<value>${hbase.tmp.dir}/local/</value> <value>${hbase.tmp.dir}/local/</value>