Package org.apache.bookkeeper.client
Class LedgerMetadataImpl
- java.lang.Object
-
- org.apache.bookkeeper.client.LedgerMetadataImpl
-
- All Implemented Interfaces:
LedgerMetadata
class LedgerMetadataImpl extends java.lang.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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.bookkeeper.client.api.LedgerMetadata
LedgerMetadata.State
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static org.slf4j.LoggerLOG(package private) booleanstoreCtime
-
Constructor Summary
Constructors Constructor Description LedgerMetadataImpl(long ledgerId, int metadataFormatVersion, int ensembleSize, int writeQuorumSize, int ackQuorumSize, LedgerMetadata.State state, java.util.Optional<java.lang.Long> lastEntryId, java.util.Optional<java.lang.Long> length, java.util.Map<java.lang.Long,java.util.List<BookieId>> ensembles, java.util.Optional<DigestType> digestType, java.util.Optional<byte[]> password, long ctime, boolean storeCtime, long cToken, java.util.Map<java.lang.String,byte[]> customMetadata)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(java.lang.Object other)booleanequals(java.lang.Object o)intgetAckQuorumSize()Returns the ack quorum size of this ledger.java.util.NavigableMap<java.lang.Long,? extends java.util.List<BookieId>>getAllEnsembles()Returns all the ensembles of this ledger.longgetCtime()Returns the creation timestamp of this ledger.longgetCToken()Get the unique creator token of the Ledger.java.util.Map<java.lang.String,byte[]>getCustomMetadata()Returns the custom metadata stored with the ledgers.DigestTypegetDigestType()Returns the digest type used by this ledger.java.util.List<BookieId>getEnsembleAt(long entryId)Returns the ensemble at the givenentryId.intgetEnsembleSize()Returns the ensemble size of this ledger.longgetLastEntryId()Returns the last entry id of this ledger.longgetLedgerId()Returns the id of this ledger.longgetLength()Returns the length of this ledger.intgetMetadataFormatVersion()Get the format version which should be used to serialize the metadata.byte[]getPassword()Get the password for the ledger.LedgerMetadata.StategetState()Returns the state of the metadata.intgetWriteQuorumSize()Returns the write quorum size of this ledger.inthashCode()booleanhasPassword()In versions 4.1.0 and below, the digest type and password were not stored in the metadata.booleanisClosed()Returns whether the ledger is sealed or not.(package private) booleanshouldStoreCtime()java.lang.StringtoSafeString()Returns a string representation of this LedgerMetadata object by filtering out the password field.java.lang.StringtoString()
-
-
-
Constructor Detail
-
LedgerMetadataImpl
LedgerMetadataImpl(long ledgerId, int metadataFormatVersion, int ensembleSize, int writeQuorumSize, int ackQuorumSize, LedgerMetadata.State state, java.util.Optional<java.lang.Long> lastEntryId, java.util.Optional<java.lang.Long> length, java.util.Map<java.lang.Long,java.util.List<BookieId>> ensembles, java.util.Optional<DigestType> digestType, java.util.Optional<byte[]> password, long ctime, boolean storeCtime, long cToken, java.util.Map<java.lang.String,byte[]> customMetadata)
-
-
Method Detail
-
getLedgerId
public long getLedgerId()
Description copied from interface:LedgerMetadataReturns the id of this ledger.- Specified by:
getLedgerIdin interfaceLedgerMetadata- Returns:
- the id of this ledger.
-
getAllEnsembles
public java.util.NavigableMap<java.lang.Long,? extends java.util.List<BookieId>> getAllEnsembles()
Description copied from interface:LedgerMetadataReturns all the ensembles of this ledger.- Specified by:
getAllEnsemblesin interfaceLedgerMetadata- Returns:
- all the ensembles of this ledger.
-
getEnsembleSize
public int getEnsembleSize()
Description copied from interface:LedgerMetadataReturns the ensemble size of this ledger.- Specified by:
getEnsembleSizein interfaceLedgerMetadata- Returns:
- the ensemble size of this ledger.
-
getWriteQuorumSize
public int getWriteQuorumSize()
Description copied from interface:LedgerMetadataReturns the write quorum size of this ledger.- Specified by:
getWriteQuorumSizein interfaceLedgerMetadata- Returns:
- the write quorum size of this ledger.
-
getAckQuorumSize
public int getAckQuorumSize()
Description copied from interface:LedgerMetadataReturns the ack quorum size of this ledger.- Specified by:
getAckQuorumSizein interfaceLedgerMetadata- Returns:
- the ack quorum size of this ledger.
-
getCtime
public long getCtime()
Description copied from interface:LedgerMetadataReturns the creation timestamp of this ledger.- Specified by:
getCtimein interfaceLedgerMetadata- 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:
hasPasswordin interfaceLedgerMetadata- Returns:
- whether the password has been stored in the metadata
-
getPassword
public byte[] getPassword()
Description copied from interface:LedgerMetadataGet the password for the ledger. For ledgers created with version 4.1.0 or older, an empty byte array is returned.- Specified by:
getPasswordin interfaceLedgerMetadata- Returns:
- the password for the ledger.
-
getDigestType
public DigestType getDigestType()
Description copied from interface:LedgerMetadataReturns the digest type used by this ledger. May return null if the ledger was created with version 4.1.0 or below.- Specified by:
getDigestTypein interfaceLedgerMetadata- Returns:
- the digest type used by this ledger.
-
getLastEntryId
public long getLastEntryId()
Description copied from interface:LedgerMetadataReturns the last entry id of this ledger.If this ledger is not sealed
LedgerMetadata.isClosed(), it returns-1L.- Specified by:
getLastEntryIdin interfaceLedgerMetadata- Returns:
- the last entry id of this ledger if it is sealed, otherwise -1.
-
getLength
public long getLength()
Description copied from interface:LedgerMetadataReturns the length of this ledger.If this ledger is not sealed
LedgerMetadata.isClosed(), it returns0.- Specified by:
getLengthin interfaceLedgerMetadata- Returns:
- the length of this ledger if it is sealed, otherwise 0.
-
isClosed
public boolean isClosed()
Description copied from interface:LedgerMetadataReturns whether the ledger is sealed or not.- Specified by:
isClosedin interfaceLedgerMetadata- Returns:
- true if the ledger is sealed, otherwise false.
-
getState
public LedgerMetadata.State getState()
Description copied from interface:LedgerMetadataReturns the state of the metadata.- Specified by:
getStatein interfaceLedgerMetadata- Returns:
- the state of the metadata.
-
getEnsembleAt
public java.util.List<BookieId> getEnsembleAt(long entryId)
Description copied from interface:LedgerMetadataReturns the ensemble at the givenentryId.- Specified by:
getEnsembleAtin interfaceLedgerMetadata- Parameters:
entryId- the entry id to retrieve its ensemble information- Returns:
- the ensemble which contains the given
entryId.
-
getCustomMetadata
public java.util.Map<java.lang.String,byte[]> getCustomMetadata()
Description copied from interface:LedgerMetadataReturns the custom metadata stored with the ledgers.- Specified by:
getCustomMetadatain interfaceLedgerMetadata- Returns:
- the custom metadata stored with the ledgers.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toSafeString
public java.lang.String toSafeString()
Returns a string representation of this LedgerMetadata object by filtering out the password field.- Specified by:
toSafeStringin interfaceLedgerMetadata- Returns:
- a string representation of the object without password field in it.
-
getMetadataFormatVersion
public int getMetadataFormatVersion()
Description copied from interface:LedgerMetadataGet the format version which should be used to serialize the metadata.- Specified by:
getMetadataFormatVersionin interfaceLedgerMetadata- Returns:
- the format version.
-
shouldStoreCtime
boolean shouldStoreCtime()
-
getCToken
public long getCToken()
Description copied from interface:LedgerMetadataGet the unique creator token of the Ledger.- Specified by:
getCTokenin interfaceLedgerMetadata- Returns:
- the creator token
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-