use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class TransformSQLJob method run.
@Override
public void run() {
try {
if (ds == null) {
RouteResultsetNode node = new RouteResultsetNode(databaseName, ServerParse.SELECT, sql);
// create new connection
PhysicalDBNode dn = DbleServer.getInstance().getConfig().getDataNodes().get(node.getName());
dn.getConnection(dn.getDatabase(), false, true, node, this, node);
} else {
ds.getConnection(databaseName, true, this, null);
}
} catch (Exception e) {
LOGGER.info("can't get connection for sql ,error:" + e);
ErrorPacket errPacket = new ErrorPacket();
errPacket.setPacketId(0);
errPacket.setErrNo(ErrorCode.ER_YES);
errPacket.setMessage(StringUtil.encode(e.toString(), StandardCharsets.UTF_8.toString()));
writeError(errPacket.toBytes());
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class TransformSQLJob method connectionClose.
@Override
public void connectionClose(BackendConnection conn, String reason) {
ErrorPacket errPacket = new ErrorPacket();
errPacket.setPacketId(0);
errPacket.setErrNo(ErrorCode.ER_YES);
errPacket.setMessage(StringUtil.encode(reason, StandardCharsets.UTF_8.toString()));
writeError(errPacket.toBytes());
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class TransformSQLJob method connectionAcquired.
@Override
public void connectionAcquired(BackendConnection conn) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("con query sql:" + sql + " to con:" + conn);
}
conn.setResponseHandler(this);
connection = conn;
try {
conn.query(sql);
} catch (Exception e) {
// (UnsupportedEncodingException e) {
ErrorPacket errPacket = new ErrorPacket();
errPacket.setPacketId(0);
errPacket.setErrNo(ErrorCode.ER_YES);
errPacket.setMessage(StringUtil.encode(e.toString(), StandardCharsets.UTF_8.toString()));
writeError(errPacket.toBytes());
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class Heartbeat method response.
public static void response(ServerConnection c, byte[] data) {
HeartbeatPacket hp = new HeartbeatPacket();
hp.read(data);
if (DbleServer.getInstance().isOnline()) {
OkPacket ok = new OkPacket();
ok.setPacketId(1);
ok.setAffectedRows(hp.getId());
ok.setServerStatus(2);
ok.write(c);
if (HEARTBEAT.isInfoEnabled()) {
HEARTBEAT.info(responseMessage("OK", c, hp.getId()));
}
} else {
ErrorPacket error = new ErrorPacket();
error.setPacketId(1);
error.setErrNo(ErrorCode.ER_SERVER_SHUTDOWN);
error.setMessage(String.valueOf(hp.getId()).getBytes());
error.write(c);
if (HEARTBEAT.isInfoEnabled()) {
HEARTBEAT.info(responseMessage("ERROR", c, hp.getId()));
}
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class FetchMySQLSequenceHandler method errorResponse.
@Override
public void errorResponse(byte[] data, BackendConnection conn) {
SequenceVal seqVal = ((SequenceVal) conn.getAttachment());
seqVal.dbfinished = true;
ErrorPacket err = new ErrorPacket();
err.read(data);
String errMsg = new String(err.getMessage());
LOGGER.info("errorResponse " + err.getErrNo() + " " + errMsg);
IncrSequenceMySQLHandler.LATEST_ERRORS.put(seqVal.seqName, errMsg);
conn.release();
}
Aggregations