Package org.apache.bookkeeper.meta
Class FlatLedgerManager
- java.lang.Object
-
- org.apache.bookkeeper.meta.AbstractZkLedgerManager
-
- org.apache.bookkeeper.meta.FlatLedgerManager
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LedgerManager
,org.apache.zookeeper.Watcher
class FlatLedgerManager extends AbstractZkLedgerManager
Manage all ledgers in a single zk node.All ledgers' metadata are put in a single zk node, created using zk sequential node. Each ledger node is prefixed with 'L'.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.bookkeeper.meta.AbstractZkLedgerManager
AbstractZkLedgerManager.CancelWatchLedgerMetadataTask, AbstractZkLedgerManager.ReadLedgerMetadataTask
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.meta.LedgerManager
LedgerManager.LedgerRange, LedgerManager.LedgerRangeIterator
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static org.slf4j.Logger
LOG
-
Fields inherited from class org.apache.bookkeeper.meta.AbstractZkLedgerManager
conf, ledgerRootPath, listeners, scheduler, zk, ZK_CONNECT_BACKOFF_MS
-
-
Constructor Summary
Constructors Constructor Description FlatLedgerManager(AbstractConfiguration conf, org.apache.zookeeper.ZooKeeper zk)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
asyncProcessLedgers(BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object ctx, int successRc, int failureRc)
Loop to process all ledgers.long
getLedgerId(java.lang.String nodeName)
Get ledger id from its znode ledger path.protected java.lang.String
getLedgerParentNodeRegex()
regex expression for name of top level parent znode for ledgers (in HierarchicalLedgerManager) or znode of a ledger (in FlatLedgerManager).java.lang.String
getLedgerPath(long ledgerId)
Get the znode path that is used to store ledger metadata.LedgerManager.LedgerRangeIterator
getLedgerRanges(long zkOpTimeoutMs)
Loop to scan a range of metadata from metadata storage.-
Methods inherited from class org.apache.bookkeeper.meta.AbstractZkLedgerManager
asyncProcessLedgersInSingleNode, close, createLedgerMetadata, isLeadgerIdGeneratorZnode, isLedgerParentNode, isSpecialZnode, ledgerListToSet, process, readLedgerMetadata, readLedgerMetadata, registerLedgerMetadataListener, removeLedgerMetadata, unregisterLedgerMetadataListener, writeLedgerMetadata
-
-
-
-
Constructor Detail
-
FlatLedgerManager
public FlatLedgerManager(AbstractConfiguration conf, org.apache.zookeeper.ZooKeeper zk)
Constructor.- Parameters:
conf
- Configuration objectzk
- ZooKeeper Client Handle- Throws:
java.io.IOException
- when version is not compatible
-
-
Method Detail
-
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 classAbstractZkLedgerManager
- Parameters:
ledgerId
- Ledger ID- Returns:
- ledger node path
-
getLedgerId
public long getLedgerId(java.lang.String nodeName) throws java.io.IOException
Description copied from class:AbstractZkLedgerManager
Get ledger id from its znode ledger path.- Specified by:
getLedgerId
in classAbstractZkLedgerManager
- Parameters:
nodeName
- Ledger path to store metadata- Returns:
- ledger id
- Throws:
java.io.IOException
- when the ledger path is invalid
-
asyncProcessLedgers
public void asyncProcessLedgers(BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object ctx, 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.
- Parameters:
processor
- Ledger Processor to process a specific ledgerfinalCb
- Callback triggered after all ledgers are processedctx
- Context of final callbacksuccessRc
- Success RC code passed to finalCb when callbackfailureRc
- 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.- Parameters:
zkOpTimeoutMs
- Iterator considers timeout while fetching ledger-range from zk.- Returns:
- 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 classAbstractZkLedgerManager
- Returns:
-
-