use of io.mycat.config.MycatNode in project Mycat-Server by MyCATApache.
the class ShowMyCATCluster method getRows.
private static List<RowDataPacket> getRows(ServerConnection c) {
List<RowDataPacket> rows = new LinkedList<RowDataPacket>();
MycatConfig config = MycatServer.getInstance().getConfig();
MycatCluster cluster = config.getCluster();
Map<String, SchemaConfig> schemas = config.getSchemas();
SchemaConfig schema = (c.getSchema() == null) ? null : schemas.get(c.getSchema());
// 如果没有指定schema或者schema为null,则使用全部集群。
if (schema == null) {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
} else {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
}
if (rows.size() == 0) {
alarm.error(Alarms.CLUSTER_EMPTY + c.toString());
}
return rows;
}
use of io.mycat.config.MycatNode in project Mycat-Server by MyCATApache.
the class ShowCobarCluster method getRows.
private static List<RowDataPacket> getRows(ServerConnection c) {
List<RowDataPacket> rows = new LinkedList<RowDataPacket>();
MycatConfig config = MycatServer.getInstance().getConfig();
MycatCluster cluster = config.getCluster();
Map<String, SchemaConfig> schemas = config.getSchemas();
SchemaConfig schema = (c.getSchema() == null) ? null : schemas.get(c.getSchema());
// 如果没有指定schema或者schema为null,则使用全部集群。
if (schema == null) {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
} else {
Map<String, MycatNode> nodes = cluster.getNodes();
for (MycatNode n : nodes.values()) {
if (n != null && n.isOnline()) {
rows.add(getRow(n, c.getCharset()));
}
}
}
if (rows.size() == 0) {
alarm.error(Alarms.CLUSTER_EMPTY + c.toString());
}
return rows;
}
Aggregations