Class ZkLedgerIdGenerator

  • All Implemented Interfaces:, java.lang.AutoCloseable, LedgerIdGenerator

    public class ZkLedgerIdGenerator
    extends java.lang.Object
    implements LedgerIdGenerator
    ZooKeeper based ledger id generator class, which using EPHEMERAL_SEQUENTIAL with (ledgerIdGenPath)/ID- prefix to generate ledger id. Note zookeeper sequential counter has a format of %10d -- that is 10 digits with 0 (zero) padding, i.e. "<path>0000000001", so ledger id space is fundamentally limited to 9 billion.
    • Field Summary

      Modifier and Type Field Description
      (package private) static java.lang.String LEDGER_ID_GEN_PREFIX  
      (package private) java.lang.String ledgerPrefix  
      (package private) static org.slf4j.Logger LOG  
      (package private) org.apache.zookeeper.ZooKeeper zk  
      (package private) java.util.List<> zkAcls  
    • Constructor Summary

      Constructor Description
      ZkLedgerIdGenerator​(org.apache.zookeeper.ZooKeeper zk, java.lang.String ledgersPath, java.lang.String idGenZnodeName, java.util.List<> zkAcls)  
    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG

        static final java.lang.String LEDGER_ID_GEN_PREFIX
        See Also:
        Constant Field Values
      • zk

        final org.apache.zookeeper.ZooKeeper zk
      • ledgerPrefix

        final java.lang.String ledgerPrefix
      • zkAcls

        final java.util.List<> zkAcls
    • Constructor Detail

      • ZkLedgerIdGenerator

        public ZkLedgerIdGenerator​(org.apache.zookeeper.ZooKeeper zk,
                                   java.lang.String ledgersPath,
                                   java.lang.String idGenZnodeName,
                                   java.util.List<> zkAcls)
    • Method Detail

      • createLedgerPrefix

        public static java.lang.String createLedgerPrefix​(java.lang.String ledgersPath,
                                                          java.lang.String idGenZnodeName)
      • generateLedgerIdImpl

        public static void generateLedgerIdImpl​(BookkeeperInternalCallbacks.GenericCallback<java.lang.Long> cb,
                                                org.apache.zookeeper.ZooKeeper zk,
                                                java.lang.String ledgerPrefix,
                                                java.util.List<> zkAcls)
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface