Skip to content

Commit

Permalink
Merge pull request MyCATApache#1 from MyCATApache/master
Browse files Browse the repository at this point in the history
更新
  • Loading branch information
kkzfl22 authored Aug 14, 2017
2 parents 9797df8 + 4b875f1 commit b138b82
Show file tree
Hide file tree
Showing 18 changed files with 386 additions and 494 deletions.
43 changes: 3 additions & 40 deletions source/src/main/java/io/mycat/mycat2/MySQLSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ public void sendAuthPackge() throws IOException {
// 发送握手数据包
HandshakePacket hs = new HandshakePacket();
hs.packetId = 0;
hs.protocolVersion = Versions.PROTOCOL_VERSION;
hs.serverVersion = Versions.SERVER_VERSION;
hs.protocolVersion = Version.PROTOCOL_VERSION;
hs.serverVersion = Version.SERVER_VERSION;
hs.threadId = this.getSessionId();
hs.seed = rand1;
hs.serverCapabilities = getServerCapabilities();
Expand Down Expand Up @@ -151,44 +151,7 @@ public void answerFront(byte[] rawPkg) throws IOException {
writeToChannel(frontBuffer, frontChannel);
}

/**
* 从Socket中读取数据,通常在NIO事件中调用,比如onFrontRead/onBackendRead
*
* @param session
* @param readFront
* @return
* @throws IOException
*/
public boolean readSocket(boolean readFront) throws IOException {
//默认获得后端的buffer和前端的channel
ProxyBuffer buffer = backendBuffer;
SocketChannel channel = frontChannel;

//如果标识当前为false,则表示当前为读取后端通道的数据
if (!readFront) {
//则当前的为前端的buffer和后端的channel
buffer = frontBuffer;
channel = backendChannel;
}
//进行通道数据的读取
int readed = readFromChannel(buffer, channel);
logger.debug("readed {} total bytes ", readed);
if (readed == -1) {
closeSocket(channel, true, "read EOF.");
return false;
} else if (readed == 0) {
logger.warn("read 0 bytes ,try compact buffer " + (readFront ? " front " : "backend ") + " ,session Id :"
+ this.getSessionId());
buffer.compact(true);
// todo curMSQLPackgInf
// 也许要对应的改变位置,如果curMSQLPackgInf是跨Package的,则可能无需改变信息
// curPackInf.
return false;
}
//更新当前数据读取到的长度信息
buffer.updateReadLimit();
return true;
}


/**
* 解析MySQL报文,解析的结果存储在curMSQLPackgInf中,如果解析到完整的报文,就返回TRUE
Expand Down
2 changes: 0 additions & 2 deletions source/src/main/java/io/mycat/mycat2/MycatCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
import io.mycat.proxy.NIOAcceptor;
import io.mycat.proxy.ProxyReactorThread;
import io.mycat.proxy.ProxyRuntime;
import io.mycat.proxy.man.AdminCommandResovler;
import io.mycat.proxy.man.ClusterNode;
import io.mycat.proxy.man.DefaultAdminSessionHandler;
import io.mycat.proxy.man.DefaultAdminSessionManager;
import io.mycat.proxy.man.MyCluster;

Expand Down
37 changes: 0 additions & 37 deletions source/src/main/java/io/mycat/mycat2/Versions.java

This file was deleted.

Loading

0 comments on commit b138b82

Please sign in to comment.