use of com.alibaba.cobar.heartbeat.CobarDetector 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;
}
Aggregations