Class ZkLedgerIdGenerator

  • All Implemented Interfaces:
    java.io.Closeable, 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

      Fields 
      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<org.apache.zookeeper.data.ACL> zkAcls  
    • Constructor Summary

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

      • LOG

        static final org.slf4j.Logger LOG
      • LEDGER_ID_GEN_PREFIX

        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<org.apache.zookeeper.data.ACL> zkAcls
    • Constructor Detail

      • ZkLedgerIdGenerator

        public ZkLedgerIdGenerator​(org.apache.zookeeper.ZooKeeper zk,
                                   java.lang.String ledgersPath,
                                   java.lang.String idGenZnodeName,
                                   java.util.List<org.apache.zookeeper.data.ACL> 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<org.apache.zookeeper.data.ACL> zkAcls)
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException