Class LongHierarchicalLedgerManager

  • All Implemented Interfaces:, java.lang.AutoCloseable, LedgerManager, org.apache.zookeeper.Watcher

    class LongHierarchicalLedgerManager
    extends AbstractHierarchicalLedgerManager
    LongHierarchical Ledger Manager which manages ledger meta in zookeeper using 5-level hierarchical znodes.

    LongHierarchicalLedgerManager splits the generated id into 5 parts (3-4-4-4-4):

     <level0 (3 digits)><level1 (4 digits)><level2 (4 digits)><level3 (4 digits)>
     <level4 (4 digits)>

    These 5 parts are used to form the actual ledger node path used to store ledger metadata:

     (ledgersRootPath) / level0 / level1 / level2 / level3 / L(level4)

    E.g Ledger 0000000000000000001 is split into 5 parts 000, 0000, 0000, 0000, 0001, which is stored in (ledgersRootPath)/000/0000/0000/0000/L0001. So each znode could have at most 10000 ledgers, which avoids errors during garbage collection due to lists of children that are too long.

    • Field Detail

      • LOG

        static final org.slf4j.Logger LOG
    • Constructor Detail

      • LongHierarchicalLedgerManager

        public LongHierarchicalLedgerManager​(AbstractConfiguration conf,
                                             org.apache.zookeeper.ZooKeeper zk)
        conf - Configuration object
        zk - ZooKeeper Client Handle
    • Method Detail

      • getLedgerId

        public long getLedgerId​(java.lang.String pathName)
        Description copied from class: AbstractZkLedgerManager
        Get ledger id from its znode ledger path.
        Specified by:
        getLedgerId in class AbstractZkLedgerManager
        pathName - Ledger path to store metadata
        ledger id
        Throws: - when the ledger path is invalid
      • getLedgerPath

        public java.lang.String getLedgerPath​(long ledgerId)
        Description copied from class: AbstractZkLedgerManager
        Get the znode path that is used to store ledger metadata.
        Specified by:
        getLedgerPath in class AbstractZkLedgerManager
        ledgerId - Ledger ID
        ledger node path
      • asyncProcessLedgers

        public void asyncProcessLedgers​(BookkeeperInternalCallbacks.Processor<java.lang.Long> processor,
                                        org.apache.zookeeper.AsyncCallback.VoidCallback finalCb,
                                        java.lang.Object context,
                                        int successRc,
                                        int failureRc)
        Description copied from interface: LedgerManager
        Loop to process all ledgers.

          After all ledgers were processed, finalCb will be triggered:
        • if all ledgers are processed done with OK, success rc will be passed to finalCb.
        • if some ledgers are processed failed, failure rc will be passed to finalCb.

        processor - Ledger Processor to process a specific ledger
        finalCb - Callback triggered after all ledgers are processed
        context - Context of final callback
        successRc - Success RC code passed to finalCb when callback
        failureRc - Failure RC code passed to finalCb when exceptions occurred.
      • getLedgerRanges

        public LedgerManager.LedgerRangeIterator getLedgerRanges​(long zkOpTimeoutMs)
        Description copied from interface: LedgerManager
        Loop to scan a range of metadata from metadata storage.
        zkOpTimeoutMs - Iterator considers timeout while fetching ledger-range from zk.
        will return a iterator of the Ranges
      • getLedgerParentNodeRegex

        protected java.lang.String getLedgerParentNodeRegex()
        Description copied from class: AbstractZkLedgerManager
        regex expression for name of top level parent znode for ledgers (in HierarchicalLedgerManager) or znode of a ledger (in FlatLedgerManager).
        Specified by:
        getLedgerParentNodeRegex in class AbstractZkLedgerManager