Package com.gigaspaces.lrmi.nio
Class Writer
java.lang.Object
com.gigaspaces.lrmi.nio.Writer
- All Implemented Interfaces:
IChannelWriter
A Writer is capable of writing Request Packets and Reply Packets to a Socket Channel. An NIO
Client Peer uses an instance of a Writer to write Request Packets while an NIO Server uses an
instance of a Writer to write Reply Packets.
- Since:
- 4.0
- Author:
- Igor Goldenberg
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
ConstructorsConstructorDescriptionWriter(SocketChannel sockChannel, int slowConsumerThroughput, int slowConsumerLatency, int slowConsumerRetries, IWriteInterestManager writeInterestManager) Writer(SocketChannel sockChannel, IWriteInterestManager writeInterestManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidlongstatic LongAdderstatic LongAdderbooleanbooleanisOpen()protected voidvoidCalled from WriteSelectorThread to complete pending write requests.voidvoidsetFilterManager(IOFilterManager filterManager) voidsetWriteInterestManager(IWriteInterestManager writeInterestManager) Do not call this method unless the last write was completed.voidwriteBytesToChannelBlocking(ByteBuffer dataBuffer) voidwriteBytesToChannelNoneBlocking(Writer.Context ctx, boolean restoreReadInterest) voidvoidwriteReply(ReplyPacket packet) voidwriteReply(ReplyPacket packet, boolean reuseBuffer) voidwriteReply(ReplyPacket packet, boolean reuseBuffer, Writer.Context ctx) voidwriteRequest(RequestPacket packet) voidwriteRequest(RequestPacket packet, boolean reuseBuffer) voidwriteRequest(RequestPacket packet, boolean reuseBuffer, Writer.Context ctx)
-
Constructor Details
-
Writer
-
Writer
public Writer(SocketChannel sockChannel, int slowConsumerThroughput, int slowConsumerLatency, int slowConsumerRetries, IWriteInterestManager writeInterestManager)
-
-
Method Details
-
getGeneratedTrafficCounter
-
getPendingWritesCounter
-
setWriteInterestManager
Do not call this method unless the last write was completed. Otherwise you may have concurrency issues, this is because _writeInterestManager is used from the selector thread as well as from the user thread (you in this case) After the last write was completed the selector thread will not use _writeInterestManager until write is performed. -
getEndPointAddress
- Returns:
- the endpoint of the connected SocketChannel.
-
writeRequest
public void writeRequest(RequestPacket packet, boolean reuseBuffer, Writer.Context ctx) throws IOException, IOFilterException - Throws:
IOExceptionIOFilterException
-
writeRequest
public void writeRequest(RequestPacket packet, boolean reuseBuffer) throws IOException, IOFilterException - Throws:
IOExceptionIOFilterException
-
writeRequest
- Throws:
IOExceptionIOFilterException
-
writeReply
public void writeReply(ReplyPacket packet, boolean reuseBuffer, Writer.Context ctx) throws IOException, IOFilterException - Throws:
IOExceptionIOFilterException
-
writeReply
public void writeReply(ReplyPacket packet, boolean reuseBuffer) throws IOException, IOFilterException - Throws:
IOExceptionIOFilterException
-
writeReply
- Throws:
IOExceptionIOFilterException
-
isOpen
public boolean isOpen() -
setFilterManager
- Specified by:
setFilterManagerin interfaceIChannelWriter
-
isBlocking
public boolean isBlocking()- Specified by:
isBlockingin interfaceIChannelWriter
-
writeBytesToChannelNoneBlocking
public void writeBytesToChannelNoneBlocking(Writer.Context ctx, boolean restoreReadInterest) throws IOException - Specified by:
writeBytesToChannelNoneBlockingin interfaceIChannelWriter- Throws:
IOException
-
noneBlockingWrite
- Throws:
IOException
-
writeBytesToChannelBlocking
public void writeBytesToChannelBlocking(ByteBuffer dataBuffer) throws IOException, ClosedChannelException, SlowConsumerException - Specified by:
writeBytesToChannelBlockingin interfaceIChannelWriter- Throws:
IOExceptionClosedChannelExceptionSlowConsumerException
-
onWriteEvent
Called from WriteSelectorThread to complete pending write requests. This is synchronized to ensure mutual exclusion with writeBytesToChannelNoneBlocking method- Throws:
IOException- See Also:
-
closeContext
public void closeContext() -
resetContext
public void resetContext() -
getGeneratedTraffic
public long getGeneratedTraffic() -
writeProtocolValidationHeader
- Throws:
IOException
-