Class LearnerSyncThrottler
java.lang.Object
org.apache.zookeeper.server.quorum.LearnerSyncThrottler
Utility class to limit the number of concurrent syncs from a leader to
observers and followers or from a follower to observers.
LearnerHandler
objects should call beginSync(boolean) before sending a sync and
endSync() after finishing, successfully or not.-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionLearnerSyncThrottler(int maxConcurrentSyncs, LearnerSyncThrottler.SyncType syncType) Constructs a new instance limiting the concurrent number of syncs tomaxConcurrentSyncs. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidbeginSync(boolean essential) Indicates that a new sync is about to be sent.voidendSync()Indicates that a sync has been completed.intvoidsetMaxConcurrentSyncs(int maxConcurrentSyncs)
-
Constructor Details
-
LearnerSyncThrottler
public LearnerSyncThrottler(int maxConcurrentSyncs, LearnerSyncThrottler.SyncType syncType) throws IllegalArgumentException Constructs a new instance limiting the concurrent number of syncs tomaxConcurrentSyncs.- Parameters:
maxConcurrentSyncs- maximum concurrent number of syncssyncType- either a snapshot sync or a txn-based diff sync- Throws:
IllegalArgumentException- whenmaxConcurrentSyncsis less than 1
-
-
Method Details
-
beginSync
Indicates that a new sync is about to be sent.- Parameters:
essential- iftrue, do not throw an exception even if throttling limit is reached- Throws:
SyncThrottleException- if throttling limit has been exceeded andessential == false, even after waiting for the timeout period, if anyInterruptedException- if thread is interrupted while trying to start a sync; cannot happen if timeout is zero
-
endSync
public void endSync()Indicates that a sync has been completed. -
setMaxConcurrentSyncs
public void setMaxConcurrentSyncs(int maxConcurrentSyncs) -
getSyncInProgress
public int getSyncInProgress()
-