public final class NonBlockingSocketReader extends AbstractHandler implements SocketReader
SocketReader tailored for non blocking IO.
When the NonBlockingIOThread receives a read event from the Selector, then the
handle() is called to read out the data from the socket into a bytebuffer and hand it over to the
ReadHandler to get processed.| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
inputBuffer |
connection, eventCount, ioThread, logger, selectionKey, socketChannel| Constructor and Description |
|---|
NonBlockingSocketReader(SocketConnection connection,
NonBlockingIOThread ioThread,
ILogger logger,
IOBalancer balancer,
SocketReaderInitializer initializer) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this SocketReader.
|
SwCounter |
getNormalFramesReadCounter()
Gets the SwCounter that counts the number of normal packets that have been read.
|
SwCounter |
getPriorityFramesReadCounter()
Gets the SwCounter that counts the number of priority packets that have been read.
|
ByteBuffer |
getProtocolBuffer() |
void |
handle()
Called when there are bytes available for reading, or space available to write.
|
void |
init()
Initializes this SocketReader.
|
void |
initInputBuffer(ByteBuffer inputBuffer) |
void |
initReadHandler(ReadHandler readHandler) |
long |
lastReadTimeMillis()
Returns the last
Clock.currentTimeMillis() a read of the socket was done. |
void |
requestMigration(NonBlockingIOThread newOwner)
Migrates this handler to a new NonBlockingIOThread.
|
String |
toString() |
getEventCount, getOwner, getSelectionKey, getSocketChannel, onFailureclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetSocketChannelprotected ByteBuffer inputBuffer
public NonBlockingSocketReader(SocketConnection connection, NonBlockingIOThread ioThread, ILogger logger, IOBalancer balancer, SocketReaderInitializer initializer)
public ByteBuffer getProtocolBuffer()
getProtocolBuffer in interface SocketReaderpublic void initInputBuffer(ByteBuffer inputBuffer)
initInputBuffer in interface SocketReaderpublic void initReadHandler(ReadHandler readHandler)
initReadHandler in interface SocketReaderpublic SwCounter getNormalFramesReadCounter()
SocketReadergetNormalFramesReadCounter in interface SocketReaderpublic SwCounter getPriorityFramesReadCounter()
SocketReadergetPriorityFramesReadCounter in interface SocketReaderpublic long lastReadTimeMillis()
SocketReaderClock.currentTimeMillis() a read of the socket was done.lastReadTimeMillis in interface SocketReaderpublic void init()
SocketReaderinit in interface SocketReaderpublic void requestMigration(NonBlockingIOThread newOwner)
requestMigration in interface MigratableHandlernewOwner - target NonBlockingIOThread this handler migrates topublic void handle()
throws Exception
SelectionHandlerhandle in interface SelectionHandlerExceptionpublic void close()
SocketReaderConnection.close(String, Throwable) method.close in interface SocketReaderCopyright © 2018 Hazelcast, Inc.. All Rights Reserved.