Class GridDirectParser
- java.lang.Object
-
- org.apache.ignite.internal.util.nio.GridDirectParser
-
- All Implemented Interfaces:
GridNioParser
public class GridDirectParser extends Object implements GridNioParser
Parser for direct messages.
-
-
Constructor Summary
Constructors Constructor Description GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMessageReaderFactory readerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable Objectdecode(GridNioSession ses, ByteBuffer buf)This method is called when input bytes are available on the underlying network connection.ByteBufferencode(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.
-
-
-
Constructor Detail
-
GridDirectParser
public GridDirectParser(IgniteLogger log, MessageFactory msgFactory, GridNioMessageReaderFactory readerFactory)
- Parameters:
log- Logger.msgFactory- Message factory.readerFactory- Message reader factory.
-
-
Method Detail
-
decode
@Nullable public @Nullable Object decode(GridNioSession ses, ByteBuffer buf) throws IOException, IgniteCheckedException
This method is called when input bytes are available on the underlying network connection.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.
- Specified by:
decodein interfaceGridNioParser- Parameters:
ses- Session on which bytes are read.buf- Buffer that contains input data.- Returns:
- Parsed user message or
nullif complete message has not been received yet. Note that in case of returningnullgiven buffer must be completely read. - Throws:
IOException- If exception occurred while reading data.IgniteCheckedException- If any user-specific error occurred.
-
encode
public ByteBuffer encode(GridNioSession ses, Object msg) throws IOException, IgniteCheckedException
This method is called whenever a message should be sent to the network connection and network buffer is ready to be filled with bytes.Method must encode the complete message and return byte buffer from which data should be read.
- Specified by:
encodein interfaceGridNioParser- Parameters:
ses- Session on which message is being sent.msg- Message to encode.- Returns:
- Buffer containing encoded message.
- Throws:
IOException- If exception occurred while encoding data.IgniteCheckedException- If any user-specific error occurred while encoding data.
-
-