public final class NonBlockingSocketWriter extends AbstractHandler implements Runnable, SocketWriter
TcpIpConnection.| Modifier and Type | Field and Description |
|---|---|
Queue<OutboundFrame> |
urgentWriteQueue |
Queue<OutboundFrame> |
writeQueue |
connection, eventCount, ioThread, logger, selectionKey, socketChannel| Constructor and Description |
|---|
NonBlockingSocketWriter(SocketConnection connection,
NonBlockingIOThread ioThread,
ILogger logger,
IOBalancer balancer,
SocketWriterInitializer initializer) |
| Modifier and Type | Method and Description |
|---|---|
long |
bytesPending() |
void |
close()
Closes this SocketWriter.
|
WriteHandler |
getWriteHandler()
Gets the
WriteHandler that belongs to this SocketWriter. |
void |
handle()
Called when there are bytes available for reading, or space available to write.
|
void |
initOutputBuffer(ByteBuffer outputBuffer) |
void |
initWriteHandler(WriteHandler writeHandler) |
long |
lastWriteTimeMillis()
Returns the last
Clock.currentTimeMillis() that a write to the socket completed. |
long |
priorityBytesPending() |
void |
requestMigration(NonBlockingIOThread newOwner)
Requests the MigratableHandler to move to the new NonBlockingIOThread.
|
void |
run() |
void |
setProtocol(String protocol)
Sets the protocol this SocketWriter should use.
|
String |
toString() |
int |
totalFramesPending()
Returns the total number of packets (urgent and non normal priority) pending to be written to the socket.
|
void |
write(OutboundFrame frame)
Offers a Frame to be written to the socket.
|
getEventCount, getOwner, getSelectionKey, getSocketChannel, onFailurepublic final Queue<OutboundFrame> writeQueue
public final Queue<OutboundFrame> urgentWriteQueue
public NonBlockingSocketWriter(SocketConnection connection, NonBlockingIOThread ioThread, ILogger logger, IOBalancer balancer, SocketWriterInitializer initializer)
public int totalFramesPending()
SocketWritertotalFramesPending in interface SocketWriterpublic long lastWriteTimeMillis()
SocketWriterClock.currentTimeMillis() that a write to the socket completed.
Writing to the socket doesn't mean that data has been send or received; it means that data was written to the
SocketChannel. It could very well be that this data is stuck somewhere in an io-buffer.lastWriteTimeMillis in interface SocketWriterpublic WriteHandler getWriteHandler()
SocketWriterWriteHandler that belongs to this SocketWriter.
This method exists for the TextReadHandler, but probably should be deleted.getWriteHandler in interface SocketWriterpublic long bytesPending()
public long priorityBytesPending()
public void setProtocol(String protocol)
SocketWriterProtocolssetProtocol in interface SocketWriterprotocol - the protocolpublic void initOutputBuffer(ByteBuffer outputBuffer)
initOutputBuffer in interface SocketWriterpublic void write(OutboundFrame frame)
SocketWriterwrite in interface SocketWriterframe - the Frame to write.public void handle()
throws Exception
SelectionHandlerhandle in interface SelectionHandlerExceptionpublic void initWriteHandler(WriteHandler writeHandler)
initWriteHandler in interface SocketWriterpublic void close()
SocketWriterTcpIpConnection.close(String, Throwable) method.close in interface SocketWriterpublic void requestMigration(NonBlockingIOThread newOwner)
MigratableHandlerIOBalancer.
Call is ignored when handler is moving to the same NonBlockingIOThread.requestMigration in interface MigratableHandlernewOwner - the NonBlockingIOThread that is going to own this MigratableHandlerCopyright © 2017 Hazelcast, Inc.. All Rights Reserved.