Search in sources :

Example 1 with MycatNode

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;
}
Also used : SchemaConfig(io.mycat.config.model.SchemaConfig) MycatNode(io.mycat.config.MycatNode) RowDataPacket(io.mycat.net.mysql.RowDataPacket) MycatCluster(io.mycat.config.MycatCluster) MycatConfig(io.mycat.config.MycatConfig) LinkedList(java.util.LinkedList)

Example 2 with MycatNode

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;
}
Also used : SchemaConfig(io.mycat.config.model.SchemaConfig) MycatNode(io.mycat.config.MycatNode) RowDataPacket(io.mycat.net.mysql.RowDataPacket) MycatCluster(io.mycat.config.MycatCluster) MycatConfig(io.mycat.config.MycatConfig) LinkedList(java.util.LinkedList)

Aggregations

MycatCluster (io.mycat.config.MycatCluster)2 MycatConfig (io.mycat.config.MycatConfig)2 MycatNode (io.mycat.config.MycatNode)2 SchemaConfig (io.mycat.config.model.SchemaConfig)2 RowDataPacket (io.mycat.net.mysql.RowDataPacket)2 LinkedList (java.util.LinkedList)2