zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] jhuan31 commented on a change in pull request #995: ZOOKEEPER-3437: Improve sync throttling on a learner master
Date Mon, 01 Jul 2019 22:14:08 GMT
jhuan31 commented on a change in pull request #995: ZOOKEEPER-3437: Improve sync throttling
on a learner master
URL: https://github.com/apache/zookeeper/pull/995#discussion_r299237261
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/LearnerMaster.java
 ##########
 @@ -29,18 +31,81 @@
 /**
  * interface for keeping Observers in sync
  */
-public interface LearnerMaster {
+public abstract class LearnerMaster {
+    private static final Logger LOG = LoggerFactory.getLogger(LearnerMaster.class);
+
+    // Throttle when there are too many concurrent snapshots being sent to observers
+    private static final String MAX_CONCURRENT_SNAPSYNCS = "zookeeper.leader.maxConcurrentSnapSyncs";
+    private static final int DEFAULT_CONCURRENT_SNAPSYNCS;
+
+    // Throttle when there are too many concurrent diff syncs being sent to observers
+    private static final String MAX_CONCURRENT_DIFF_SYNCS = "zookeeper.leader.maxConcurrentDiffSyncs";
+    private static final int DEFAULT_CONCURRENT_DIFF_SYNCS;
+
+    static {
+        DEFAULT_CONCURRENT_SNAPSYNCS = Integer.getInteger(MAX_CONCURRENT_SNAPSYNCS, 10);
+        LOG.info(MAX_CONCURRENT_SNAPSYNCS + " = " + DEFAULT_CONCURRENT_SNAPSYNCS);
+
+        DEFAULT_CONCURRENT_DIFF_SYNCS = Integer.getInteger(MAX_CONCURRENT_DIFF_SYNCS, 100);
+        LOG.info(MAX_CONCURRENT_DIFF_SYNCS + " = " + DEFAULT_CONCURRENT_DIFF_SYNCS);
+    }
+
+    private volatile int maxConcurrentSnapSyncs = DEFAULT_CONCURRENT_SNAPSYNCS;
+    private volatile int maxConcurrentDiffSyncs = DEFAULT_CONCURRENT_DIFF_SYNCS;
+
+    private final LearnerSyncThrottler learnerSnapSyncThrottler =
+            new LearnerSyncThrottler(maxConcurrentSnapSyncs, LearnerSyncThrottler.SyncType.SNAP);
+
+    private final LearnerSyncThrottler learnerDiffSyncThrottler =
+            new LearnerSyncThrottler(maxConcurrentDiffSyncs,LearnerSyncThrottler.SyncType.DIFF);
+
+    public int getMaxConcurrentSnapSyncs() {
+        return maxConcurrentSnapSyncs;
+    }
+
+    public void setMaxConcurrentSnapSyncs(int maxConcurrentSnapSyncs) {
 
 Review comment:
   This function is called in FollwerBean and LeaderBean. No, we can't set different values
for Leader and ObserverMaster. We did have a discussion whether to support different settings
for Leader and ObserverMaster. Since we don't see a need for different settings and since
we have too many flags/settings already, we decide to go with one setting for both Leader
and ObserverMaster

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message