Search in sources :

Example 6 with ERTable

use of com.actiontech.dble.config.model.ERTable in project dble by actiontech.

the class ERJoinChooser method leftJoinOptimizer.

/* ------------------- left join optimizer start -------------------- */
/**
 * left join's ER is different from inner join's
 * ex:t1,t2 ,if t1 left join t2 on
 * t1.id=t2.id can be pushed
 * < we cna't change left join's structure>
 *
 * @return
 */
private JoinNode leftJoinOptimizer() {
    PlanNode left = jn.getLeftNode();
    PlanNode right = jn.getRightNode();
    if (left.type() == PlanNode.PlanNodeType.JOIN) {
        left = JoinERProcessor.optimize(left);
        jn.setLeftNode(left);
    }
    if (right.type() == PlanNode.PlanNodeType.JOIN) {
        right = JoinERProcessor.optimize(right);
        jn.setRightNode(right);
    }
    for (ItemFuncEqual filter : jn.getJoinFilter()) {
        ERTable leftER = getLeftOutJoinChildER(jn, left, filter.arguments().get(0));
        ERTable rightER = getLeftOutJoinChildER(jn, right, filter.arguments().get(1));
        if (isErRelation(leftER, rightER)) {
            jn.getERkeys().add(leftER);
        }
    }
    return jn;
}
Also used : PlanNode(com.actiontech.dble.plan.node.PlanNode) ItemFuncEqual(com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual) ERTable(com.actiontech.dble.config.model.ERTable)

Example 7 with ERTable

use of com.actiontech.dble.config.model.ERTable in project dble by actiontech.

the class RollbackConfig method rollback.

public static void rollback() throws Exception {
    ServerConfig conf = DbleServer.getInstance().getConfig();
    Map<String, PhysicalDBPool> dataHosts = conf.getBackupDataHosts();
    Map<String, UserConfig> users = conf.getBackupUsers();
    Map<String, SchemaConfig> schemas = conf.getBackupSchemas();
    Map<String, PhysicalDBNode> dataNodes = conf.getBackupDataNodes();
    FirewallConfig firewall = conf.getBackupFirewall();
    Map<ERTable, Set<ERTable>> erRelations = conf.getBackupErRelations();
    boolean backDataHostWithoutWR = conf.backDataHostWithoutWR();
    if (conf.canRollback()) {
        conf.rollback(users, schemas, dataNodes, dataHosts, erRelations, firewall, backDataHostWithoutWR);
    } else if (conf.canRollbackAll()) {
        boolean rollbackStatus = true;
        String errorMsg = null;
        for (PhysicalDBPool dn : dataHosts.values()) {
            dn.init(dn.getActiveIndex());
            if (!dn.isInitSuccess()) {
                rollbackStatus = false;
                errorMsg = "dataHost[" + dn.getHostName() + "] inited failure";
                break;
            }
        }
        // INIT FAILED
        if (!rollbackStatus) {
            for (PhysicalDBPool dn : dataHosts.values()) {
                dn.clearDataSources("rollbackup config");
                dn.stopHeartbeat();
            }
            throw new Exception(errorMsg);
        }
        final Map<String, PhysicalDBPool> cNodes = conf.getDataHosts();
        // apply
        conf.rollback(users, schemas, dataNodes, dataHosts, erRelations, firewall, backDataHostWithoutWR);
        // stop old resource heartbeat
        for (PhysicalDBPool dn : cNodes.values()) {
            dn.clearDataSources("clear old config ");
            dn.stopHeartbeat();
        }
        AlarmAppender.rollbackConfig();
    } else {
        throw new Exception("there is no old version");
    }
}
Also used : PhysicalDBNode(com.actiontech.dble.backend.datasource.PhysicalDBNode) SchemaConfig(com.actiontech.dble.config.model.SchemaConfig) Set(java.util.Set) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool) ERTable(com.actiontech.dble.config.model.ERTable) UserConfig(com.actiontech.dble.config.model.UserConfig) FirewallConfig(com.actiontech.dble.config.model.FirewallConfig) ServerConfig(com.actiontech.dble.config.ServerConfig) Map(java.util.Map)

Aggregations

ERTable (com.actiontech.dble.config.model.ERTable)7 Set (java.util.Set)4 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)3 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)3 FirewallConfig (com.actiontech.dble.config.model.FirewallConfig)3 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)3 UserConfig (com.actiontech.dble.config.model.UserConfig)3 ConfigInitializer (com.actiontech.dble.config.ConfigInitializer)2 ServerConfig (com.actiontech.dble.config.ServerConfig)2 ItemField (com.actiontech.dble.plan.common.item.ItemField)2 JoinNode (com.actiontech.dble.plan.node.JoinNode)2 TableNode (com.actiontech.dble.plan.node.TableNode)2 ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)1 PlanNode (com.actiontech.dble.plan.node.PlanNode)1 SystemVariables (com.actiontech.dble.server.variables.SystemVariables)1 VarsExtractorHandler (com.actiontech.dble.server.variables.VarsExtractorHandler)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1