Package org.apache.bookkeeper.meta
Class NullMetadataBookieDriver.NullLedgerManager
- java.lang.Object
-
- org.apache.bookkeeper.meta.NullMetadataBookieDriver.NullLedgerManager
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LedgerManager
- Enclosing class:
- NullMetadataBookieDriver
public static class NullMetadataBookieDriver.NullLedgerManager extends java.lang.Object implements LedgerManager
A no-op implementation of LedgerManager.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.meta.LedgerManager
LedgerManager.LedgerRange, LedgerManager.LedgerRangeIterator
-
-
Constructor Summary
Constructors Constructor Description NullLedgerManager()
-
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 context, int successRc, int failureRc)
Loop to process all ledgers.void
close()
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
public java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> createLedgerMetadata(long ledgerId, LedgerMetadata metadata)
Description copied from interface:LedgerManager
Create a new ledger with provided ledger id and metadata.- Specified by:
createLedgerMetadata
in interfaceLedgerManager
- 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
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
-
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.
-
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.
-
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
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
-