This is an automated email from the ASF dual-hosted git repository.
fangmin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git
The following commit(s) were added to refs/heads/master by this push:
new 0b504de ZOOKEEPER-3218: Add min notification interval property for
fast leader election
0b504de is described below
commit 0b504dec95b09acb05b40505588f7cda8131fea6
Author: Brian Nixon <[email protected]>
AuthorDate: Fri Jan 18 10:42:12 2019 +0800
ZOOKEEPER-3218: Add min notification interval property for fast leader
election
…to the new leader is too long,then session expired
Author: Brian Nixon <[email protected]>
Reviewers: [email protected], [email protected]
Closes #747 from enixon/noti-inter
---
.../src/main/resources/markdown/zookeeperAdmin.md | 18 +++++++++++++
.../server/quorum/FastLeaderElection.java | 31 ++++++++++++++++++++--
2 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
index d808b61..95787b7 100644
--- a/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
+++ b/zookeeper-docs/src/main/resources/markdown/zookeeperAdmin.md
@@ -720,6 +720,24 @@ property, when available, is noted below.
of the observers on restart. Set to "false" to disable this
feature. Default is "true"
+* *fastleader.minNotificationInterval* :
+ (Java system property: **zookeeper.fastleader.minNotificationInterval**)
+ Lower bound for length of time between two consecutive notification
+ checks on the leader election. This interval determines how long a
+ peer waits to check the set of election votes and effects how
+ quickly an election can resolve. The interval follows a backoff
+ strategy from the configured minimum (this) and the configured maximum
+ (fastleader.maxNotificationInterval) for long elections.
+
+* *fastleader.maxNotificationInterval* :
+ (Java system property: **zookeeper.fastleader.maxNotificationInterval**)
+ Upper bound for length of time between two consecutive notification
+ checks on the leader election. This interval determines how long a
+ peer waits to check the set of election votes and effects how
+ quickly an election can resolve. The interval follows a backoff
+ strategy from the configured minimum (fastleader.minNotificationInterval)
+ and the configured maximum (this) for long elections.
+
<a name="sc_clusterOptions"></a>
#### Cluster Options
diff --git
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/FastLeaderElection.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/FastLeaderElection.java
index 84e269c..9ebdabd 100644
---
a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/FastLeaderElection.java
+++
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/FastLeaderElection.java
@@ -68,7 +68,34 @@ public class FastLeaderElection implements Election {
* the system up again after long partitions. Currently 60 seconds.
*/
- final static int maxNotificationInterval = 60000;
+ private static int maxNotificationInterval = 60000;
+
+ /**
+ * Lower bound for notification check. The observer don't need to use
+ * the same lower bound as participant members
+ */
+ private static int minNotificationInterval = finalizeWait;
+
+ /**
+ * Minimum notification interval, default is equal to finalizeWait
+ */
+ public static final String MIN_NOTIFICATION_INTERVAL =
+ "zookeeper.fastleader.minNotificationInterval";
+
+ /**
+ * Maximum notification interval, default is 60s
+ */
+ public static final String MAX_NOTIFICATION_INTERVAL =
+ "zookeeper.fastleader.maxNotificationInterval";
+
+ static {
+ minNotificationInterval = Integer.getInteger(MIN_NOTIFICATION_INTERVAL,
+ minNotificationInterval);
+ LOG.info("{}={}", MIN_NOTIFICATION_INTERVAL, minNotificationInterval);
+ maxNotificationInterval = Integer.getInteger(MAX_NOTIFICATION_INTERVAL,
+ maxNotificationInterval);
+ LOG.info("{}={}", MAX_NOTIFICATION_INTERVAL, maxNotificationInterval);
+ }
/**
* Connection manager. Fast leader election uses TCP for
@@ -898,7 +925,7 @@ public class FastLeaderElection implements Election {
Map<Long, Vote> outofelection = new HashMap<Long, Vote>();
- int notTimeout = finalizeWait;
+ int notTimeout = minNotificationInterval;
synchronized(this){
logicalclock.incrementAndGet();