public class CompressPacketOutputStream extends AbstractPacketOutputStream
| Modifier and Type | Field and Description |
|---|---|
private int |
compressSeqNo |
private static byte[] |
EMPTY_ARRAY |
private byte[] |
header |
private boolean |
lastPacketExactMaxPacketLength |
private static Logger |
logger |
private static int |
MAX_PACKET_LENGTH |
private int |
maxPacketLength |
private static float |
MIN_COMPRESSION_RATIO |
private static int |
MIN_COMPRESSION_SIZE |
private byte[] |
remainingData |
private byte[] |
subHeader |
buf, cmdLength, maxAllowedPacket, maxQuerySizeToLog, permitTrace, pos, seqNo, serverThreadLog, threadId, traceCache| Constructor and Description |
|---|
CompressPacketOutputStream(java.io.OutputStream out,
int maxQuerySizeToLog,
long threadId) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
flushBuffer(boolean commandEnd)
Flush the internal buffer.
|
int |
getMaxPacketLength() |
int |
initialPacketPos() |
void |
setMaxAllowedPacket(int maxAllowedPacket) |
void |
startPacket(int compressSeqNo) |
void |
writeEmptyPacket()
Write an empty packet.
|
bufferIsDataAfterMark, checkMaxAllowedLength, checkRemainingSize, exceedMaxLength, flush, flushBufferStopAtMark, getMaxAllowedPacket, getOutputStream, isMarked, mark, permitTrace, resetMark, setServerThreadId, setTraceCache, write, write, write, write, write, write, write, write, write, writeBytes, writeBytesEscaped, writeEmptyPacket, writeFieldLength, writeInt, writeLong, writeShortclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcloseprivate static final Logger logger
private static final int MAX_PACKET_LENGTH
private static final byte[] EMPTY_ARRAY
private static final int MIN_COMPRESSION_SIZE
private static final float MIN_COMPRESSION_RATIO
private final byte[] header
private final byte[] subHeader
private int maxPacketLength
private int compressSeqNo
private byte[] remainingData
private boolean lastPacketExactMaxPacketLength
public CompressPacketOutputStream(java.io.OutputStream out,
int maxQuerySizeToLog,
long threadId)
public int getMaxPacketLength()
getMaxPacketLength in class AbstractPacketOutputStreampublic void setMaxAllowedPacket(int maxAllowedPacket)
setMaxAllowedPacket in interface PacketOutputStreamsetMaxAllowedPacket in class AbstractPacketOutputStreampublic void startPacket(int compressSeqNo)
startPacket in interface PacketOutputStreamstartPacket in class AbstractPacketOutputStreampublic int initialPacketPos()
protected void flushBuffer(boolean commandEnd)
throws java.io.IOException
Compression add a 7 header :
in case packet isn't compressed (last 3 bytes == 0):
Content correspond to standard content.
Problem is when standard content is bigger than 16mb : content will not send 4byte standard header + 16mb content, since packet are limited to 16mb then 4 bytes standard header + 16mb - 4 bytes content. the ending 4 bytes are waiting to be send. next packet will then send the waiting data before next packet, putting more waiting data is needed. if ending data is exactly MAX_PACKET_LENGTH length, then an empty packet must be send.
flushBuffer in class AbstractPacketOutputStreamcommandEnd - command endjava.io.IOException - id connection error occur.public void writeEmptyPacket()
throws java.io.IOException
writeEmptyPacket in interface PacketOutputStreamwriteEmptyPacket in class AbstractPacketOutputStreamjava.io.IOException - if socket error occur.