public abstract class AbstractPacketOutputStream extends FilterOutputStream implements PacketOutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected Charset |
charset |
protected long |
cmdLength |
protected boolean |
enableNetworkStatistics |
protected int |
maxAllowedPacket |
protected int |
maxPacketLength |
protected int |
maxQuerySizeToLog |
protected int |
mysqlSeqNo |
protected boolean |
permitTrace |
protected int |
pos |
protected String |
serverThreadLog |
protected long |
threadId |
protected long |
timestampBeforeFlush |
protected LruTraceCache |
traceCache |
out| Constructor and Description |
|---|
AbstractPacketOutputStream(OutputStream out,
int maxQuerySizeToLog,
long threadId,
String encoding)
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) |
void |
clearNetworkStatistics() |
void |
enableNetworkStatistics(boolean flag) |
boolean |
exceedMaxLength() |
void |
flush()
Send packet to socket.
|
protected abstract void |
flushBuffer(boolean commandEnd) |
void |
flushBufferStopAtMark()
Flush to last mark.
|
Charset |
getCharset() |
int |
getMaxAllowedPacket() |
int |
getMaxPacketLength() |
OutputStream |
getOutputStream() |
int |
getPosition()
Get current position
|
long |
getTimestampBeforeFlush() |
TimeZone |
getTimeZone() |
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 |
setPosition(int val)
Set current position
|
void |
setServerThreadId(long serverThreadId,
Boolean isMaster)
Set server thread id.
|
void |
setTimeZone(TimeZone tm) |
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.
|
void |
writeBytesEscaped(byte[] bytes,
int len,
boolean noBackslashEscapes)
Write escape bytes to socket.
|
void |
writeBytesEscapedQuote(byte[] bytes,
int len,
boolean noBackslashEscapes)
Write escape bytes to socket.
|
abstract void |
writeEmptyPacket() |
void |
writeEmptyPacket(int seqNo)
Send empty packet.
|
void |
writeEscapeQuote(Reader reader,
boolean noBackslashEscapes) |
void |
writeEscapeQuote(Reader reader,
long length,
boolean noBackslashEscapes) |
void |
writeFieldLength(long length)
Write field length into buffer, flush socket if needed.
|
void |
writeFloatV1(float f) |
void |
writeHex(InputStream is,
boolean escape,
boolean noBackslashEscapes)
Write stream AS hexdump into socket.
|
void |
writeHex(InputStream is,
long length,
boolean escape,
boolean noBackslashEscapes)
Write stream As hexdump into socket.
|
void |
writeInt(int value)
Write int value into buffer.
|
void |
writeIntV1(int i)
writeInt operation for jdbc 1.x
|
void |
writeLong(long value)
Write long value into buffer.
|
void |
writeLongV1(long i)
writeLong operation for jdbc 1.x
|
void |
writeShort(short value)
Write short value into buffer.
|
closeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, initialPacketPosprotected long threadId
protected int mysqlSeqNo
protected LruTraceCache traceCache
protected String serverThreadLog
protected final int maxQuerySizeToLog
protected boolean enableNetworkStatistics
protected long timestampBeforeFlush
protected byte[] buf
protected int pos
protected long cmdLength
protected int maxPacketLength
protected int maxAllowedPacket
protected boolean permitTrace
protected Charset charset
public AbstractPacketOutputStream(OutputStream out, int maxQuerySizeToLog, long threadId, String encoding)
out - socket outputStreammaxQuerySizeToLog - maximum query size to logthreadId - thread idpublic void setTimeZone(TimeZone tm)
setTimeZone in interface PacketOutputStreampublic TimeZone getTimeZone()
getTimeZone in interface PacketOutputStreampublic int getMaxPacketLength()
public abstract void startPacket(int seqNo)
startPacket in interface PacketOutputStreampublic void enableNetworkStatistics(boolean flag)
enableNetworkStatistics in interface PacketOutputStreampublic long getTimestampBeforeFlush()
getTimestampBeforeFlush in interface PacketOutputStreampublic void clearNetworkStatistics()
clearNetworkStatistics in interface PacketOutputStreampublic Charset getCharset()
getCharset 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 PacketOutputStreamflush in interface Flushableflush 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 final void writeIntV1(int i)
throws IOException
writeIntV1 in interface PacketOutputStreami - IOExceptionpublic void writeInt(int value)
throws IOException
writeInt in interface PacketOutputStreamvalue - int valueIOException - if socket error occurpublic void writeFloatV1(float f)
throws IOException
writeFloatV1 in interface PacketOutputStreamIOExceptionpublic void writeLong(long value)
throws IOException
writeLong in interface PacketOutputStreamvalue - long valueIOException - if socket error occurpublic void writeLongV1(long i)
throws IOException
writeLongV1 in interface PacketOutputStreami - IOExceptionpublic 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 writeHex(InputStream is, boolean escape, boolean noBackslashEscapes) throws IOException
writeHex 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 writeHex(InputStream is, long length, boolean escape, boolean noBackslashEscapes) throws IOException
writeHex 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 writeEscapeQuote(Reader reader, boolean noBackslashEscapes) throws IOException
writeEscapeQuote in interface PacketOutputStreamIOExceptionpublic void writeEscapeQuote(Reader reader, long length, boolean noBackslashEscapes) throws IOException
writeEscapeQuote in interface PacketOutputStreamIOExceptionpublic 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 void writeBytesEscapedQuote(byte[] bytes,
int len,
boolean noBackslashEscapes)
throws IOException
writeBytesEscapedQuote 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 PacketOutputStreampublic int getPosition()
getPosition in interface PacketOutputStreampublic void setPosition(int val)
setPosition in interface PacketOutputStreamval - set current position vallue to valCopyright © 2022 oceanbase.com. All rights reserved.