use of com.actiontech.dble.backend.mysql.nio.MySQLConnection in project dble by actiontech.
the class MultiNodeMergeHandler method execute.
public void execute() throws Exception {
synchronized (exeHandlers) {
if (terminate.get())
return;
for (BaseSelectHandler exeHandler : exeHandlers) {
MySQLConnection exeConn = exeHandler.initConnection();
if (exeConn != null) {
exeConn.setComplexQuery(true);
queues.put(exeConn, new LinkedBlockingQueue<HeapItem>(queueSize));
exeHandler.execute(exeConn);
}
}
}
}
use of com.actiontech.dble.backend.mysql.nio.MySQLConnection in project dble by actiontech.
the class OrderByHandler method ownThreadJob.
@Override
protected void ownThreadJob(Object... objects) {
MySQLConnection conn = (MySQLConnection) objects[0];
recordElapsedTime("order write start :");
try {
while (true) {
if (terminate.get()) {
return;
}
RowDataPacket row = null;
try {
row = queue.take();
} catch (InterruptedException e) {
// ignore error
}
if (row.getFieldCount() == 0) {
break;
}
localResult.add(row);
}
recordElapsedTime("order write end :");
localResult.done();
recordElapsedTime("order read start :");
while (true) {
if (terminate.get()) {
return;
}
RowDataPacket row = localResult.next();
if (row == null) {
break;
}
if (nextHandler.rowResponse(null, row, this.isLeft, conn))
break;
}
recordElapsedTime("order read end:");
nextHandler.rowEofResponse(null, this.isLeft, conn);
} catch (Exception e) {
String msg = "OrderBy thread error, " + e.getLocalizedMessage();
LOGGER.info(msg, e);
session.onQueryError(msg.getBytes());
}
}
use of com.actiontech.dble.backend.mysql.nio.MySQLConnection in project dble by actiontech.
the class ConnectionHeartBeatHandler method doHeartBeat.
public void doHeartBeat(BackendConnection conn) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("do heartbeat for con " + conn);
}
lock.lock();
try {
conn.setResponseHandler(this);
MySQLConnection mCon = (MySQLConnection) conn;
mCon.write(mCon.writeToBuffer(PingPacket.PING, mCon.allocate()));
long validateTime = 2;
if (!condition.await(validateTime, TimeUnit.SECONDS)) {
// if the thread be waked up by timer than close the connection
conn.close("heartbeat timeout ");
}
} catch (Exception e) {
executeException(conn, e);
} finally {
lock.unlock();
}
}
use of com.actiontech.dble.backend.mysql.nio.MySQLConnection in project dble by actiontech.
the class KillConnectionHandler method connectionAcquired.
@Override
public void connectionAcquired(BackendConnection conn) {
conn.setResponseHandler(this);
conn.setSession(session);
CommandPacket packet = new CommandPacket();
packet.setPacketId(0);
packet.setCommand(MySQLPacket.COM_QUERY);
packet.setArg(("KILL " + toKilled.getThreadId()).getBytes());
MySQLConnection mysqlCon = (MySQLConnection) conn;
packet.write(mysqlCon);
}
Aggregations