Package org.apache.bookkeeper.client
Class LedgerMetadataImpl
java.lang.Object
org.apache.bookkeeper.client.LedgerMetadataImpl
- All Implemented Interfaces:
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
FieldsModifier and TypeFieldDescription(package private) static final org.slf4j.Logger(package private) final boolean -
Constructor Summary
ConstructorsConstructorDescriptionLedgerMetadataImpl(long ledgerId, int metadataFormatVersion, int ensembleSize, int writeQuorumSize, int ackQuorumSize, LedgerMetadata.State state, Optional<Long> lastEntryId, Optional<Long> length, Map<Long, List<BookieId>> ensembles, Optional<DigestType> digestType, Optional<byte[]> password, long ctime, boolean storeCtime, long cToken, Map<String, byte[]> customMetadata) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanbooleanintReturns the ack quorum size of this ledger.NavigableMap<Long,? extends List<BookieId>> Returns all the ensembles of this ledger.longgetCtime()Returns the creation timestamp of this ledger.longGet the unique creator token of the Ledger.Returns the custom metadata stored with the ledgers.Returns the digest type used by this ledger.getEnsembleAt(long entryId) Returns the ensemble at the givenentryId.intReturns the ensemble size of this ledger.longReturns the last entry id of this ledger.longReturns the id of this ledger.longReturns the length of this ledger.intGet the format version which should be used to serialize the metadata.byte[]Get the password for the ledger.getState()Returns the state of the metadata.intReturns the write quorum size of this ledger.inthashCode()booleanIn 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) booleanReturns a string representation of this LedgerMetadata object by filtering out the password field.toString()
-
Field Details
-
LOG
static final org.slf4j.Logger LOG -
storeCtime
final boolean storeCtime
-
-
Constructor Details
-
LedgerMetadataImpl
LedgerMetadataImpl(long ledgerId, int metadataFormatVersion, int ensembleSize, int writeQuorumSize, int ackQuorumSize, LedgerMetadata.State state, Optional<Long> lastEntryId, Optional<Long> length, Map<Long, List<BookieId>> ensembles, Optional<DigestType> digestType, Optional<byte[]> password, long ctime, boolean storeCtime, long cToken, Map<String, byte[]> customMetadata)
-
-
Method Details
-
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
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
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
Description copied from interface:LedgerMetadataReturns the state of the metadata.- Specified by:
getStatein interfaceLedgerMetadata- Returns:
- the state of the metadata.
-
getEnsembleAt
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
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
-
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
-
canEqual
-
hashCode
public int hashCode()
-