Search in sources :

Example 16 with PhysicalDBPool

use of com.actiontech.dble.backend.datasource.PhysicalDBPool in project dble by actiontech.

the class DbleServer method reloadDnIndex.

public void reloadDnIndex() {
    if (DbleServer.getInstance().getFrontProcessors() == null)
        return;
    // load datanode active index from properties
    dnIndexProperties = DnPropertyUtil.loadDnIndexProps();
    // init datahost
    Map<String, PhysicalDBPool> dataHosts = this.getConfig().getDataHosts();
    LOGGER.info("reInitialize dataHost ...");
    for (PhysicalDBPool node : dataHosts.values()) {
        String index = dnIndexProperties.getProperty(node.getHostName(), "0");
        if (!"0".equals(index)) {
            LOGGER.info("reinit datahost: " + node.getHostName() + "  to use datasource index:" + index);
        }
        node.switchSource(Integer.parseInt(index), true, "reload dnindex");
    }
}
Also used : PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool)

Example 17 with PhysicalDBPool

use of com.actiontech.dble.backend.datasource.PhysicalDBPool in project dble by actiontech.

the class DbleServer method initDataHost.

private void initDataHost() {
    // init datahost
    Map<String, PhysicalDBPool> dataHosts = this.getConfig().getDataHosts();
    LOGGER.info("Initialize dataHost ...");
    for (PhysicalDBPool node : dataHosts.values()) {
        String index = dnIndexProperties.getProperty(node.getHostName(), "0");
        if (!"0".equals(index)) {
            LOGGER.info("init datahost: " + node.getHostName() + "  to use datasource index:" + index);
        }
        node.init(Integer.parseInt(index));
        node.startHeartbeat();
    }
}
Also used : PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool)

Example 18 with PhysicalDBPool

use of com.actiontech.dble.backend.datasource.PhysicalDBPool in project dble by actiontech.

the class ProxyMetaManager method getSelfNodes.

private Set<String> getSelfNodes(ServerConfig config) {
    Set<String> selfNode = null;
    for (Map.Entry<String, PhysicalDBPool> entry : config.getDataHosts().entrySet()) {
        PhysicalDBPool host = entry.getValue();
        DBHostConfig wHost = host.getSource().getConfig();
        if (("localhost".equalsIgnoreCase(wHost.getIp()) || "127.0.0.1".equalsIgnoreCase(wHost.getIp())) && wHost.getPort() == config.getSystem().getServerPort()) {
            for (Map.Entry<String, PhysicalDBNode> nodeEntry : config.getDataNodes().entrySet()) {
                if (nodeEntry.getValue().getDbPool().getHostName().equals(host.getHostName())) {
                    if (selfNode == null) {
                        selfNode = new HashSet<>(2);
                    }
                    selfNode.add(nodeEntry.getKey());
                }
            }
            break;
        }
    }
    return selfNode;
}
Also used : DBHostConfig(com.actiontech.dble.config.model.DBHostConfig) PhysicalDBNode(com.actiontech.dble.backend.datasource.PhysicalDBNode) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool)

Example 19 with PhysicalDBPool

use of com.actiontech.dble.backend.datasource.PhysicalDBPool in project dble by actiontech.

the class ConfigTest method getPhysicalDBPool.

private PhysicalDBPool getPhysicalDBPool(DataHostConfig conf) {
    String name = conf.getName();
    PhysicalDatasource[] writeSources = createDataSource(conf, name, conf.getWriteHosts(), false);
    Map<Integer, DBHostConfig[]> readHostsMap = conf.getReadHosts();
    Map<Integer, PhysicalDatasource[]> readSourcesMap = new HashMap<Integer, PhysicalDatasource[]>(readHostsMap.size());
    for (Map.Entry<Integer, DBHostConfig[]> entry : readHostsMap.entrySet()) {
        PhysicalDatasource[] readSources = createDataSource(conf, name, entry.getValue(), true);
        readSourcesMap.put(entry.getKey(), readSources);
    }
    PhysicalDBPool pool = new PhysicalDBPool(conf.getName(), conf, writeSources, readSourcesMap, conf.getBalance());
    return pool;
}
Also used : PhysicalDatasource(com.actiontech.dble.backend.datasource.PhysicalDatasource) HashMap(java.util.HashMap) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool) HashMap(java.util.HashMap) Map(java.util.Map)

Example 20 with PhysicalDBPool

use of com.actiontech.dble.backend.datasource.PhysicalDBPool in project dble by actiontech.

the class ConfigTest method initDataHosts.

private Map<String, PhysicalDBPool> initDataHosts(SchemaLoader schemaLoader) {
    Map<String, DataHostConfig> nodeConfs = schemaLoader.getDataHosts();
    Map<String, PhysicalDBPool> nodes = new HashMap<String, PhysicalDBPool>(nodeConfs.size());
    for (DataHostConfig conf : nodeConfs.values()) {
        PhysicalDBPool pool = getPhysicalDBPool(conf);
        nodes.put(pool.getHostName(), pool);
    }
    return nodes;
}
Also used : HashMap(java.util.HashMap) PhysicalDBPool(com.actiontech.dble.backend.datasource.PhysicalDBPool)

Aggregations

PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)31 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)16 ServerConfig (com.actiontech.dble.config.ServerConfig)9 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)8 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)7 DBHeartbeat (com.actiontech.dble.backend.heartbeat.DBHeartbeat)5 Map (java.util.Map)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 ERTable (com.actiontech.dble.config.model.ERTable)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 DataSourceSyncRecorder (com.actiontech.dble.statistic.DataSourceSyncRecorder)3 Set (java.util.Set)3 ConfigInitializer (com.actiontech.dble.config.ConfigInitializer)2 ConfigException (com.actiontech.dble.config.util.ConfigException)2 OkPacket (com.actiontech.dble.net.mysql.OkPacket)2 OneRawSQLQueryResultHandler (com.actiontech.dble.sqlengine.OneRawSQLQueryResultHandler)2