Package org.apache.bookkeeper.bookie
Class EntryLogMetadata
- java.lang.Object
-
- org.apache.bookkeeper.bookie.EntryLogMetadata
-
- Direct Known Subclasses:
EntryLogMetadata.EntryLogMetadataRecyclable
public class EntryLogMetadata extends java.lang.Object
Records the total size, remaining size and the set of ledgers that comprise a entry log.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EntryLogMetadata.EntryLogMetadataRecyclable
RecyclableEntryLogMetadata
class.
-
Field Summary
Fields Modifier and Type Field Description protected long
entryLogId
protected ConcurrentLongLongHashMap
ledgersMap
protected long
remainingSize
protected long
totalSize
-
Constructor Summary
Constructors Modifier Constructor Description protected
EntryLogMetadata()
EntryLogMetadata(long logId)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addLedgerSize(long ledgerId, long size)
void
clear()
boolean
containsLedger(long ledgerId)
static EntryLogMetadata.EntryLogMetadataRecyclable
deserialize(java.io.DataInputStream in)
DeserializesEntryLogMetadata.EntryLogMetadataRecyclable
from givenDataInputStream
.long
getEntryLogId()
ConcurrentLongLongHashMap
getLedgersMap()
long
getRemainingSize()
long
getTotalSize()
double
getUsage()
boolean
isEmpty()
void
removeLedgerIf(java.util.function.LongPredicate predicate)
void
serialize(java.io.DataOutputStream out)
SerializesEntryLogMetadata
and writes toDataOutputStream
.java.lang.String
toString()
-
-
-
Field Detail
-
entryLogId
protected long entryLogId
-
totalSize
protected long totalSize
-
remainingSize
protected long remainingSize
-
ledgersMap
protected final ConcurrentLongLongHashMap ledgersMap
-
-
Method Detail
-
addLedgerSize
public void addLedgerSize(long ledgerId, long size)
-
containsLedger
public boolean containsLedger(long ledgerId)
-
getUsage
public double getUsage()
-
isEmpty
public boolean isEmpty()
-
getEntryLogId
public long getEntryLogId()
-
getTotalSize
public long getTotalSize()
-
getRemainingSize
public long getRemainingSize()
-
getLedgersMap
public ConcurrentLongLongHashMap getLedgersMap()
-
removeLedgerIf
public void removeLedgerIf(java.util.function.LongPredicate predicate)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
serialize
public void serialize(java.io.DataOutputStream out) throws java.io.IOException, java.lang.IllegalStateException
SerializesEntryLogMetadata
and writes toDataOutputStream
.schema: 2-bytes: schema-version 8-bytes: entrylog-entryLogId 8-bytes: entrylog-totalSize 8-bytes: entrylog-remainingSize 8-bytes: total number of ledgers ledgers-map [repeat]: (8-bytes::ledgerId, 8-bytes::size-of-ledger)
- Parameters:
out
-- Throws:
java.io.IOException
- throws if it couldn't serialize metadata-fieldsjava.lang.IllegalStateException
- throws if it couldn't serialize ledger-map
-
deserialize
public static EntryLogMetadata.EntryLogMetadataRecyclable deserialize(java.io.DataInputStream in) throws java.io.IOException
DeserializesEntryLogMetadata.EntryLogMetadataRecyclable
from givenDataInputStream
. Caller has to recycle returnedEntryLogMetadata.EntryLogMetadataRecyclable
.- Parameters:
in
-- Returns:
- Throws:
java.io.IOException
-
clear
public void clear()
-
-