use of com.actiontech.dble.route.RouteResultsetNode 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.route.RouteResultsetNode in project dble by actiontech.
the class ReloadConfig method findAndcloseFrontCon.
private static void findAndcloseFrontCon(BackendConnection con) {
if (con instanceof MySQLConnection) {
MySQLConnection mcon1 = (MySQLConnection) con;
for (NIOProcessor processor : DbleServer.getInstance().getFrontProcessors()) {
for (FrontendConnection fcon : processor.getFrontends().values()) {
if (fcon instanceof ServerConnection) {
ServerConnection scon = (ServerConnection) fcon;
Map<RouteResultsetNode, BackendConnection> bons = scon.getSession2().getTargetMap();
for (BackendConnection bcon : bons.values()) {
if (bcon instanceof MySQLConnection) {
MySQLConnection mcon2 = (MySQLConnection) bcon;
if (mcon1 == mcon2) {
scon.killAndClose("reload config all");
return;
}
}
}
}
}
}
}
}
use of com.actiontech.dble.route.RouteResultsetNode in project dble by actiontech.
the class RouteResultCopy method rrnCopy.
public static RouteResultsetNode rrnCopy(RouteResultsetNode node, int sqlType, String stmt) {
RouteResultsetNode nn = new RouteResultsetNode(node.getName(), sqlType, stmt);
nn.setRunOnSlave(node.getRunOnSlave());
nn.setCanRunInReadDB(false);
nn.setLimitSize(0);
return nn;
}
use of com.actiontech.dble.route.RouteResultsetNode in project dble by actiontech.
the class RouteResultCopy method rrCopy.
public static RouteResultset rrCopy(RouteResultset rrs, int sqlType, String stmt) {
RouteResultset rr = new RouteResultset(stmt, sqlType);
rr.setRunOnSlave(rrs.getRunOnSlave());
rr.setFinishedRoute(rrs.isFinishedRoute());
rr.setGlobalTable(rrs.isGlobalTable());
rr.setCanRunInReadDB(false);
RouteResultsetNode[] ns = rrs.getNodes();
RouteResultsetNode[] nodes = new RouteResultsetNode[ns.length];
for (int i = 0; i < ns.length; i++) {
nodes[i] = rrnCopy(ns[i], sqlType, stmt);
}
rr.setNodes(nodes);
return rr;
}
use of com.actiontech.dble.route.RouteResultsetNode in project dble by actiontech.
the class RouterUtil method routeToDDLNode.
public static void routeToDDLNode(SchemaInfo schemaInfo, RouteResultset rrs) throws SQLException {
String stmt = getFixedSql(removeSchema(rrs.getStatement(), schemaInfo.getSchema()));
List<String> dataNodes;
Map<String, TableConfig> tables = schemaInfo.getSchemaConfig().getTables();
TableConfig tc = tables.get(schemaInfo.getTable());
if (tc != null) {
dataNodes = tc.getDataNodes();
} else {
String msg = "Table '" + schemaInfo.getSchema() + "." + schemaInfo.getTable() + "' doesn't exist";
throw new SQLException(msg, "42S02", ErrorCode.ER_NO_SUCH_TABLE);
}
Iterator<String> iterator1 = dataNodes.iterator();
int nodeSize = dataNodes.size();
RouteResultsetNode[] nodes = new RouteResultsetNode[nodeSize];
for (int i = 0; i < nodeSize; i++) {
String name = iterator1.next();
nodes[i] = new RouteResultsetNode(name, ServerParse.DDL, stmt);
}
rrs.setNodes(nodes);
rrs.setSchema(schemaInfo.getSchema());
rrs.setTable(schemaInfo.getTable());
rrs.setFinishedRoute(true);
}
Aggregations