use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class AbstractCommitNodesHandler method commit.
@Override
public void commit() {
final int initCount = session.getTargetCount();
lock.lock();
try {
reset(initCount);
} finally {
lock.unlock();
}
int position = 0;
// then the XA transaction will be not killed, if killed ,then we will not commit
if (session.getXaState() != null && session.getXaState() == TxState.TX_ENDED_STATE) {
if (!session.cancelableStatusSet(NonBlockingSession.CANCEL_STATUS_COMMITTING)) {
return;
}
}
try {
sendFinishedFlag = false;
for (RouteResultsetNode rrn : session.getTargetKeys()) {
final BackendConnection conn = session.getTarget(rrn);
conn.setResponseHandler(this);
if (!executeCommit((MySQLConnection) conn, position++)) {
break;
}
}
} finally {
lockForErrorHandle.lock();
try {
sendFinishedFlag = true;
sendFinished.signalAll();
} finally {
lockForErrorHandle.unlock();
}
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class NormalRollbackNodesHandler method rollback.
public void rollback() {
final int initCount = session.getTargetCount();
lock.lock();
try {
reset(initCount);
} finally {
lock.unlock();
}
int position = 0;
for (final RouteResultsetNode node : session.getTargetKeys()) {
final BackendConnection conn = session.getTarget(node);
if (conn.isClosed()) {
lock.lock();
try {
nodeCount--;
} finally {
lock.unlock();
}
continue;
}
position++;
conn.setResponseHandler(this);
conn.rollback();
}
if (position == 0) {
if (sendData == null) {
sendData = OkPacket.OK;
}
cleanAndFeedback();
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class XARollbackNodesHandler method rollback.
public void rollback() {
final int initCount = session.getTargetCount();
lock.lock();
try {
reset(initCount);
} finally {
lock.unlock();
}
int position = 0;
// then the XA transaction will be not killed. if killed ,then we will not rollback
if (session.getXaState() != null && session.getXaState() == TxState.TX_ENDED_STATE) {
if (!session.cancelableStatusSet(NonBlockingSession.CANCEL_STATUS_COMMITTING)) {
return;
}
}
try {
sendFinishedFlag = false;
for (final RouteResultsetNode node : session.getTargetKeys()) {
final BackendConnection conn = session.getTarget(node);
conn.setResponseHandler(this);
if (!executeRollback((MySQLConnection) conn, position++)) {
break;
}
}
} finally {
lockForErrorHandle.lock();
try {
sendFinishedFlag = true;
sendFinished.signalAll();
} finally {
lockForErrorHandle.unlock();
}
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class ShowBackendStat method stat.
private static HashMap<String, BackendStat> stat() {
HashMap<String, BackendStat> all = new HashMap<String, BackendStat>();
for (NIOProcessor p : DbleServer.getInstance().getBackendProcessors()) {
for (BackendConnection bc : p.getBackends().values()) {
if ((bc == null) || !(bc instanceof MySQLConnection)) {
break;
}
MySQLConnection con = (MySQLConnection) bc;
String host = con.getHost();
long port = con.getPort();
BackendStat info = all.get(host + Long.toString(port));
if (info == null) {
info = new BackendStat(host, port);
all.put(host + Long.toString(port), info);
}
if (con.isBorrowed()) {
info.addActive();
}
info.addTotal();
}
}
return all;
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class ShowBackend method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
buffer = HEADER.write(buffer, c, true);
for (FieldPacket field : FIELDS) {
buffer = field.write(buffer, c, true);
}
buffer = EOF.write(buffer, c, true);
byte packetId = EOF.getPacketId();
for (NIOProcessor p : DbleServer.getInstance().getBackendProcessors()) {
for (BackendConnection bc : p.getBackends().values()) {
if (bc != null) {
RowDataPacket row = getRow(bc, c.getCharset().getResults());
if (row != null) {
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
}
}
}
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
c.write(buffer);
}
Aggregations