Package org.apache.bookkeeper.proto
Class PacketProcessorBase<T extends BookieProtocol.Request>
- java.lang.Object
-
- org.apache.bookkeeper.util.SafeRunnable
-
- org.apache.bookkeeper.proto.PacketProcessorBase<T>
-
- All Implemented Interfaces:
java.lang.Runnable
,SafeRunnable
- Direct Known Subclasses:
ReadEntryProcessor
,WriteEntryProcessor
abstract class PacketProcessorBase<T extends BookieProtocol.Request> extends SafeRunnable
A base class for bookeeper packet processors.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) io.netty.channel.Channel
channel
(package private) long
enqueueNanos
(package private) T
request
(package private) BookieRequestProcessor
requestProcessor
-
Fields inherited from interface org.apache.bookkeeper.common.util.SafeRunnable
LOGGER
-
-
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, io.netty.channel.Channel channel, BookieRequestProcessor requestProcessor)
protected boolean
isVersionCompatible()
protected abstract void
processPacket()
protected void
reset()
void
safeRun()
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.-
Methods inherited from class org.apache.bookkeeper.util.SafeRunnable
safeRun, safeRun
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.bookkeeper.common.util.SafeRunnable
run
-
-
-
-
Field Detail
-
request
T extends BookieProtocol.Request request
-
channel
io.netty.channel.Channel channel
-
requestProcessor
BookieRequestProcessor requestProcessor
-
enqueueNanos
long enqueueNanos
-
-
Method Detail
-
init
protected void init(T request, io.netty.channel.Channel channel, BookieRequestProcessor requestProcessor)
-
reset
protected void reset()
-
isVersionCompatible
protected boolean isVersionCompatible()
-
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.
-
safeRun
public void safeRun()
-
processPacket
protected abstract void processPacket()
-
-