Package org.apache.bookkeeper.client
Class LedgerFragment
- java.lang.Object
-
- org.apache.bookkeeper.client.LedgerFragment
-
public class LedgerFragment extends java.lang.Object
Represents the entries of a segment of a ledger which are stored on subset of bookies in the segments bookie ensemble.Used for checking and recovery
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LedgerFragment.ReplicateType
ReplicateType.
-
Constructor Summary
Constructors Constructor Description LedgerFragment(LedgerFragment lf, java.util.Set<java.lang.Integer> subset)
LedgerFragment(LedgerHandle lh, long firstEntryId, long lastKnownEntryId, java.util.Set<java.lang.Integer> bookieIndexes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BookieId
getAddress(int bookieIndex)
Gets the failedBookie address.java.util.Set<BookieId>
getAddresses()
java.util.Set<java.lang.Integer>
getBookiesIndexes()
Gets the failedBookie index.java.util.List<BookieId>
getEnsemble()
Gets the ensemble of fragment.long
getFirstEntryId()
long
getFirstStoredEntryId()
Gets the first stored entry id of the fragment in failed bookies.java.lang.Long
getFirstStoredEntryId(int bookieIndex)
Get the first stored entry id of the fragment in the given failed bookies.long
getLastKnownEntryId()
long
getLastStoredEntryId()
Gets the last stored entry id of the fragment in failed bookie.java.lang.Long
getLastStoredEntryId(int bookieIndex)
Get the last stored entry id of the fragment in the given failed bookie.long
getLedgerId()
LedgerFragment.ReplicateType
getReplicateType()
boolean
isClosed()
Returns true, if and only if the ledger fragment will never be modified by any of the clients in future, otherwise false.boolean
isStoredEntryId(long entryId, int bookieIndex)
void
setReplicateType(LedgerFragment.ReplicateType replicateType)
LedgerFragment
subset(java.util.Set<java.lang.Integer> subset)
Return a ledger fragment contains subset of bookies.java.lang.String
toString()
-
-
-
Constructor Detail
-
LedgerFragment
public LedgerFragment(LedgerHandle lh, long firstEntryId, long lastKnownEntryId, java.util.Set<java.lang.Integer> bookieIndexes)
-
LedgerFragment
public LedgerFragment(LedgerFragment lf, java.util.Set<java.lang.Integer> subset)
-
-
Method Detail
-
subset
public LedgerFragment subset(java.util.Set<java.lang.Integer> subset)
Return a ledger fragment contains subset of bookies.- Parameters:
subset
- subset of bookies.- Returns:
- ledger fragment contains subset of bookies
-
isClosed
public boolean isClosed()
Returns true, if and only if the ledger fragment will never be modified by any of the clients in future, otherwise false. i.e,- If ledger is in closed state, then no other clients can modify this fragment.
- If ledger is not in closed state and the current fragment is not a last fragment, then no one will modify this fragment.
-
getLedgerId
public long getLedgerId()
-
getFirstEntryId
public long getFirstEntryId()
-
getLastKnownEntryId
public long getLastKnownEntryId()
-
getAddress
public BookieId getAddress(int bookieIndex)
Gets the failedBookie address.
-
getAddresses
public java.util.Set<BookieId> getAddresses()
-
getBookiesIndexes
public java.util.Set<java.lang.Integer> getBookiesIndexes()
Gets the failedBookie index.
-
getFirstStoredEntryId
public long getFirstStoredEntryId()
Gets the first stored entry id of the fragment in failed bookies.- Returns:
- entryId
-
getFirstStoredEntryId
public java.lang.Long getFirstStoredEntryId(int bookieIndex)
Get the first stored entry id of the fragment in the given failed bookies.- Parameters:
bookieIndex
- the bookie index in the ensemble.- Returns:
- first stored entry id on the bookie.
-
getLastStoredEntryId
public long getLastStoredEntryId()
Gets the last stored entry id of the fragment in failed bookie.- Returns:
- entryId
-
getLastStoredEntryId
public java.lang.Long getLastStoredEntryId(int bookieIndex)
Get the last stored entry id of the fragment in the given failed bookie.- Parameters:
bookieIndex
- the bookie index in the ensemble.- Returns:
- first stored entry id on the bookie.
-
isStoredEntryId
public boolean isStoredEntryId(long entryId, int bookieIndex)
-
getEnsemble
public java.util.List<BookieId> getEnsemble()
Gets the ensemble of fragment.- Returns:
- the ensemble for the segment which this fragment is a part of
-
getReplicateType
public LedgerFragment.ReplicateType getReplicateType()
-
setReplicateType
public void setReplicateType(LedgerFragment.ReplicateType replicateType)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-