Interface LedgerManager

    • 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 created
        metadata - 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 exist
        • BKException.BKZKException/BKException.BKMetaStoreException 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 Id
        version - 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 match
        • BKException.BKNoSuchLedgerExistsOnMetadataServerException if ledger not exist
        • BKException.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 exist
        • BKException.ZKException for other issues
      • writeLedgerMetadata

        java.util.concurrent.CompletableFuture<Versioned<LedgerMetadata>> writeLedgerMetadata​(long ledgerId,
                                                                                              LedgerMetadata metadata,
                                                                                              Version currentVersion)
        Write ledger metadata.
        Parameters:
        ledgerId - Ledger Id
        metadata - Ledger Metadata to write
        currentVersion - The version of the metadata we expect to be overwriting.
        Returns:
        Future which, when completed, contains the newly written metadata. Comleted with an exceptione:
        • BKException.BKMetadataVersionException if version in metadata doesn't match
        • BKException.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 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.

        Parameters:
        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.
      • 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