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");
}
}
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();
}
}
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;
}
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;
}
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;
}
Aggregations