Class HierarchicalLedgerManager

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

    class HierarchicalLedgerManager
    extends AbstractHierarchicalLedgerManager
    HierarchicalLedgerManager makes use of both LongHierarchicalLedgerManager and LegacyHierarchicalLedgerManager to extend the 31-bit ledger id range of the LegacyHierarchicalLedgerManager to that of the LongHierarchicalLedgerManager while remaining backwards-compatible with the legacy manager.

    In order to achieve backwards-compatibility, the HierarchicalLedgerManager forwards requests relating to ledger IDs which are < Integer.MAX_INT to the LegacyHierarchicalLedgerManager. The new 5-part directory structure will not appear until a ledger with an ID >= Integer.MAX_INT is created.

    See Also:
    LongHierarchicalLedgerManager, LegacyHierarchicalLedgerManager
    • Constructor Detail

      • HierarchicalLedgerManager

        public HierarchicalLedgerManager​(AbstractConfiguration conf,
                                         org.apache.zookeeper.ZooKeeper zk)
    • Method Detail

      • 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 triggerred:
        • if all ledgers are processed done with OK, success rc will be passed to finalCb.
        • if some ledgers are prcoessed 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 occured.
      • 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
      • getLedgerId

        protected long getLedgerId​(java.lang.String ledgerPath)
        Description copied from class: AbstractZkLedgerManager
        Get ledger id from its znode ledger path.
        Specified by:
        getLedgerId in class AbstractZkLedgerManager
        ledgerPath - Ledger path to store metadata
        ledger id
        Throws: - when the ledger path is invalid
      • 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
      • close

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