voldemort.common.nio
Class SelectorManagerWorker
java.lang.Object
voldemort.common.nio.SelectorManagerWorker
- All Implemented Interfaces:
- java.lang.Runnable
- Direct Known Subclasses:
- AsyncRequestHandler, ClientRequestExecutor
public abstract class SelectorManagerWorker
- extends java.lang.Object
- implements java.lang.Runnable
SelectorManagerWorker manages a Selector, SocketChannel, and IO streams
implementation. At the point that the run method is invoked, the Selector
with which the (socket) Channel has been registered has notified us that the
socket has data to read or write.
The bulk of the complexity in this class surrounds partial reads and writes,
as well as determining when all the data needed for the request has been
read.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
selector
protected final java.nio.channels.Selector selector
socketChannel
protected final java.nio.channels.SocketChannel socketChannel
socketBufferSize
protected final int socketBufferSize
resizeThreshold
protected final int resizeThreshold
inputStream
protected ByteBufferBackedInputStream inputStream
outputStream
protected ByteBufferBackedOutputStream outputStream
createTimestamp
protected final long createTimestamp
isClosed
protected final java.util.concurrent.atomic.AtomicBoolean isClosed
logger
protected final org.apache.log4j.Logger logger
SelectorManagerWorker
public SelectorManagerWorker(java.nio.channels.Selector selector,
java.nio.channels.SocketChannel socketChannel,
int socketBufferSize,
CommBufferSizeStats commBufferStats)
read
protected abstract void read(java.nio.channels.SelectionKey selectionKey)
throws java.io.IOException
- Throws:
java.io.IOException
write
protected abstract void write(java.nio.channels.SelectionKey selectionKey)
throws java.io.IOException
- Throws:
java.io.IOException
initializeStreams
protected abstract void initializeStreams(int socketBufferSize,
CommBufferSizeStats commBufferStats)
getCreateTimestamp
public long getCreateTimestamp()
- Returns the nanosecond-based timestamp of when this was created.
- Returns:
- Nanosecond-based timestamp of creation
run
public void run()
- Specified by:
run
in interface java.lang.Runnable
close
public void close()
closeInternal
protected void closeInternal()
isClosed
public boolean isClosed()
handleIncompleteRequest
protected void handleIncompleteRequest(int newPosition)
traceInputBufferState
protected void traceInputBufferState(java.lang.String preamble)
Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu