Search in sources :

Example 1 with MySQLDetector

use of com.alibaba.cobar.heartbeat.MySQLDetector in project cobar by alibaba.

the class ShowBackend method getRow.

private static RowDataPacket getRow(BackendConnection c, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(c.getProcessor().getName().getBytes());
    row.add(LongUtil.toBytes(c.getId()));
    row.add(StringUtil.encode(c.getHost(), charset));
    row.add(IntegerUtil.toBytes(c.getPort()));
    row.add(IntegerUtil.toBytes(c.getLocalPort()));
    row.add(LongUtil.toBytes(c.getNetInBytes()));
    row.add(LongUtil.toBytes(c.getNetOutBytes()));
    row.add(LongUtil.toBytes((TimeUtil.currentTimeMillis() - c.getStartupTime()) / 1000L));
    row.add(c.isClosed() ? "true".getBytes() : "false".getBytes());
    if (c instanceof CobarDetector) {
        CobarDetector detector = (CobarDetector) c;
        CobarHeartbeat heartbeat = detector.getHeartbeat();
        row.add(detector.isAuthenticated() ? "true".getBytes() : "false".getBytes());
        row.add(detector.isQuit() ? "true".getBytes() : "false".getBytes());
        row.add(heartbeat.isChecking() ? "true".getBytes() : "false".getBytes());
        row.add(heartbeat.isStop() ? "true".getBytes() : "false".getBytes());
        row.add(LongUtil.toBytes(heartbeat.getStatus()));
    } else if (c instanceof MySQLDetector) {
        MySQLDetector detector = (MySQLDetector) c;
        MySQLHeartbeat heartbeat = detector.getHeartbeat();
        row.add(detector.isAuthenticated() ? "true".getBytes() : "false".getBytes());
        row.add(detector.isQuit() ? "true".getBytes() : "false".getBytes());
        row.add(heartbeat.isChecking() ? "true".getBytes() : "false".getBytes());
        row.add(heartbeat.isStop() ? "true".getBytes() : "false".getBytes());
        row.add(LongUtil.toBytes(heartbeat.getStatus()));
    } else {
        row.add(null);
        row.add(null);
        row.add(null);
        row.add(null);
        row.add(null);
    }
    return row;
}
Also used : CobarHeartbeat(com.alibaba.cobar.heartbeat.CobarHeartbeat) MySQLDetector(com.alibaba.cobar.heartbeat.MySQLDetector) RowDataPacket(com.alibaba.cobar.net.mysql.RowDataPacket) MySQLHeartbeat(com.alibaba.cobar.heartbeat.MySQLHeartbeat) CobarDetector(com.alibaba.cobar.heartbeat.CobarDetector)

Aggregations

CobarDetector (com.alibaba.cobar.heartbeat.CobarDetector)1 CobarHeartbeat (com.alibaba.cobar.heartbeat.CobarHeartbeat)1 MySQLDetector (com.alibaba.cobar.heartbeat.MySQLDetector)1 MySQLHeartbeat (com.alibaba.cobar.heartbeat.MySQLHeartbeat)1 RowDataPacket (com.alibaba.cobar.net.mysql.RowDataPacket)1