Package org.apache.bookkeeper.client
Class PendingReadOp.LedgerEntryRequest
- java.lang.Object
-
- org.apache.bookkeeper.client.PendingReadOp.LedgerEntryRequest
-
- All Implemented Interfaces:
java.lang.AutoCloseable,SpeculativeRequestExecutor
- Direct Known Subclasses:
PendingReadOp.ParallelReadRequest,PendingReadOp.SequenceReadRequest
- Enclosing class:
- PendingReadOp
abstract class PendingReadOp.LedgerEntryRequest extends java.lang.Object implements SpeculativeRequestExecutor, java.lang.AutoCloseable
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.concurrent.atomic.AtomicBooleancomplete(package private) longeId(package private) java.util.List<org.apache.bookkeeper.net.BookieId>ensemble(package private) LedgerEntryImplentryImpl(package private) intfirstError(package private) intnumBookiesMissingEntry(package private) intrc(package private) DistributionSchedule.WriteSetwriteSet
-
Constructor Summary
Constructors Constructor Description LedgerEntryRequest(java.util.List<org.apache.bookkeeper.net.BookieId> ensemble, long lId, long eId)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidclose()(package private) booleancomplete(int bookieIndex, org.apache.bookkeeper.net.BookieId host, io.netty.buffer.ByteBuf buffer)Complete the read request from host.(package private) booleanfail(int rc)Fail the request with given result code rc.(package private) intgetRc()Get result code of this entry.(package private) booleanisComplete()Whether the read request completed.com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean>issueSpeculativeRequest()Issues a speculative request and indicates if more speculative requests should be issued.(package private) voidlogErrorAndReattemptRead(int bookieIndex, org.apache.bookkeeper.net.BookieId host, java.lang.String errMsg, int rc)Log error errMsg and reattempt read from host.(package private) abstract org.apache.bookkeeper.net.BookieIdmaybeSendSpeculativeRead(java.util.BitSet heardFromHostsBitSet)Send to next replica speculatively, if required and possible.(package private) abstract voidread()Execute the read request.java.lang.StringtoString()
-
-
-
Field Detail
-
complete
final java.util.concurrent.atomic.AtomicBoolean complete
-
rc
int rc
-
firstError
int firstError
-
numBookiesMissingEntry
int numBookiesMissingEntry
-
ensemble
final java.util.List<org.apache.bookkeeper.net.BookieId> ensemble
-
writeSet
final DistributionSchedule.WriteSet writeSet
-
entryImpl
final LedgerEntryImpl entryImpl
-
eId
final long eId
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable
-
read
abstract void read()
Execute the read request.
-
complete
boolean complete(int bookieIndex, org.apache.bookkeeper.net.BookieId host, io.netty.buffer.ByteBuf buffer)Complete the read request from host.- Parameters:
bookieIndex- bookie indexhost- host that respond the readbuffer- the data buffer- Returns:
- return true if we managed to complete the entry; otherwise return false if the read entry is not complete or it is already completed before
-
fail
boolean fail(int rc)
Fail the request with given result code rc.- Parameters:
rc- result code to fail the request.- Returns:
- true if we managed to fail the entry; otherwise return false if it already failed or completed.
-
logErrorAndReattemptRead
void logErrorAndReattemptRead(int bookieIndex, org.apache.bookkeeper.net.BookieId host, java.lang.String errMsg, int rc)Log error errMsg and reattempt read from host.- Parameters:
bookieIndex- bookie indexhost- host that just responderrMsg- error msg to logrc- read result code
-
maybeSendSpeculativeRead
abstract org.apache.bookkeeper.net.BookieId maybeSendSpeculativeRead(java.util.BitSet heardFromHostsBitSet)
Send to next replica speculatively, if required and possible. This returns the host we may have sent to for unit testing.- Parameters:
heardFromHostsBitSet- the set of hosts that we already received responses.- Returns:
- host we sent to if we sent. null otherwise.
-
isComplete
boolean isComplete()
Whether the read request completed.- Returns:
- true if the read request is completed.
-
getRc
int getRc()
Get result code of this entry.- Returns:
- result code.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
issueSpeculativeRequest
public com.google.common.util.concurrent.ListenableFuture<java.lang.Boolean> issueSpeculativeRequest()
Issues a speculative request and indicates if more speculative requests should be issued.- Specified by:
issueSpeculativeRequestin interfaceSpeculativeRequestExecutor- Returns:
- whether more speculative requests should be issued
-
-