Package org.apache.bookkeeper.meta
Class MSLedgerManagerFactory.MsLedgerManager
- java.lang.Object
-
- org.apache.bookkeeper.meta.MSLedgerManagerFactory.MsLedgerManager
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LedgerManager
,MetastoreWatcher
- Enclosing class:
- MSLedgerManagerFactory
static class MSLedgerManagerFactory.MsLedgerManager extends java.lang.Object implements LedgerManager, MetastoreWatcher
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
MSLedgerManagerFactory.MsLedgerManager.MSLedgerRangeIterator
protected class
MSLedgerManagerFactory.MsLedgerManager.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) AbstractConfiguration
conf
(package private) static java.lang.String
IDGEN_ZNODE
(package private) MetastoreScannableTable
ledgerTable
protected java.util.concurrent.ConcurrentMap<java.lang.Long,java.util.Set<BookkeeperInternalCallbacks.LedgerMetadataListener>>
listeners
(package private) int
maxEntriesPerScan
(package private) MetaStore
metastore
(package private) java.util.concurrent.ScheduledExecutorService
scheduler
(package private) org.apache.zookeeper.ZooKeeper
zk
-
Constructor Summary
Constructors Constructor Description MsLedgerManager(AbstractConfiguration conf, org.apache.zookeeper.ZooKeeper zk, MetaStore metastore)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
asyncProcessLedgers(MetastoreCursor cursor, BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
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.void
close()
java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>>
createLedgerMetadata(long lid, LedgerMetadata metadata)
Create a new ledger with provided ledger id and metadata.(package private) void
doAsyncProcessLedgers(MetastoreCursor cursor, BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
LedgerManager.LedgerRangeIterator
getLedgerRanges(long zkOpTimeoutMs)
Loop to scan a range of metadata from metadata storage.static boolean
isSpecialZnode(java.lang.String znode)
Whether the znode a special znode.void
process(MSWatchedEvent e)
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.
-
-
-
Field Detail
-
zk
final org.apache.zookeeper.ZooKeeper zk
-
conf
final AbstractConfiguration conf
-
metastore
final MetaStore metastore
-
ledgerTable
final MetastoreScannableTable ledgerTable
-
maxEntriesPerScan
final int maxEntriesPerScan
-
IDGEN_ZNODE
static final java.lang.String IDGEN_ZNODE
- See Also:
- Constant Field Values
-
listeners
protected final java.util.concurrent.ConcurrentMap<java.lang.Long,java.util.Set<BookkeeperInternalCallbacks.LedgerMetadataListener>> listeners
-
scheduler
java.util.concurrent.ScheduledExecutorService scheduler
-
-
Constructor Detail
-
MsLedgerManager
MsLedgerManager(AbstractConfiguration conf, org.apache.zookeeper.ZooKeeper zk, MetaStore metastore)
-
-
Method Detail
-
process
public void process(MSWatchedEvent e)
- Specified by:
process
in interfaceMetastoreWatcher
-
registerLedgerMetadataListener
public void registerLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Description copied from interface:LedgerManager
Register the ledger metadata listener on ledgerId.- Specified by:
registerLedgerMetadataListener
in interfaceLedgerManager
- Parameters:
ledgerId
- ledger id.listener
- listener.
-
unregisterLedgerMetadataListener
public void unregisterLedgerMetadataListener(long ledgerId, BookkeeperInternalCallbacks.LedgerMetadataListener listener)
Description copied from interface:LedgerManager
Unregister the ledger metadata listener on ledgerId.- Specified by:
unregisterLedgerMetadataListener
in interfaceLedgerManager
- Parameters:
ledgerId
- ledger id.listener
- ledger metadata listener.
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
createLedgerMetadata
public java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> createLedgerMetadata(long lid, LedgerMetadata metadata)
Description copied from interface:LedgerManager
Create a new ledger with provided ledger id and metadata.- Specified by:
createLedgerMetadata
in interfaceLedgerManager
- Parameters:
lid
- 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
public java.util.concurrent.CompletableFuture<java.lang.Void> removeLedgerMetadata(long ledgerId, Version version)
Description copied from interface:LedgerManager
Remove a specified ledger metadata by ledgerId and version.- Specified by:
removeLedgerMetadata
in interfaceLedgerManager
- 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
public java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> readLedgerMetadata(long ledgerId)
Description copied from interface:LedgerManager
Read ledger metadata of a specified ledger.- Specified by:
readLedgerMetadata
in interfaceLedgerManager
- 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
public java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> writeLedgerMetadata(long ledgerId, LedgerMetadata metadata, Version currentVersion)
Description copied from interface:LedgerManager
Write ledger metadata.- Specified by:
writeLedgerMetadata
in interfaceLedgerManager
- 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
-
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.
- Specified by:
asyncProcessLedgers
in interfaceLedgerManager
- 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.
-
asyncProcessLedgers
void asyncProcessLedgers(MetastoreCursor cursor, BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
-
doAsyncProcessLedgers
void doAsyncProcessLedgers(MetastoreCursor cursor, BookkeeperInternalCallbacks.Processor<java.lang.Long> processor, org.apache.zookeeper.AsyncCallback.VoidCallback finalCb, java.lang.Object context, int successRc, int failureRc)
-
getLedgerRanges
public LedgerManager.LedgerRangeIterator getLedgerRanges(long zkOpTimeoutMs)
Description copied from interface:LedgerManager
Loop to scan a range of metadata from metadata storage.- Specified by:
getLedgerRanges
in interfaceLedgerManager
- Parameters:
zkOpTimeoutMs
- Iterator considers timeout while fetching ledger-range from zk.- Returns:
- will return a iterator of the Ranges
-
isSpecialZnode
public static boolean isSpecialZnode(java.lang.String znode)
Whether the znode a special znode.- Parameters:
znode
- Znode Name- Returns:
- true if the znode is a special znode otherwise false
-
-