Search in sources :

Example 56 with EOFPacket

use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.

the class ShowTables method writeRowEof.

private static void writeRowEof(ByteBuffer buffer, ServerConnection c, byte packetId) {
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : EOFPacket(com.actiontech.dble.net.mysql.EOFPacket)

Example 57 with EOFPacket

use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.

the class SelectVersion method response.

public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = HEADER.write(buffer, c, true);
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    buffer = EOF.write(buffer, c, true);
    byte packetId = EOF.getPacketId();
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(Versions.getServerVersion());
    row.setPacketId(++packetId);
    buffer = row.write(buffer, c, true);
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    c.write(buffer);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 58 with EOFPacket

use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.

the class SessionIsolation method response.

public static void response(ServerConnection c) {
    ByteBuffer buffer = c.allocate();
    buffer = HEADER.write(buffer, c, true);
    for (FieldPacket field : FIELDS) {
        buffer = field.write(buffer, c, true);
    }
    buffer = EOF.write(buffer, c, true);
    byte packetId = EOF.getPacketId();
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    String value = "";
    switch(c.getTxIsolation()) {
        case Isolations.READ_COMMITTED:
            value = "READ-COMMITTED";
            break;
        case Isolations.READ_UNCOMMITTED:
            value = "READ-UNCOMMITTED";
            break;
        case Isolations.REPEATABLE_READ:
            value = "REPEATABLE-READ";
            break;
        case Isolations.SERIALIZABLE:
            value = "SERIALIZABLE";
            break;
        default:
            break;
    }
    row.add(StringUtil.encode(value, c.getCharset().getResults()));
    row.setPacketId(++packetId);
    buffer = row.write(buffer, c, true);
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    c.write(buffer);
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 59 with EOFPacket

use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.

the class ShowDatabases method response.

public static void response(ServerConnection 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();
    ServerConfig conf = DbleServer.getInstance().getConfig();
    Map<String, UserConfig> users = conf.getUsers();
    UserConfig user = users == null ? null : users.get(c.getUser());
    if (user != null) {
        TreeSet<String> schemaSet = new TreeSet<>();
        Set<String> schemaList = user.getSchemas();
        if (schemaList == null || schemaList.size() == 0) {
            schemaSet.addAll(conf.getSchemas().keySet());
        } else {
            for (String schema : schemaList) {
                schemaSet.add(schema);
            }
        }
        for (String name : schemaSet) {
            RowDataPacket row = new RowDataPacket(FIELD_COUNT);
            row.add(StringUtil.encode(name, 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);
    // post write
    c.write(buffer);
}
Also used : ServerConfig(com.actiontech.dble.config.ServerConfig) TreeSet(java.util.TreeSet) RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) UserConfig(com.actiontech.dble.config.model.UserConfig) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Example 60 with EOFPacket

use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.

the class InformationSchemaProfiling method response.

/**
 * response method.
 *
 * @param c
 */
public static void response(ServerConnection c) {
    int i = 0;
    byte packetId = 0;
    HEADER.setPacketId(++packetId);
    FIELDS[i] = PacketUtil.getField("State", Fields.FIELD_TYPE_VAR_STRING);
    FIELDS[i].setPacketId(++packetId);
    FIELDS[i + 1] = PacketUtil.getField("Duration", Fields.FIELD_TYPE_DECIMAL);
    FIELDS[i + 1].setPacketId(++packetId);
    FIELDS[i + 2] = PacketUtil.getField("Percentage", Fields.FIELD_TYPE_DECIMAL);
    FIELDS[i + 2].setPacketId(++packetId);
    EOF.setPacketId(++packetId);
    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
    packetId = EOF.getPacketId();
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.setPacketId(++packetId);
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : EOFPacket(com.actiontech.dble.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket)

Aggregations

EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)67 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)66 ByteBuffer (java.nio.ByteBuffer)64 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)59 Map (java.util.Map)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)6 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)6 UserStat (com.actiontech.dble.statistic.stat.UserStat)6 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 ServerConfig (com.actiontech.dble.config.ServerConfig)3 FrontendConnection (com.actiontech.dble.net.FrontendConnection)3 BackendConnection (com.actiontech.dble.backend.BackendConnection)2 PhysicalDBNode (com.actiontech.dble.backend.datasource.PhysicalDBNode)2 TableConfig (com.actiontech.dble.config.model.TableConfig)2 UserConfig (com.actiontech.dble.config.model.UserConfig)2 PackageBufINf (com.actiontech.dble.manager.handler.PackageBufINf)2 PreparedOkPacket (com.actiontech.dble.net.mysql.PreparedOkPacket)2 TreeSet (java.util.TreeSet)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 Matcher (java.util.regex.Matcher)2