LearnerSyncThrottler (Apache ZooKeeper - Server 3.7.0 API)
Date: 2021-03-17

org.apache.zookeeper.server.quorum

## Class LearnerSyncThrottler

- java.lang.Object
- - org.apache.zookeeper.server.quorum.LearnerSyncThrottler

-     public class LearnerSyncThrottler
      extends Object

  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
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LearnerSyncThrottler.SyncType`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LearnerSyncThrottler(int maxConcurrentSyncs, LearnerSyncThrottler.SyncType syncType)` Constructs a new instance limiting the concurrent number of syncs to `maxConcurrentSyncs`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LearnerSyncThrottler

          public LearnerSyncThrottler(int maxConcurrentSyncs,
                                      LearnerSyncThrottler.SyncType syncType)
                               throws IllegalArgumentException

      Constructs a new instance limiting the concurrent number of syncs to `maxConcurrentSyncs`.
      Parameters:
        `maxConcurrentSyncs` - maximum concurrent number of syncs
        `syncType` - either a snapshot sync or a txn-based diff sync
      Throws:
        `IllegalArgumentException` - when `maxConcurrentSyncs` is less than 1

  - ### Method Detail

    - #### beginSync

          protected void beginSync(boolean essential)
                            throws SyncThrottleException,
                                   InterruptedException

      Indicates that a new sync is about to be sent.
      Parameters:
        `essential` - if `true`, do not throw an exception even if throttling limit is reached
      Throws:
        `SyncThrottleException` - if throttling limit has been exceeded and `essential == false`, even after waiting for the timeout period, if any
        `InterruptedException` - 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()

Copyright © 2008–2021 The Apache Software Foundation. All rights reserved.