Search in sources :

Example 1 with BackendConnection

use of com.alibaba.cobar.net.BackendConnection in project cobar by alibaba.

the class ShowBackend method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = header.write(buffer, c);
    for (FieldPacket field : fields) {
        buffer = field.write(buffer, c);
    }
    buffer = eof.write(buffer, c);
    byte packetId = eof.packetId;
    String charset = c.getCharset();
    for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
        for (BackendConnection bc : p.getBackends().values()) {
            if (bc != null) {
                RowDataPacket row = getRow(bc, charset);
                row.packetId = ++packetId;
                buffer = row.write(buffer, c);
            }
        }
    }
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c);
    c.write(buffer);
}
Also used : BackendConnection(com.alibaba.cobar.net.BackendConnection) RowDataPacket(com.alibaba.cobar.net.mysql.RowDataPacket) EOFPacket(com.alibaba.cobar.net.mysql.EOFPacket) NIOProcessor(com.alibaba.cobar.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.alibaba.cobar.net.mysql.FieldPacket)

Aggregations

BackendConnection (com.alibaba.cobar.net.BackendConnection)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