Search in sources :

Example 1 with CobarServer

use of com.alibaba.cobar.CobarServer in project cobar by alibaba.

the class ShowThreadPool method getExecutors.

private static List<NameableExecutor> getExecutors() {
    List<NameableExecutor> list = new LinkedList<NameableExecutor>();
    CobarServer server = CobarServer.getInstance();
    list.add(server.getInitExecutor());
    list.add(server.getTimerExecutor());
    list.add(server.getManagerExecutor());
    for (NIOProcessor p : server.getProcessors()) {
        list.add(p.getHandler());
        list.add(p.getExecutor());
        list.add(p.getCommitter());
    }
    return list;
}
Also used : NameableExecutor(com.alibaba.cobar.util.NameableExecutor) NIOProcessor(com.alibaba.cobar.net.NIOProcessor) LinkedList(java.util.LinkedList) CobarServer(com.alibaba.cobar.CobarServer)

Example 2 with CobarServer

use of com.alibaba.cobar.CobarServer in project cobar by alibaba.

the class ShowServer method getRow.

private static RowDataPacket getRow(String charset) {
    CobarServer server = CobarServer.getInstance();
    long startupTime = server.getStartupTime();
    long now = TimeUtil.currentTimeMillis();
    long uptime = now - startupTime;
    Runtime rt = Runtime.getRuntime();
    long total = rt.totalMemory();
    long max = rt.maxMemory();
    long used = (total - rt.freeMemory());
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(FormatUtil.formatTime(uptime, 3), charset));
    row.add(LongUtil.toBytes(used));
    row.add(LongUtil.toBytes(total));
    row.add(LongUtil.toBytes(max));
    row.add(LongUtil.toBytes(server.getConfig().getReloadTime()));
    row.add(LongUtil.toBytes(server.getConfig().getRollbackTime()));
    row.add(StringUtil.encode(charset, charset));
    row.add(StringUtil.encode(CobarServer.getInstance().isOnline() ? "ON" : "OFF", charset));
    return row;
}
Also used : RowDataPacket(com.alibaba.cobar.net.mysql.RowDataPacket) CobarServer(com.alibaba.cobar.CobarServer)

Aggregations

CobarServer (com.alibaba.cobar.CobarServer)2 NIOProcessor (com.alibaba.cobar.net.NIOProcessor)1 RowDataPacket (com.alibaba.cobar.net.mysql.RowDataPacket)1 NameableExecutor (com.alibaba.cobar.util.NameableExecutor)1 LinkedList (java.util.LinkedList)1