Package com.mysql.cj.protocol.a
Class SimplePacketReader
java.lang.Object
com.mysql.cj.protocol.a.SimplePacketReader
- All Implemented Interfaces:
MessageReader<NativePacketHeader,NativePacketPayload>
public class SimplePacketReader extends java.lang.Object implements MessageReader<NativePacketHeader,NativePacketPayload>
Simple implementation of
MessageReader which handles the receiving of logical MySQL packets from the provided socket input stream.
Multi-packets are handled outside of this reader.-
Field Summary
Fields Modifier and Type Field Description protected RuntimeProperty<java.lang.Integer>maxAllowedPacketprotected SocketConnectionsocketConnection -
Constructor Summary
Constructors Constructor Description SimplePacketReader(SocketConnection socketConnection, RuntimeProperty<java.lang.Integer> maxAllowedPacket) -
Method Summary
Modifier and Type Method Description bytegetMessageSequence()Get last message sequence number, as it was stored byMessageReader.readHeader().NativePacketHeaderreadHeader()Read the next message header from server, possibly blocking indefinitely until the message is received.NativePacketPayloadreadMessage(java.util.Optional<NativePacketPayload> reuse, NativePacketHeader header)Read message from server into to the givenMessageinstance or into the new one if not present.voidresetMessageSequence()Set stored message sequence number to 0.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.mysql.cj.protocol.MessageReader
pushMessageListener, readMessage, start, stopAfterNextMessage, undecorate, undecorateAll
-
Field Details
-
Constructor Details
-
SimplePacketReader
public SimplePacketReader(SocketConnection socketConnection, RuntimeProperty<java.lang.Integer> maxAllowedPacket)
-
-
Method Details
-
readHeader
Description copied from interface:MessageReaderRead the next message header from server, possibly blocking indefinitely until the message is received.- Specified by:
readHeaderin interfaceMessageReader<NativePacketHeader,NativePacketPayload>- Returns:
MessageHeaderof the next message- Throws:
java.io.IOException- if an error occurs
-
readMessage
public NativePacketPayload readMessage(java.util.Optional<NativePacketPayload> reuse, NativePacketHeader header) throws java.io.IOExceptionDescription copied from interface:MessageReaderRead message from server into to the givenMessageinstance or into the new one if not present. For asynchronous channel it synchronously reads the next message in the stream, blocking until the message is read fully. Could throw CJCommunicationsException wrapping anIOExceptionduring read or parse- Specified by:
readMessagein interfaceMessageReader<NativePacketHeader,NativePacketPayload>- Parameters:
reuse-Messageobject to reuse. May be ignored by implementation.header-MessageHeaderinstance- Returns:
Messageinstance- Throws:
java.io.IOException- if an error occurs
-
getMessageSequence
public byte getMessageSequence()Description copied from interface:MessageReaderGet last message sequence number, as it was stored byMessageReader.readHeader().- Specified by:
getMessageSequencein interfaceMessageReader<NativePacketHeader,NativePacketPayload>- Returns:
- number
-
resetMessageSequence
public void resetMessageSequence()Description copied from interface:MessageReaderSet stored message sequence number to 0.- Specified by:
resetMessageSequencein interfaceMessageReader<NativePacketHeader,NativePacketPayload>
-