Search in sources :

Example 1 with NIOProcessor

use of com.actiontech.dble.net.NIOProcessor in project dble by actiontech.

the class ShowSession method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = HEADER.write(buffer, c, true);
    // write fields
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    // write eof
    buffer = EOF.write(buffer, c, true);
    // write rows
    byte packetId = EOF.getPacketId();
    for (NIOProcessor process : DbleServer.getInstance().getFrontProcessors()) {
        for (FrontendConnection front : process.getFrontends().values()) {
            if (!(front instanceof ServerConnection)) {
                continue;
            }
            ServerConnection sc = (ServerConnection) front;
            RowDataPacket row = getRow(sc, c.getCharset().getResults());
            if (row != null) {
                row.setPacketId(++packetId);
                buffer = row.write(buffer, c, true);
            }
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ServerConnection(com.actiontech.dble.server.ServerConnection) NIOProcessor(com.actiontech.dble.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 2 with NIOProcessor

use of com.actiontech.dble.net.NIOProcessor in project dble by actiontech.

the class ShowBinlogStatus method getNeedWaitSession.

private static List<NonBlockingSession> getNeedWaitSession() {
    List<NonBlockingSession> fcList = new ArrayList<>();
    for (NIOProcessor process : DbleServer.getInstance().getFrontProcessors()) {
        for (FrontendConnection front : process.getFrontends().values()) {
            if (!(front instanceof ServerConnection)) {
                continue;
            }
            ServerConnection sc = (ServerConnection) front;
            NonBlockingSession session = sc.getSession2();
            if (session.isNeedWaitFinished()) {
                fcList.add(session);
            }
        }
    }
    return fcList;
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) NonBlockingSession(com.actiontech.dble.server.NonBlockingSession) ServerConnection(com.actiontech.dble.server.ServerConnection) NIOProcessor(com.actiontech.dble.net.NIOProcessor)

Example 3 with NIOProcessor

use of com.actiontech.dble.net.NIOProcessor in project dble by actiontech.

the class ShowConnection method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = HEADER.write(buffer, c, true);
    // write fields
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    // write eof
    buffer = EOF.write(buffer, c, true);
    // write rows
    byte packetId = EOF.getPacketId();
    NIOProcessor[] processors = DbleServer.getInstance().getFrontProcessors();
    for (NIOProcessor p : processors) {
        for (FrontendConnection fc : p.getFrontends().values()) {
            if (fc != null) {
                RowDataPacket row = getRow(fc, c.getCharset().getResults());
                row.setPacketId(++packetId);
                buffer = row.write(buffer, c, true);
            }
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) NIOProcessor(com.actiontech.dble.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 4 with NIOProcessor

use of com.actiontech.dble.net.NIOProcessor in project dble by actiontech.

the class ShowConnectionCount method getRow.

private static RowDataPacket getRow() {
    int cons = 0;
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    NIOProcessor[] processors = DbleServer.getInstance().getFrontProcessors();
    for (NIOProcessor p : processors) {
        for (FrontendConnection fc : p.getFrontends().values()) {
            if (fc != null) {
                cons++;
            }
        }
    }
    row.add(IntegerUtil.toBytes(cons));
    return row;
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) NIOProcessor(com.actiontech.dble.net.NIOProcessor)

Example 5 with NIOProcessor

use of com.actiontech.dble.net.NIOProcessor in project dble by actiontech.

the class ShowConnectionSQL method execute.

public static void execute(ManagerConnection c) {
    ByteBuffer buffer = c.allocate();
    // write header
    buffer = HEADER.write(buffer, c, true);
    // write fields
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    // write eof
    buffer = EOF.write(buffer, c, true);
    // write rows
    byte packetId = EOF.getPacketId();
    for (NIOProcessor p : DbleServer.getInstance().getFrontProcessors()) {
        for (FrontendConnection fc : p.getFrontends().values()) {
            if (!fc.isClosed()) {
                RowDataPacket row = getRow(fc, c.getCharset().getResults());
                row.setPacketId(++packetId);
                buffer = row.write(buffer, c, true);
            }
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) NIOProcessor(com.actiontech.dble.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

NIOProcessor (com.actiontech.dble.net.NIOProcessor)16 FrontendConnection (com.actiontech.dble.net.FrontendConnection)8 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)8 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)6 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)6 ByteBuffer (java.nio.ByteBuffer)6 BackendConnection (com.actiontech.dble.backend.BackendConnection)4 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)4 ServerConnection (com.actiontech.dble.server.ServerConnection)3 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)1 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)1 RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)1 NonBlockingSession (com.actiontech.dble.server.NonBlockingSession)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1