Search in sources :

Example 61 with FieldPacket

use of io.mycat.net.mysql.FieldPacket in project Mycat-Server by MyCATApache.

the class ShowSysParam 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.packetId;
    SystemConfig sysConfig = MycatServer.getInstance().getConfig().getSystem();
    List<String> paramValues = new ArrayList<String>();
    paramValues.add(sysConfig.getProcessors() + "");
    paramValues.add(sysConfig.getBufferPoolChunkSize() + "B");
    paramValues.add(sysConfig.getBufferPoolPageSize() + "B");
    paramValues.add(sysConfig.getProcessorBufferLocalPercent() + "");
    paramValues.add(sysConfig.getProcessorExecutor() + "");
    paramValues.add(sysConfig.getSequnceHandlerType() == 1 ? "数据库方式" : "本地文件方式");
    paramValues.add(sysConfig.getPacketHeaderSize() + "B");
    paramValues.add(sysConfig.getMaxPacketSize() / 1024 / 1024 + "M");
    paramValues.add(sysConfig.getIdleTimeout() / 1000 / 60 + "分钟");
    paramValues.add(sysConfig.getCharset() + "");
    paramValues.add(ISOLATIONS[sysConfig.getTxIsolation()]);
    paramValues.add(sysConfig.getSqlExecuteTimeout() + "秒");
    paramValues.add(sysConfig.getProcessorCheckPeriod() / 1000 + "秒");
    paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() / 1000 + "秒");
    paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() / 1000 + "秒");
    paramValues.add(sysConfig.getBindIp() + "");
    paramValues.add(sysConfig.getServerPort() + "");
    paramValues.add(sysConfig.getManagerPort() + "");
    for (int i = 0; i < PARAMNAMES.length; i++) {
        RowDataPacket row = new RowDataPacket(FIELD_COUNT);
        row.add(StringUtil.encode(PARAMNAMES[i], c.getCharset()));
        row.add(StringUtil.encode(paramValues.get(i), c.getCharset()));
        row.add(StringUtil.encode(PARAM_DESCRIPTION[i], c.getCharset()));
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : SystemConfig(io.mycat.config.model.SystemConfig) RowDataPacket(io.mycat.net.mysql.RowDataPacket) ArrayList(java.util.ArrayList) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 62 with FieldPacket

use of io.mycat.net.mysql.FieldPacket in project Mycat-Server by MyCATApache.

the class ShowThreadPool 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.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, true);
        }
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : NameableExecutor(io.mycat.util.NameableExecutor) RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 63 with FieldPacket

use of io.mycat.net.mysql.FieldPacket in project Mycat-Server by MyCATApache.

the class ShowHelp 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.packetId;
    for (String key : keys) {
        RowDataPacket row = getRow(key, helps.get(key), c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // post write
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 64 with FieldPacket

use of io.mycat.net.mysql.FieldPacket in project Mycat-Server by MyCATApache.

the class ShowParser 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.packetId;
    for (int i = 0; i < 1; i++) {
        RowDataPacket row = getRow(c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Example 65 with FieldPacket

use of io.mycat.net.mysql.FieldPacket in project Mycat-Server by MyCATApache.

the class ShowProcessor 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.packetId;
    for (NIOProcessor p : MycatServer.getInstance().getProcessors()) {
        RowDataPacket row = getRow(p, c.getCharset());
        row.packetId = ++packetId;
        buffer = row.write(buffer, c, true);
    }
    // write last eof
    EOFPacket lastEof = new EOFPacket();
    lastEof.packetId = ++packetId;
    buffer = lastEof.write(buffer, c, true);
    // write buffer
    c.write(buffer);
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) EOFPacket(io.mycat.net.mysql.EOFPacket) NIOProcessor(io.mycat.net.NIOProcessor) ByteBuffer(java.nio.ByteBuffer) FieldPacket(io.mycat.net.mysql.FieldPacket)

Aggregations

FieldPacket (io.mycat.net.mysql.FieldPacket)84 ByteBuffer (java.nio.ByteBuffer)75 EOFPacket (io.mycat.net.mysql.EOFPacket)74 RowDataPacket (io.mycat.net.mysql.RowDataPacket)69 ResultSetHeaderPacket (io.mycat.net.mysql.ResultSetHeaderPacket)9 NIOProcessor (io.mycat.net.NIOProcessor)7 UserStat (io.mycat.statistic.stat.UserStat)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 SchemaConfig (io.mycat.config.model.SchemaConfig)4 MycatConfig (io.mycat.config.MycatConfig)3 FrontendConnection (io.mycat.net.FrontendConnection)3 BackendConnection (io.mycat.backend.BackendConnection)2 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)2 UserConfig (io.mycat.config.model.UserConfig)2 ServerConnection (io.mycat.server.ServerConnection)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 HashMap (java.util.HashMap)2 List (java.util.List)2 TreeSet (java.util.TreeSet)2