public abstract class AbstractPacketOutputStream extends FilterOutputStream implements PacketOutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected long |
cmdLength |
protected int |
maxAllowedPacket |
protected int |
maxQuerySizeToLog |
protected boolean |
permitTrace |
protected int |
pos |
protected int |
seqNo |
protected String |
serverThreadLog |
protected LruTraceCache |
traceCache |
out| Constructor and Description |
|---|
AbstractPacketOutputStream(OutputStream out,
int maxQuerySizeToLog)
Common feature to write data into socket, creating MariaDB Packet.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
bufferIsDataAfterMark() |
void |
checkMaxAllowedLength(int length)
Count query size.
|
boolean |
checkRemainingSize(int len) |
boolean |
exceedMaxLength() |
void |
flush()
Send packet to socket.
|
protected abstract void |
flushBuffer(boolean commandEnd) |
void |
flushBufferStopAtMark()
Flush to last mark.
|
int |
getMaxAllowedPacket() |
abstract int |
getMaxPacketLength() |
OutputStream |
getOutputStream() |
boolean |
isMarked() |
void |
mark() |
void |
permitTrace(boolean permitTrace) |
byte[] |
resetMark()
Reset mark flag and send bytes after mark flag.
|
abstract void |
setMaxAllowedPacket(int maxAllowedPacket) |
void |
setServerThreadId(long serverThreadId,
Boolean isMaster)
Set server thread id.
|
void |
setTraceCache(LruTraceCache traceCache) |
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.
|
closeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, initialPacketPosprotected final int maxQuerySizeToLog
protected byte[] buf
protected int pos
protected int maxAllowedPacket
protected long cmdLength
protected boolean permitTrace
protected int seqNo
protected String serverThreadLog
protected LruTraceCache traceCache
public AbstractPacketOutputStream(OutputStream out, int maxQuerySizeToLog)
out - socket outputStreammaxQuerySizeToLog - maximum query size to logpublic abstract int getMaxPacketLength()
public abstract void startPacket(int seqNo)
startPacket in interface PacketOutputStreamprotected abstract void flushBuffer(boolean commandEnd)
throws IOException
IOExceptionpublic void writeEmptyPacket(int seqNo)
throws IOException
writeEmptyPacket in interface PacketOutputStreamseqNo - packet sequenceIOException - if socket error occur.public abstract void writeEmptyPacket()
throws IOException
writeEmptyPacket in interface PacketOutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in interface PacketOutputStreamflush in class FilterOutputStreamIOException - if socket error occur.public boolean checkRemainingSize(int len)
checkRemainingSize in interface PacketOutputStreampublic void checkMaxAllowedLength(int length)
throws MaxAllowedPacketException
checkMaxAllowedLength in interface PacketOutputStreamlength - additional length to query sizeMaxAllowedPacketException - if query has not to be send.public boolean exceedMaxLength()
exceedMaxLength in interface PacketOutputStreampublic OutputStream getOutputStream()
getOutputStream in interface PacketOutputStreampublic void writeShort(short value)
throws IOException
writeShort in interface PacketOutputStreamvalue - short valueIOException - if socket error occurpublic void writeInt(int value)
throws IOException
writeInt in interface PacketOutputStreamvalue - int valueIOException - if socket error occurpublic void writeLong(long value)
throws IOException
writeLong in interface PacketOutputStreamvalue - long valueIOException - if socket error occurpublic void writeBytes(byte value,
int len)
throws IOException
writeBytes in interface PacketOutputStreamvalue - byte valuelen - number of time to write value.IOException - if socket error occur.public void writeFieldLength(long length)
throws IOException
writeFieldLength in interface PacketOutputStreamlength - field lengthIOException - if socket error occur.public void write(int value)
throws IOException
write in interface PacketOutputStreamwrite in class FilterOutputStreamvalue - byte to sendIOException - if socket error occur.public void write(byte[] arr)
throws IOException
write in interface PacketOutputStreamwrite in class FilterOutputStreamIOExceptionpublic void write(byte[] arr,
int off,
int len)
throws IOException
write in interface PacketOutputStreamwrite in class FilterOutputStreamarr - byte arrayoff - offsetlen - byte length to writeIOException - if socket error occurpublic void write(String str) throws IOException
write in interface PacketOutputStreamIOExceptionpublic void write(String str, boolean escape, boolean noBackslashEscapes) throws IOException
write in interface PacketOutputStreamstr - stringescape - must be escapenoBackslashEscapes - escape methodIOException - if socket error occurpublic void write(InputStream is, boolean escape, boolean noBackslashEscapes) throws IOException
write in interface PacketOutputStreamis - 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 PacketOutputStreamis - 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 PacketOutputStreamreader - 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 PacketOutputStreamreader - 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 PacketOutputStreambytes - byteslen - len to writenoBackslashEscapes - escape methodIOException - if socket error occurpublic int getMaxAllowedPacket()
getMaxAllowedPacket in interface PacketOutputStreampublic abstract void setMaxAllowedPacket(int maxAllowedPacket)
setMaxAllowedPacket in interface PacketOutputStreampublic void permitTrace(boolean permitTrace)
permitTrace in interface PacketOutputStreampublic void setServerThreadId(long serverThreadId,
Boolean isMaster)
setServerThreadId in interface PacketOutputStreamserverThreadId - current server thread id.isMaster - is server masterpublic void setTraceCache(LruTraceCache traceCache)
setTraceCache in interface PacketOutputStreampublic void mark()
mark in interface PacketOutputStreampublic boolean isMarked()
isMarked in interface PacketOutputStreampublic void flushBufferStopAtMark()
throws IOException
flushBufferStopAtMark in interface PacketOutputStreamIOException - if flush fail.public boolean bufferIsDataAfterMark()
bufferIsDataAfterMark in interface PacketOutputStreampublic byte[] resetMark()
resetMark in interface PacketOutputStreamCopyright © 2019 mariadb.org. All rights reserved.