use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.
the class MySQLConnectionAuthenticator method handle.
@Override
public void handle(byte[] data) {
try {
switch(data[4]) {
case OkPacket.FIELD_COUNT:
HandshakePacket packet = source.getHandshake();
if (packet == null) {
processHandShakePacket(data);
// 发送认证数据包
source.authenticate();
break;
}
// 处理认证结果
source.setHandler(new MySQLConnectionHandler(source));
source.setAuthenticated(true);
boolean clientCompress = Capabilities.CLIENT_COMPRESS == (Capabilities.CLIENT_COMPRESS & packet.serverCapabilities);
boolean usingCompress = MycatServer.getInstance().getConfig().getSystem().getUseCompression() == 1;
if (clientCompress && usingCompress) {
source.setSupportCompress(true);
}
if (listener != null) {
listener.connectionAcquired(source);
}
break;
case ErrorPacket.FIELD_COUNT:
ErrorPacket err = new ErrorPacket();
err.read(data);
String errMsg = new String(err.message);
LOGGER.warn("can't connect to mysql server ,errmsg:" + errMsg + " " + source);
//source.close(errMsg);
throw new ConnectionException(err.errno, errMsg);
case EOFPacket.FIELD_COUNT:
auth323(data[3]);
break;
default:
packet = source.getHandshake();
if (packet == null) {
processHandShakePacket(data);
// 发送认证数据包
source.authenticate();
break;
} else {
throw new RuntimeException("Unknown Packet!");
}
}
} catch (RuntimeException e) {
if (listener != null) {
listener.connectionError(e, source);
return;
}
throw e;
}
}
use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.
the class SingleNodeHandler method connectionClose.
@Override
public void connectionClose(BackendConnection conn, String reason) {
ErrorPacket err = new ErrorPacket();
err.packetId = ++packetId;
err.errno = ErrorCode.ER_ERROR_ON_CLOSE;
err.message = StringUtil.encode(reason, session.getSource().getCharset());
this.backConnectionErr(err, conn);
}
use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.
the class FetchStoreNodeOfChildTableHandler method errorResponse.
@Override
public void errorResponse(byte[] data, BackendConnection conn) {
finished.incrementAndGet();
ErrorPacket err = new ErrorPacket();
err.read(data);
LOGGER.warn("errorResponse " + err.errno + " " + new String(err.message));
conn.release();
}
use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.
the class KillConnectionHandler method errorResponse.
@Override
public void errorResponse(byte[] data, BackendConnection conn) {
ErrorPacket err = new ErrorPacket();
err.read(data);
String msg = null;
try {
msg = new String(err.message, conn.getCharset());
} catch (UnsupportedEncodingException e) {
msg = new String(err.message);
}
LOGGER.warn("kill backend connection " + killee + " failed: " + msg + " con:" + conn);
conn.release();
killee.close("exception:" + msg);
}
use of io.mycat.net.mysql.ErrorPacket in project Mycat-Server by MyCATApache.
the class CommitCommand method errorResponse.
@Override
public void errorResponse(NonBlockingSession session, byte[] err, int total, int failed) {
ErrorPacket errPkg = new ErrorPacket();
errPkg.read(err);
String errInfo = "total " + total + " failed " + failed + " detail:" + new String(errPkg.message);
session.getSource().setTxInterrupt(errInfo);
errPkg.write(session.getSource());
}
Aggregations