Search in sources :

Example 1 with FrontendConnection

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

the class KillConnection method response.

public static void response(String stmt, int offset, ManagerConnection mc) {
    int count = 0;
    List<FrontendConnection> list = getList(stmt, offset, mc);
    if (list != null) {
        for (FrontendConnection c : list) {
            StringBuilder s = new StringBuilder();
            LOGGER.info(s.append(c).append("killed by manager").toString());
            c.killAndClose("kill by manager");
            count++;
        }
    }
    OkPacket packet = new OkPacket();
    packet.setPacketId(1);
    packet.setAffectedRows(count);
    packet.setServerStatus(2);
    packet.write(mc);
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) OkPacket(com.actiontech.dble.net.mysql.OkPacket)

Example 2 with FrontendConnection

use of com.actiontech.dble.net.FrontendConnection 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 3 with FrontendConnection

use of com.actiontech.dble.net.FrontendConnection 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 4 with FrontendConnection

use of com.actiontech.dble.net.FrontendConnection 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 5 with FrontendConnection

use of com.actiontech.dble.net.FrontendConnection 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)

Aggregations

FrontendConnection (com.actiontech.dble.net.FrontendConnection)10 NIOProcessor (com.actiontech.dble.net.NIOProcessor)8 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)4 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)3 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)3 ServerConnection (com.actiontech.dble.server.ServerConnection)3 ByteBuffer (java.nio.ByteBuffer)3 BackendConnection (com.actiontech.dble.backend.BackendConnection)1 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)1 OkPacket (com.actiontech.dble.net.mysql.OkPacket)1 RouteResultsetNode (com.actiontech.dble.route.RouteResultsetNode)1 NonBlockingSession (com.actiontech.dble.server.NonBlockingSession)1 ArrayList (java.util.ArrayList)1