public class GridDelimitedParser extends Object implements GridNioParser
GridNioDelimitedBuffer.
The rule for this parser is that every message sent over the stream is appended with delimiter (bytes array). So, the stream structure is as follows:
+--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
| MESSAGE | DELIMITER | MESSAGE | DELIMITER |
+--+--+...+--+--+--+--+--+--+--+...+--+--+--+--+--+-
| Constructor and Description |
|---|
GridDelimitedParser(byte[] delim,
boolean directBuf) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
decode(GridNioSession ses,
ByteBuffer buf)
This method is called when input bytes are available on the underlying network connection.
|
ByteBuffer |
encode(GridNioSession ses,
Object msg)
This method is called whenever a message should be sent to the network connection
and network buffer is ready to be filled with bytes.
|
String |
toString() |
public GridDelimitedParser(byte[] delim,
boolean directBuf)
delim - Delimiter.directBuf - Direct buffer.public byte[] decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException
Method must read given buffer until either it reaches the end of buffer or a valid user message is encountered. In this case it must return parsed message.
decode in interface GridNioParserses - Session on which bytes are read.buf - Buffer that contains input data.null if complete message has not been received yet. Note
that in case of returning null given buffer must be completely read.IOException - If exception occurred while reading data.IgniteCheckedException - If any user-specific error occurred.public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException
Method must encode the complete message and return byte buffer from which data should be read.
encode in interface GridNioParserses - Session on which message is being sent.msg - Message to encode.IOException - If exception occurred while encoding data.IgniteCheckedException - If any user-specific error occurred while encoding data.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.9.0 Release Date : March 2 2017