public abstract class AbstractPacketOutputStream extends FilterOutputStream implements PacketOutputStream
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf |
protected long |
cmdLength |
protected static Logger |
logger |
protected int |
maxAllowedPacket |
protected int |
maxQuerySizeToLog |
protected boolean |
permitTrace |
protected int |
pos |
protected int |
seqNo |
protected String |
serverThreadLog |
out
Constructor and Description |
---|
AbstractPacketOutputStream(OutputStream out,
int maxQuerySizeToLog)
Common feature to write data into socket, creating MySQL Packet.
|
Modifier and Type | Method and Description |
---|---|
void |
checkMaxAllowedLength(int length)
Count query size.
|
boolean |
checkRemainingSize(int len) |
void |
flush()
Send packet to socket.
|
protected abstract void |
flushBuffer(boolean commandEnd) |
int |
getMaxAllowedPacket() |
abstract int |
getMaxPacketLength() |
OutputStream |
getOutputStream() |
boolean |
isAllowedCmdLength() |
void |
permitTrace(boolean permitTrace) |
abstract void |
setMaxAllowedPacket(int maxAllowedPacket) |
void |
setServerThreadId(long serverThreadId,
Boolean isMaster)
Set server thread id.
|
abstract void |
startPacket(int seqNo) |
void |
write(byte[] arr) |
void |
write(byte[] arr,
int off,
int len)
Write byte array to buffer.
|
void |
write(InputStream is,
boolean escape,
boolean noBackslashEscapes)
Write stream into socket.
|
void |
write(InputStream is,
long length,
boolean escape,
boolean noBackslashEscapes)
Write stream into socket.
|
void |
write(int value)
Write byte into buffer, flush buffer to socket if needed.
|
void |
write(Reader reader,
boolean escape,
boolean noBackslashEscapes)
Write reader into socket.
|
void |
write(Reader reader,
long length,
boolean escape,
boolean noBackslashEscapes)
Write reader into socket.
|
void |
write(String str) |
void |
write(String str,
boolean escape,
boolean noBackslashEscapes)
Write string to socket.
|
void |
writeBytes(byte value,
int len)
Write byte value, len times into buffer. flush buffer if too small.
|
void |
writeBytesEscaped(byte[] bytes,
int len,
boolean noBackslashEscapes)
Write escape bytes to socket.
|
abstract void |
writeEmptyPacket() |
void |
writeEmptyPacket(int seqNo)
Send empty packet.
|
void |
writeFieldLength(long length)
Write field length into buffer, flush socket if needed.
|
void |
writeInt(int value)
Write int value into buffer. flush buffer if too small.
|
void |
writeLong(long value)
Write long value into buffer. flush buffer if too small.
|
void |
writeShort(short value)
Write short value into buffer. flush buffer if too small.
|
close
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
protected static Logger logger
protected byte[] buf
protected int pos
protected int maxAllowedPacket
protected int maxQuerySizeToLog
protected long cmdLength
protected boolean permitTrace
protected int seqNo
protected String serverThreadLog
public AbstractPacketOutputStream(OutputStream out, int maxQuerySizeToLog)
out
- socket outputStreammaxQuerySizeToLog
- maximum query size to logpublic abstract int getMaxPacketLength()
public abstract void setMaxAllowedPacket(int maxAllowedPacket)
setMaxAllowedPacket
in interface PacketOutputStream
public abstract void startPacket(int seqNo)
startPacket
in interface PacketOutputStream
protected abstract void flushBuffer(boolean commandEnd) throws IOException
IOException
public void writeEmptyPacket(int seqNo) throws IOException
writeEmptyPacket
in interface PacketOutputStream
seqNo
- packet sequenceIOException
- if socket error occur.public abstract void writeEmptyPacket() throws IOException
writeEmptyPacket
in interface PacketOutputStream
IOException
public void flush() throws IOException
flush
in interface Flushable
flush
in interface PacketOutputStream
flush
in class FilterOutputStream
IOException
- if socket error occur.public boolean checkRemainingSize(int len)
checkRemainingSize
in interface PacketOutputStream
public void checkMaxAllowedLength(int length) throws MaxAllowedPacketException
length
- additional length to query sizeMaxAllowedPacketException
- if query has not to be send.public boolean isAllowedCmdLength()
isAllowedCmdLength
in interface PacketOutputStream
public OutputStream getOutputStream()
getOutputStream
in interface PacketOutputStream
public void writeShort(short value) throws IOException
writeShort
in interface PacketOutputStream
value
- short valueIOException
- if socket error occurpublic void writeInt(int value) throws IOException
writeInt
in interface PacketOutputStream
value
- int valueIOException
- if socket error occurpublic void writeLong(long value) throws IOException
writeLong
in interface PacketOutputStream
value
- long valueIOException
- if socket error occurpublic void writeBytes(byte value, int len) throws IOException
writeBytes
in interface PacketOutputStream
value
- byte valuelen
- number of time to write value.IOException
- if socket error occur.public void writeFieldLength(long length) throws IOException
writeFieldLength
in interface PacketOutputStream
length
- field lengthIOException
- if socket error occur.public void write(int value) throws IOException
write
in interface PacketOutputStream
write
in class FilterOutputStream
value
- byte to sendIOException
- if socket error occur.public void write(byte[] arr) throws IOException
write
in interface PacketOutputStream
write
in class FilterOutputStream
IOException
public void write(byte[] arr, int off, int len) throws IOException
write
in interface PacketOutputStream
write
in class FilterOutputStream
arr
- byte arrayoff
- offsetlen
- byte length to writeIOException
- if socket error occurpublic void write(String str) throws IOException
write
in interface PacketOutputStream
IOException
public void write(String str, boolean escape, boolean noBackslashEscapes) throws IOException
write
in interface PacketOutputStream
str
- stringescape
- must be escapenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic void write(InputStream is, boolean escape, boolean noBackslashEscapes) throws IOException
write
in interface PacketOutputStream
is
- inputStreamescape
- must be escapenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic void write(InputStream is, long length, boolean escape, boolean noBackslashEscapes) throws IOException
write
in interface PacketOutputStream
is
- inputStreamlength
- write lengthescape
- must be escapenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic void write(Reader reader, boolean escape, boolean noBackslashEscapes) throws IOException
write
in interface PacketOutputStream
reader
- readerescape
- must be escapenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic void write(Reader reader, long length, boolean escape, boolean noBackslashEscapes) throws IOException
write
in interface PacketOutputStream
reader
- readerlength
- write lengthescape
- must be escapenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic void writeBytesEscaped(byte[] bytes, int len, boolean noBackslashEscapes) throws IOException
writeBytesEscaped
in interface PacketOutputStream
bytes
- byteslen
- len to writenoBackslashEscapes
- escape methodIOException
- if socket error occurpublic int getMaxAllowedPacket()
getMaxAllowedPacket
in interface PacketOutputStream
public void permitTrace(boolean permitTrace)
permitTrace
in interface PacketOutputStream
public void setServerThreadId(long serverThreadId, Boolean isMaster)
setServerThreadId
in interface PacketOutputStream
serverThreadId
- current server thread id.isMaster
- is server masterCopyright © 2017. All rights reserved.