Package org.apache.bookkeeper.client.api
Interface LedgerMetadata
-
- All Known Implementing Classes:
LedgerMetadataImpl
@LimitedPrivate @Unstable public interface LedgerMetadata
Represents the client-side metadata of a ledger. It is immutable.- Since:
- 4.6
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
LedgerMetadata.State
Possible metadata states.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description int
getAckQuorumSize()
Returns the ack quorum size of this ledger.java.util.NavigableMap<java.lang.Long,? extends java.util.List<org.apache.bookkeeper.net.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<org.apache.bookkeeper.net.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.boolean
hasPassword()
Whether the metadata contains the password and digest type for the ledger.boolean
isClosed()
Returns whether the ledger is sealed or not.java.lang.String
toSafeString()
Similar to #toString(), but omits the password of the ledger, so that it is safe to log the output.
-
-
-
Method Detail
-
getLedgerId
long getLedgerId()
Returns the id of this ledger.- Returns:
- the id of this ledger.
-
getEnsembleSize
int getEnsembleSize()
Returns the ensemble size of this ledger.- Returns:
- the ensemble size of this ledger.
-
getWriteQuorumSize
int getWriteQuorumSize()
Returns the write quorum size of this ledger.- Returns:
- the write quorum size of this ledger.
-
getAckQuorumSize
int getAckQuorumSize()
Returns the ack quorum size of this ledger.- Returns:
- the ack quorum size of this ledger.
-
getLastEntryId
long getLastEntryId()
Returns the last entry id of this ledger.If this ledger is not sealed
isClosed()
, it returns-1L
.- Returns:
- the last entry id of this ledger if it is sealed, otherwise -1.
-
getLength
long getLength()
Returns the length of this ledger.If this ledger is not sealed
isClosed()
, it returns0
.- Returns:
- the length of this ledger if it is sealed, otherwise 0.
-
hasPassword
boolean hasPassword()
Whether the metadata contains the password and digest type for the ledger. Ledgers created with version 4.1.0 clients or older do not have this information.- Returns:
- true if the metadata contains the password and digest type, false otherwise.
-
getPassword
byte[] getPassword()
Get the password for the ledger. For ledgers created with version 4.1.0 or older, an empty byte array is returned.- Returns:
- the password for the ledger.
-
getDigestType
DigestType getDigestType()
Returns the digest type used by this ledger. May return null if the ledger was created with version 4.1.0 or below.- Returns:
- the digest type used by this ledger.
-
getCtime
long getCtime()
Returns the creation timestamp of this ledger.- Returns:
- the creation timestamp of this ledger.
-
isClosed
boolean isClosed()
Returns whether the ledger is sealed or not.- Returns:
- true if the ledger is sealed, otherwise false.
-
getCustomMetadata
java.util.Map<java.lang.String,byte[]> getCustomMetadata()
Returns the custom metadata stored with the ledgers.- Returns:
- the custom metadata stored with the ledgers.
-
getEnsembleAt
java.util.List<org.apache.bookkeeper.net.BookieId> getEnsembleAt(long entryId)
Returns the ensemble at the givenentryId
.- Parameters:
entryId
- the entry id to retrieve its ensemble information- Returns:
- the ensemble which contains the given
entryId
.
-
getAllEnsembles
java.util.NavigableMap<java.lang.Long,? extends java.util.List<org.apache.bookkeeper.net.BookieId>> getAllEnsembles()
Returns all the ensembles of this ledger.- Returns:
- all the ensembles of this ledger.
-
getState
LedgerMetadata.State getState()
Returns the state of the metadata.- Returns:
- the state of the metadata.
-
toSafeString
java.lang.String toSafeString()
Similar to #toString(), but omits the password of the ledger, so that it is safe to log the output.- Returns:
- a string representation of the metadata, omitting the password.
-
getMetadataFormatVersion
int getMetadataFormatVersion()
Get the format version which should be used to serialize the metadata.- Returns:
- the format version.
-
getCToken
long getCToken()
Get the unique creator token of the Ledger.- Returns:
- the creator token
-
-