use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class BaseHandlerBuilder method handleBlockingSubQuery.
protected void handleBlockingSubQuery() {
if (node.getSubQueries().size() == 0) {
return;
}
final ReentrantLock lock = new ReentrantLock();
final Condition finishSubQuery = lock.newCondition();
final AtomicBoolean finished = new AtomicBoolean(false);
final AtomicInteger subNodes = new AtomicInteger(node.getSubQueries().size());
final CopyOnWriteArrayList<ErrorPacket> errorPackets = new CopyOnWriteArrayList<>();
for (ItemSubQuery itemSubQuery : node.getSubQueries()) {
if (itemSubQuery instanceof ItemSingleRowSubQuery) {
final SubQueryHandler tempHandler = new SingleRowSubQueryHandler(getSequenceId(), session, (ItemSingleRowSubQuery) itemSubQuery);
if (isExplain) {
handleSubQueryForExplain(lock, finishSubQuery, finished, subNodes, itemSubQuery.getPlanNode(), tempHandler);
} else {
handleSubQuery(lock, finishSubQuery, finished, subNodes, errorPackets, itemSubQuery.getPlanNode(), tempHandler);
}
} else if (itemSubQuery instanceof ItemInSubQuery) {
final SubQueryHandler tempHandler = new InSubQueryHandler(getSequenceId(), session, (ItemInSubQuery) itemSubQuery);
if (isExplain) {
handleSubQueryForExplain(lock, finishSubQuery, finished, subNodes, itemSubQuery.getPlanNode(), tempHandler);
} else {
handleSubQuery(lock, finishSubQuery, finished, subNodes, errorPackets, itemSubQuery.getPlanNode(), tempHandler);
}
} else if (itemSubQuery instanceof ItemAllAnySubQuery) {
final SubQueryHandler tempHandler = new AllAnySubQueryHandler(getSequenceId(), session, (ItemAllAnySubQuery) itemSubQuery);
if (isExplain) {
handleSubQueryForExplain(lock, finishSubQuery, finished, subNodes, itemSubQuery.getPlanNode(), tempHandler);
} else {
handleSubQuery(lock, finishSubQuery, finished, subNodes, errorPackets, itemSubQuery.getPlanNode(), tempHandler);
}
}
}
lock.lock();
try {
while (!finished.get()) {
finishSubQuery.await();
}
} catch (InterruptedException e) {
LOGGER.info("execute ScalarSubQuery " + e);
ErrorPacket errorPackage = new ErrorPacket();
errorPackage.setErrNo(ErrorCode.ER_UNKNOWN_ERROR);
String errorMsg = e.getMessage() == null ? e.toString() : e.getMessage();
errorPackage.setMessage(errorMsg.getBytes(StandardCharsets.UTF_8));
errorPackets.add(errorPackage);
} finally {
lock.unlock();
}
if (errorPackets.size() > 0) {
throw new MySQLOutPutException(errorPackets.get(0).getErrNo(), "", new String(errorPackets.get(0).getMessage(), StandardCharsets.UTF_8));
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class MultiNodeHandler method errorResponse.
public void errorResponse(byte[] data, BackendConnection conn) {
session.releaseConnectionIfSafe(conn, false);
ErrorPacket errPacket = new ErrorPacket();
errPacket.read(data);
String errMsg = new String(errPacket.getMessage());
LOGGER.info("error response from " + conn + " err " + errMsg + " code:" + errPacket.getErrNo());
this.tryErrorFinished(this.decrementCountBy(1));
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class MultiNodeHandler method createErrPkg.
protected ErrorPacket createErrPkg(String errMsg) {
ErrorPacket err = new ErrorPacket();
lock.lock();
try {
err.setPacketId(++packetId);
} finally {
lock.unlock();
}
err.setErrNo(ErrorCode.ER_UNKNOWN_ERROR);
err.setMessage(StringUtil.encode(errMsg, session.getSource().getCharset().getResults()));
return err;
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class SubQueryHandler method genErrorPackage.
protected void genErrorPackage(int errorNum, String msg) {
if (errorPacket == null) {
errorPacket = new ErrorPacket();
errorPacket.setErrNo(errorNum);
errorPacket.setMessage(msg.getBytes(StandardCharsets.UTF_8));
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class MultiNodeDdlHandler method connectionClose.
@Override
public void connectionClose(BackendConnection conn, String reason) {
if (checkClosedConn(conn)) {
return;
}
LOGGER.info("backend connect" + reason);
ErrorPacket errPacket = new ErrorPacket();
errPacket.setPacketId(++packetId);
errPacket.setErrNo(ErrorCode.ER_ABORTING_CONNECTION);
errPacket.setMessage(StringUtil.encode(reason, session.getSource().getCharset().getResults()));
err = errPacket;
executeConnError(conn);
}
Aggregations