use of io.mycat.beans.mysql.packet.ProxyBuffer in project Mycat2 by MyCATApache.
the class ResultSetHandler method onWriteFinished.
/**
* 向mysql服务器写入结束,切换到读事件
*/
@Override
default void onWriteFinished(MySQLClientSession mysql) {
ProxyBuffer proxyBuffer = mysql.currentProxyBuffer();
// 写入完毕不清理buffer但是要把下标重置
proxyBuffer.channelReadStartIndex(0);
proxyBuffer.channelReadEndIndex(0);
mysql.change2ReadOpts();
}
use of io.mycat.beans.mysql.packet.ProxyBuffer in project Mycat2 by MyCATApache.
the class MySQLClientSession method readFromChannel.
@Override
public boolean readFromChannel() throws IOException {
boolean b = MySQLProxySession.super.readFromChannel();
ProxyBuffer proxyBuffer = this.proxyBuffer;
MycatMonitor.onBackendRead(this, proxyBuffer.currentByteBuffer(), proxyBuffer.channelReadStartIndex(), proxyBuffer.channelReadEndIndex() - proxyBuffer.channelReadStartIndex());
return b;
}
use of io.mycat.beans.mysql.packet.ProxyBuffer in project Mycat2 by MyCATApache.
the class MySQLClientSession method newCurrentProxyPacket.
/**
* 把当前的proxybuffer作为报文构造
*/
public MySQLPacket newCurrentProxyPacket(int packetLength) {
ProxyBuffer proxyBuffer = currentProxyBuffer();
proxyBuffer.reset();
proxyBuffer.newBuffer(packetLength);
MySQLPacket mySQLPacket = (MySQLPacket) proxyBuffer;
mySQLPacket.writeSkipInWriting(4);
return mySQLPacket;
}
use of io.mycat.beans.mysql.packet.ProxyBuffer in project Mycat2 by MyCATApache.
the class MySQLClientSession method writeProxyBufferToChannel.
/**
* 最终把buffer写入通道的方法
*/
final PromiseInternal<Void> writeProxyBufferToChannel() throws IOException {
ProxyBuffer proxyBuffer = this.currentProxyBuffer();
int oldIndex = proxyBuffer.channelWriteStartIndex();
proxyBuffer.writeToChannel(this.channel());
MycatMonitor.onBackendWrite(this, proxyBuffer.currentByteBuffer(), oldIndex, proxyBuffer.channelWriteEndIndex());
this.updateLastActiveTime();
this.checkWriteFinished();
getChannelKey().selector().wakeup();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("sessionId:{} writeProxyBufferToChannel successfully", sessionId());
}
return VertxUtil.newSuccessPromise();
}
use of io.mycat.beans.mysql.packet.ProxyBuffer in project Mycat2 by MyCATApache.
the class MySQLProxySession method readFromChannel.
/**
* 读取通道的数据,该方法在mycat 与mysql session都作为通道读
*/
default boolean readFromChannel() throws IOException {
ProxyBuffer proxyBuffer = currentProxyBuffer();
// proxyBuffer.newBufferIfNeed();
proxyBuffer.compactInChannelReadingIfNeed();
boolean b = proxyBuffer.readFromChannel(this.channel());
updateLastActiveTime();
return b;
}
Aggregations