Search in sources :

Example 11 with MySQLConnection

use of io.mycat.backend.mysql.nio.MySQLConnection in project Mycat-Server by MyCATApache.

the class ShowBackend method getRow.

private static RowDataPacket getRow(BackendConnection c, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    if (c instanceof BackendAIOConnection) {
        row.add(((BackendAIOConnection) c).getProcessor().getName().getBytes());
    } else if (c instanceof JDBCConnection) {
        row.add(((JDBCConnection) c).getProcessor().getName().getBytes());
    } else {
        row.add("N/A".getBytes());
    }
    row.add(LongUtil.toBytes(c.getId()));
    long threadId = 0;
    if (c instanceof MySQLConnection) {
        threadId = ((MySQLConnection) c).getThreadId();
    }
    row.add(LongUtil.toBytes(threadId));
    row.add(StringUtil.encode(c.getHost(), charset));
    row.add(IntegerUtil.toBytes(c.getPort()));
    row.add(IntegerUtil.toBytes(c.getLocalPort()));
    row.add(LongUtil.toBytes(c.getNetInBytes()));
    row.add(LongUtil.toBytes(c.getNetOutBytes()));
    row.add(LongUtil.toBytes((TimeUtil.currentTimeMillis() - c.getStartupTime()) / 1000L));
    row.add(c.isClosed() ? "true".getBytes() : "false".getBytes());
    // boolean isRunning = c.isRunning();
    // row.add(isRunning ? "true".getBytes() : "false".getBytes());
    boolean isBorrowed = c.isBorrowed();
    row.add(isBorrowed ? "true".getBytes() : "false".getBytes());
    int writeQueueSize = 0;
    String schema = "";
    String charsetInf = "";
    String txLevel = "";
    String txAutommit = "";
    if (c instanceof MySQLConnection) {
        MySQLConnection mysqlC = (MySQLConnection) c;
        writeQueueSize = mysqlC.getWriteQueue().size();
        schema = mysqlC.getSchema();
        charsetInf = mysqlC.getCharset() + ":" + mysqlC.getCharsetIndex();
        txLevel = mysqlC.getTxIsolation() + "";
        txAutommit = mysqlC.isAutocommit() + "";
    }
    row.add(IntegerUtil.toBytes(writeQueueSize));
    row.add(schema.getBytes());
    row.add(charsetInf.getBytes());
    row.add(txLevel.getBytes());
    row.add(txAutommit.getBytes());
    return row;
}
Also used : RowDataPacket(io.mycat.net.mysql.RowDataPacket) BackendAIOConnection(io.mycat.net.BackendAIOConnection) JDBCConnection(io.mycat.backend.jdbc.JDBCConnection) MySQLConnection(io.mycat.backend.mysql.nio.MySQLConnection)

Aggregations

MySQLConnection (io.mycat.backend.mysql.nio.MySQLConnection)11 BackendConnection (io.mycat.backend.BackendConnection)3 JDBCConnection (io.mycat.backend.jdbc.JDBCConnection)3 CoordinatorLogEntry (io.mycat.backend.mysql.xa.CoordinatorLogEntry)2 NIOProcessor (io.mycat.net.NIOProcessor)2 RowDataPacket (io.mycat.net.mysql.RowDataPacket)2 RouteResultsetNode (io.mycat.route.RouteResultsetNode)2 PhysicalDBNode (io.mycat.backend.datasource.PhysicalDBNode)1 PhysicalDBPool (io.mycat.backend.datasource.PhysicalDBPool)1 PhysicalDatasource (io.mycat.backend.datasource.PhysicalDatasource)1 ParticipantLogEntry (io.mycat.backend.mysql.xa.ParticipantLogEntry)1 ConfigInitializer (io.mycat.config.ConfigInitializer)1 MycatCluster (io.mycat.config.MycatCluster)1 MycatConfig (io.mycat.config.MycatConfig)1 FirewallConfig (io.mycat.config.model.FirewallConfig)1 SchemaConfig (io.mycat.config.model.SchemaConfig)1 UserConfig (io.mycat.config.model.UserConfig)1 BackendAIOConnection (io.mycat.net.BackendAIOConnection)1 CommandPacket (io.mycat.net.mysql.CommandPacket)1 ServerConnection (io.mycat.server.ServerConnection)1