Search in sources :

Example 1 with NameableExecutor

use of com.alibaba.cobar.util.NameableExecutor 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 NameableExecutor

use of com.alibaba.cobar.util.NameableExecutor in project cobar by alibaba.

the class ShowThreadPool method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = header.write(buffer, c);
    // write fields
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    // write eof
    buffer = eof.write(buffer, c);
    // write rows
    byte packetId = eof.packetId;
    List<NameableExecutor> executors = getExecutors();
    for (NameableExecutor exec : executors) {
        if (exec != null) {
            RowDataPacket row = getRow(exec, c.getCharset());
            row.packetId = ++packetId;
            buffer = row.write(buffer, c);
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    // write buffer
    c.write(buffer);
}
Also used : NameableExecutor(com.alibaba.cobar.util.NameableExecutor) RowDataPacket(com.alibaba.cobar.net.mysql.RowDataPacket) EOFPacket(com.alibaba.cobar.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.alibaba.cobar.net.mysql.FieldPacket)

Aggregations

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