Package org.apache.bookkeeper.proto
Class PacketProcessorBase<T extends BookieProtocol.Request>
- java.lang.Object
-
- org.apache.bookkeeper.proto.PacketProcessorBase<T>
-
- All Implemented Interfaces:
java.lang.Runnable
- Direct Known Subclasses:
ReadEntryProcessor
,WriteEntryProcessor
abstract class PacketProcessorBase<T extends BookieProtocol.Request> extends java.lang.Object implements java.lang.Runnable
A base class for bookeeper packet processors.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) long
enqueueNanos
(package private) T
request
(package private) BookieRequestHandler
requestHandler
(package private) BookieRequestProcessor
requestProcessor
-
Constructor Summary
Constructors Constructor Description PacketProcessorBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
init(T request, BookieRequestHandler requestHandler, BookieRequestProcessor requestProcessor)
protected boolean
isVersionCompatible()
protected abstract void
processPacket()
protected void
reset()
void
run()
protected void
sendReadReqResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger, boolean throttle)
protected void
sendResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger)
protected void
sendResponseAndWait(int rc, java.lang.Object response, OpStatsLogger statsLogger)
Write on the channel and wait until the write is completed.protected void
sendWriteReqResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger)
-
-
-
Field Detail
-
request
T extends BookieProtocol.Request request
-
requestHandler
BookieRequestHandler requestHandler
-
requestProcessor
BookieRequestProcessor requestProcessor
-
enqueueNanos
long enqueueNanos
-
-
Method Detail
-
init
protected void init(T request, BookieRequestHandler requestHandler, BookieRequestProcessor requestProcessor)
-
reset
protected void reset()
-
isVersionCompatible
protected boolean isVersionCompatible()
-
sendWriteReqResponse
protected void sendWriteReqResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger)
-
sendReadReqResponse
protected void sendReadReqResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger, boolean throttle)
-
sendResponse
protected void sendResponse(int rc, java.lang.Object response, OpStatsLogger statsLogger)
-
sendResponseAndWait
protected void sendResponseAndWait(int rc, java.lang.Object response, OpStatsLogger statsLogger)
Write on the channel and wait until the write is completed.That will make the thread to get blocked until we're able to write everything on the TCP stack, providing auto-throttling and avoiding using too much memory when handling read-requests.
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
processPacket
protected abstract void processPacket()
-
-