use of com.actiontech.dble.config.model.DBHostConfig 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.config.model.DBHostConfig in project dble by actiontech.
the class ShowTableDataNode method getRows.
private static List<RowDataPacket> getRows(List<String> dataNodes, String charset) {
List<RowDataPacket> list = new ArrayList<>();
int sequence = 0;
for (String dataNode : dataNodes) {
PhysicalDBNode dn = DbleServer.getInstance().getConfig().getDataNodes().get(dataNode);
DBHostConfig dbConfig = dn.getDbPool().getSource().getConfig();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(dn.getName(), charset));
row.add(LongUtil.toBytes(sequence));
row.add(StringUtil.encode(dbConfig.getIp(), charset));
row.add(LongUtil.toBytes(dbConfig.getPort()));
row.add(StringUtil.encode(dn.getDatabase(), charset));
row.add(StringUtil.encode(dbConfig.getUser(), charset));
row.add(StringUtil.encode(dbConfig.getPassword(), charset));
list.add(row);
sequence++;
}
return list;
}
use of com.actiontech.dble.config.model.DBHostConfig in project dble by actiontech.
the class MySQLConnectionFactory method make.
@SuppressWarnings({ "unchecked", "rawtypes" })
public MySQLConnection make(MySQLDataSource pool, ResponseHandler handler, String schema) throws IOException {
DBHostConfig dsc = pool.getConfig();
NetworkChannel channel = openSocketChannel(DbleServer.getInstance().isAIO());
MySQLConnection c = new MySQLConnection(channel, pool.isReadNode());
c.setSocketParams(false);
c.setHost(dsc.getIp());
c.setPort(dsc.getPort());
c.setUser(dsc.getUser());
c.setPassword(dsc.getPassword());
c.setSchema(schema);
c.setHandler(new MySQLConnectionAuthenticator(c, handler));
c.setPool(pool);
c.setIdleTimeout(pool.getConfig().getIdleTimeout());
if (channel instanceof AsynchronousSocketChannel) {
((AsynchronousSocketChannel) channel).connect(new InetSocketAddress(dsc.getIp(), dsc.getPort()), c, (CompletionHandler) DbleServer.getInstance().getConnector());
} else {
((NIOConnector) DbleServer.getInstance().getConnector()).postConnect(c);
}
return c;
}
Aggregations