Package org.apache.bookkeeper.meta
Interface LedgerManager
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.io.Closeable
- All Known Implementing Classes:
AbstractHierarchicalLedgerManager
,AbstractZkLedgerManager
,CleanupLedgerManager
,FlatLedgerManager
,HierarchicalLedgerManager
,LegacyHierarchicalLedgerManager
,LongHierarchicalLedgerManager
,MSLedgerManagerFactory.MsLedgerManager
,NullMetadataBookieDriver.NullLedgerManager
public interface LedgerManager extends java.io.Closeable
LedgerManager takes responsibility of ledger management in client side.- How to store ledger meta (e.g. in ZooKeeper or other key/value store)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
LedgerManager.LedgerRange
Used to represent the Ledgers range returned from the current scan.static interface
LedgerManager.LedgerRangeIterator
Interface of the ledger meta range iterator from storage (e.g.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
asyncProcessLedgers(BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
Loop to process all ledgers.java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>>
createLedgerMetadata(long ledgerId, LedgerMetadata metadata)
Create a new ledger with provided ledger id and metadata.LedgerManager.LedgerRangeIterator
getLedgerRanges(long zkOpTimeOutMs)
Loop to scan a range of metadata from metadata storage.java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>>
readLedgerMetadata(long ledgerId)
Read ledger metadata of a specified ledger.void
registerLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Register the ledger metadata listener on ledgerId.java.util.concurrent.CompletableFuture<java.lang.Void>
removeLedgerMetadata(long ledgerId, Version version)
Remove a specified ledger metadata by ledgerId and version.void
unregisterLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Unregister the ledger metadata listener on ledgerId.java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>>
writeLedgerMetadata(long ledgerId, LedgerMetadata metadata, Version currentVersion)
Write ledger metadata.
-
-
-
Method Detail
-
createLedgerMetadata
java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> createLedgerMetadata(long ledgerId, LedgerMetadata metadata)
Create a new ledger with provided ledger id and metadata.- Parameters:
ledgerId
- Ledger id provided to be createdmetadata
- Metadata provided when creating the new ledger- Returns:
- Future which, when completed returns the metadata of the newly created ledger.
Completed with an exception:
BKException.BKLedgerExistException
if given ledger id existBKException.ZKException
/BKException.BKMetadataSerializationException
for other issues
-
removeLedgerMetadata
java.util.concurrent.CompletableFuture<java.lang.Void> removeLedgerMetadata(long ledgerId, Version version)
Remove a specified ledger metadata by ledgerId and version.- Parameters:
ledgerId
- Ledger Idversion
- Ledger metadata version- Returns:
- Future which, when completed, denotes that the ledger metadata has been removed.
Completed with an exception:
BKException.BKMetadataVersionException
if version doesn't matchBKException.BKNoSuchLedgerExistsOnMetadataServerException
if ledger not existBKException.ZKException
for other issues
-
readLedgerMetadata
java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> readLedgerMetadata(long ledgerId)
Read ledger metadata of a specified ledger.- Parameters:
ledgerId
- Ledger Id- Returns:
- Future which, when completed, contains the requested versioned metadata.
Completed with an exception::
BKException.BKNoSuchLedgerExistsOnMetadataServerException
if ledger not existBKException.ZKException
for other issues
-
writeLedgerMetadata
java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> writeLedgerMetadata(long ledgerId, LedgerMetadata metadata, Version currentVersion)
Write ledger metadata.- Parameters:
ledgerId
- Ledger Idmetadata
- Ledger Metadata to writecurrentVersion
- The version of the metadata we expect to be overwriting.- Returns:
- Future which, when completed, contains the newly written metadata.
Completed with an exception:
BKException.BKMetadataVersionException
if version in metadata doesn't matchBKException.ZKException
for other issue
-
registerLedgerMetadataListener
void registerLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Register the ledger metadata listener on ledgerId.- Parameters:
ledgerId
- ledger id.listener
- listener.
-
unregisterLedgerMetadataListener
void unregisterLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Unregister the ledger metadata listener on ledgerId.- Parameters:
ledgerId
- ledger id.listener
- ledger metadata listener.
-
asyncProcessLedgers
void asyncProcessLedgers(BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
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 processedcontext
- Context of final callbacksuccessRc
- Success RC code passed to finalCb when callbackfailureRc
- Failure RC code passed to finalCb when exceptions occurred.
-
getLedgerRanges
LedgerManager.LedgerRangeIterator getLedgerRanges(long zkOpTimeOutMs)
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
-
-