Class LearnerSnapshotThrottler
- java.lang.Object
-
- org.apache.zookeeper.server.quorum.LearnerSnapshotThrottler
-
public class LearnerSnapshotThrottler extends java.lang.Object
Utility class to limit the number of concurrent snapshots from a leader to observers and followers.LearnerHandler
objects should callbeginSnapshot(boolean)
before sending a snapshot andendSnapshot()
after finishing, successfully or not.
-
-
Constructor Summary
Constructors Constructor Description LearnerSnapshotThrottler(int maxConcurrentSnapshots)
LearnerSnapshotThrottler(int maxConcurrentSnapshots, long timeoutMillis)
Constructs a new instance limiting the concurrent number of snapshots tomaxConcurrentSnapshots
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LearnerSnapshot
beginSnapshot(boolean essential)
Indicates that a new snapshot is about to be sent.void
endSnapshot()
Indicates that a snapshot has been completed.
-
-
-
Constructor Detail
-
LearnerSnapshotThrottler
public LearnerSnapshotThrottler(int maxConcurrentSnapshots, long timeoutMillis)
Constructs a new instance limiting the concurrent number of snapshots tomaxConcurrentSnapshots
.- Parameters:
maxConcurrentSnapshots
- maximum concurrent number of snapshotstimeoutMillis
- milliseconds to attempt to wait when attempting to begin a snapshot that would otherwise be throttled; a value of zero means no waiting will be attempted- Throws:
java.lang.IllegalArgumentException
- whentimeoutMillis
is negative ormaxConcurrentSnaphots
is less than 1
-
LearnerSnapshotThrottler
public LearnerSnapshotThrottler(int maxConcurrentSnapshots)
-
-
Method Detail
-
beginSnapshot
public LearnerSnapshot beginSnapshot(boolean essential) throws SnapshotThrottleException, java.lang.InterruptedException
Indicates that a new snapshot is about to be sent.- Parameters:
essential
- iftrue
, do not throw an exception even if throttling limit is reached- Throws:
SnapshotThrottleException
- if throttling limit has been exceeded andessential == false
, even after waiting for the timeout period, if anyjava.lang.InterruptedException
- if thread is interrupted while trying to start a snapshot; cannot happen if timeout is zero
-
endSnapshot
public void endSnapshot()
Indicates that a snapshot has been completed.
-
-