Class LedgerMetadataImpl

java.lang.Object
org.apache.bookkeeper.client.LedgerMetadataImpl
All Implemented Interfaces:
LedgerMetadata

class LedgerMetadataImpl extends Object implements LedgerMetadata
This class encapsulates all the ledger metadata that is persistently stored in metadata store.

It provides parsing and serialization methods of such metadata.

  • Field Details

    • LOG

      static final org.slf4j.Logger LOG
    • storeCtime

      final boolean storeCtime
  • Constructor Details

  • Method Details

    • getLedgerId

      public long getLedgerId()
      Description copied from interface: LedgerMetadata
      Returns the id of this ledger.
      Specified by:
      getLedgerId in interface LedgerMetadata
      Returns:
      the id of this ledger.
    • getAllEnsembles

      public NavigableMap<Long,? extends List<BookieId>> getAllEnsembles()
      Description copied from interface: LedgerMetadata
      Returns all the ensembles of this ledger.
      Specified by:
      getAllEnsembles in interface LedgerMetadata
      Returns:
      all the ensembles of this ledger.
    • getEnsembleSize

      public int getEnsembleSize()
      Description copied from interface: LedgerMetadata
      Returns the ensemble size of this ledger.
      Specified by:
      getEnsembleSize in interface LedgerMetadata
      Returns:
      the ensemble size of this ledger.
    • getWriteQuorumSize

      public int getWriteQuorumSize()
      Description copied from interface: LedgerMetadata
      Returns the write quorum size of this ledger.
      Specified by:
      getWriteQuorumSize in interface LedgerMetadata
      Returns:
      the write quorum size of this ledger.
    • getAckQuorumSize

      public int getAckQuorumSize()
      Description copied from interface: LedgerMetadata
      Returns the ack quorum size of this ledger.
      Specified by:
      getAckQuorumSize in interface LedgerMetadata
      Returns:
      the ack quorum size of this ledger.
    • getCtime

      public long getCtime()
      Description copied from interface: LedgerMetadata
      Returns the creation timestamp of this ledger.
      Specified by:
      getCtime in interface LedgerMetadata
      Returns:
      the creation timestamp of this ledger.
    • hasPassword

      public boolean hasPassword()
      In versions 4.1.0 and below, the digest type and password were not stored in the metadata.
      Specified by:
      hasPassword in interface LedgerMetadata
      Returns:
      whether the password has been stored in the metadata
    • getPassword

      public byte[] getPassword()
      Description copied from interface: LedgerMetadata
      Get the password for the ledger. For ledgers created with version 4.1.0 or older, an empty byte array is returned.
      Specified by:
      getPassword in interface LedgerMetadata
      Returns:
      the password for the ledger.
    • getDigestType

      public DigestType getDigestType()
      Description copied from interface: LedgerMetadata
      Returns the digest type used by this ledger. May return null if the ledger was created with version 4.1.0 or below.
      Specified by:
      getDigestType in interface LedgerMetadata
      Returns:
      the digest type used by this ledger.
    • getLastEntryId

      public long getLastEntryId()
      Description copied from interface: LedgerMetadata
      Returns the last entry id of this ledger.

      If this ledger is not sealed LedgerMetadata.isClosed(), it returns -1L.

      Specified by:
      getLastEntryId in interface LedgerMetadata
      Returns:
      the last entry id of this ledger if it is sealed, otherwise -1.
    • getLength

      public long getLength()
      Description copied from interface: LedgerMetadata
      Returns the length of this ledger.

      If this ledger is not sealed LedgerMetadata.isClosed(), it returns 0.

      Specified by:
      getLength in interface LedgerMetadata
      Returns:
      the length of this ledger if it is sealed, otherwise 0.
    • isClosed

      public boolean isClosed()
      Description copied from interface: LedgerMetadata
      Returns whether the ledger is sealed or not.
      Specified by:
      isClosed in interface LedgerMetadata
      Returns:
      true if the ledger is sealed, otherwise false.
    • getState

      public LedgerMetadata.State getState()
      Description copied from interface: LedgerMetadata
      Returns the state of the metadata.
      Specified by:
      getState in interface LedgerMetadata
      Returns:
      the state of the metadata.
    • getEnsembleAt

      public List<BookieId> getEnsembleAt(long entryId)
      Description copied from interface: LedgerMetadata
      Returns the ensemble at the given entryId.
      Specified by:
      getEnsembleAt in interface LedgerMetadata
      Parameters:
      entryId - the entry id to retrieve its ensemble information
      Returns:
      the ensemble which contains the given entryId.
    • getCustomMetadata

      public Map<String,byte[]> getCustomMetadata()
      Description copied from interface: LedgerMetadata
      Returns the custom metadata stored with the ledgers.
      Specified by:
      getCustomMetadata in interface LedgerMetadata
      Returns:
      the custom metadata stored with the ledgers.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toSafeString

      public String toSafeString()
      Returns a string representation of this LedgerMetadata object by filtering out the password field.
      Specified by:
      toSafeString in interface LedgerMetadata
      Returns:
      a string representation of the object without password field in it.
    • getMetadataFormatVersion

      public int getMetadataFormatVersion()
      Description copied from interface: LedgerMetadata
      Get the format version which should be used to serialize the metadata.
      Specified by:
      getMetadataFormatVersion in interface LedgerMetadata
      Returns:
      the format version.
    • shouldStoreCtime

      boolean shouldStoreCtime()
    • getCToken

      public long getCToken()
      Description copied from interface: LedgerMetadata
      Get the unique creator token of the Ledger.
      Specified by:
      getCToken in interface LedgerMetadata
      Returns:
      the creator token
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object