public class LearnerSyncThrottler extends Object
LearnerHandler
objects should call beginSync(boolean)
before sending a sync and
endSync()
after finishing, successfully or not.Modifier and Type | Class and Description |
---|---|
static class |
LearnerSyncThrottler.SyncType |
Constructor and Description |
---|
LearnerSyncThrottler(int maxConcurrentSyncs,
LearnerSyncThrottler.SyncType syncType)
Constructs a new instance limiting the concurrent number of syncs to
maxConcurrentSyncs . |
Modifier and Type | Method and Description |
---|---|
protected void |
beginSync(boolean essential)
Indicates that a new sync is about to be sent.
|
void |
endSync()
Indicates that a sync has been completed.
|
int |
getSyncInProgress() |
void |
setMaxConcurrentSyncs(int maxConcurrentSyncs) |
public LearnerSyncThrottler(int maxConcurrentSyncs, LearnerSyncThrottler.SyncType syncType) throws IllegalArgumentException
maxConcurrentSyncs
.maxConcurrentSyncs
- maximum concurrent number of syncssyncType
- either a snapshot sync or a txn-based diff syncIllegalArgumentException
- when maxConcurrentSyncs
is less than 1protected void beginSync(boolean essential) throws SyncThrottleException, InterruptedException
essential
- if true
, do not throw an exception even
if throttling limit is reachedSyncThrottleException
- if throttling limit has been exceeded
and essential == 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 zeropublic void endSync()
public void setMaxConcurrentSyncs(int maxConcurrentSyncs)
public int getSyncInProgress()
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.