Search in sources :

Example 26 with RouteResultsetNode

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();
        }
    }
}
Also used : BackendConnection(com.actiontech.dble.backend.BackendConnection) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) MySQLConnection(com.actiontech.dble.backend.mysql.nio.MySQLConnection)

Example 27 with RouteResultsetNode

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;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) BackendConnection(com.actiontech.dble.backend.BackendConnection) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) ServerConnection(com.actiontech.dble.server.ServerConnection) NIOProcessor(com.actiontech.dble.net.NIOProcessor) MySQLConnection(com.actiontech.dble.backend.mysql.nio.MySQLConnection)

Example 28 with RouteResultsetNode

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;
}
Also used : RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode)

Example 29 with RouteResultsetNode

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;
}
Also used : RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) RouteResultset(com.actiontech.dble.route.RouteResultset)

Example 30 with RouteResultsetNode

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);
}
Also used : SQLException(java.sql.SQLException) RouteResultsetNode(com.actiontech.dble.route.RouteResultsetNode) TableConfig(com.actiontech.dble.config.model.TableConfig)

Aggregations

RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)48 BackendConnection (com.actiontech.dble.backend.BackendConnection)12 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)9 RouteResultset (com.actiontech.dble.route.RouteResultset)8 TableConfig (com.actiontech.dble.config.model.TableConfig)6 SQLNonTransientException (java.sql.SQLNonTransientException)6 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)5 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)5 PushDownVisitor (com.actiontech.dble.backend.mysql.nio.handler.builder.sqlvisitor.PushDownVisitor)4 AbstractPartitionAlgorithm (com.actiontech.dble.route.function.AbstractPartitionAlgorithm)4 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)4 ServerConfig (com.actiontech.dble.config.ServerConfig)3 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)3 RouteCalculateUnit (com.actiontech.dble.route.parser.druid.RouteCalculateUnit)3 LoadData (com.actiontech.dble.sqlengine.mpp.LoadData)3 LayerCachePool (com.actiontech.dble.cache.LayerCachePool)2 DruidShardingParseInfo (com.actiontech.dble.route.parser.druid.DruidShardingParseInfo)2 SQLException (java.sql.SQLException)2 SQLSyntaxErrorException (java.sql.SQLSyntaxErrorException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2