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.Logger
LOG
(package private) boolean
storeCtime
-
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 boolean
canEqual(java.lang.Object other)
boolean
equals(java.lang.Object o)
int
getAckQuorumSize()
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.long
getCtime()
Returns the creation timestamp of this ledger.long
getCToken()
Get the unique creator token of the Ledger.java.util.Map<java.lang.String,byte[]>
getCustomMetadata()
Returns the custom metadata stored with the ledgers.DigestType
getDigestType()
Returns the digest type used by this ledger.java.util.List<BookieId>
getEnsembleAt(long entryId)
Returns the ensemble at the givenentryId
.int
getEnsembleSize()
Returns the ensemble size of this ledger.long
getLastEntryId()
Returns the last entry id of this ledger.long
getLedgerId()
Returns the id of this ledger.long
getLength()
Returns the length of this ledger.int
getMetadataFormatVersion()
Get the format version which should be used to serialize the metadata.byte[]
getPassword()
Get the password for the ledger.LedgerMetadata.State
getState()
Returns the state of the metadata.int
getWriteQuorumSize()
Returns the write quorum size of this ledger.int
hashCode()
boolean
hasPassword()
In versions 4.1.0 and below, the digest type and password were not stored in the metadata.boolean
isClosed()
Returns whether the ledger is sealed or not.(package private) boolean
shouldStoreCtime()
java.lang.String
toSafeString()
Returns a string representation of this LedgerMetadata object by filtering out the password field.java.lang.String
toString()
-
-
-
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:LedgerMetadata
Returns the id of this ledger.- Specified by:
getLedgerId
in 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:LedgerMetadata
Returns all the ensembles of this ledger.- Specified by:
getAllEnsembles
in interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 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:
hasPassword
in interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 returns0
.- Specified by:
getLength
in interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- Returns:
- the state of the metadata.
-
getEnsembleAt
public java.util.List<BookieId> getEnsembleAt(long entryId)
Description copied from interface:LedgerMetadata
Returns the ensemble at the givenentryId
.- Specified by:
getEnsembleAt
in 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:LedgerMetadata
Returns the custom metadata stored with the ledgers.- Specified by:
getCustomMetadata
in interfaceLedgerMetadata
- Returns:
- the custom metadata stored with the ledgers.
-
toString
public java.lang.String toString()
- Overrides:
toString
in 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:
toSafeString
in interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- 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 interfaceLedgerMetadata
- Returns:
- the creator token
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
canEqual
protected boolean canEqual(java.lang.Object other)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
-