Search in sources :

Example 61 with RowDataPacket

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

the class ShowTime method execute.

public static void execute(ManagerConnection c, int type) {
    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();
    RowDataPacket row = getRow(type, 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 : 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 62 with RowDataPacket

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

the class ShowWhiteHost method getRow.

private static RowDataPacket getRow(String ip, String user, String charset) {
    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
    row.add(StringUtil.encode(ip, charset));
    row.add(StringUtil.encode(user, charset));
    return row;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Example 63 with RowDataPacket

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

the class ShowWhiteHost 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();
    Map<String, List<UserConfig>> map = DbleServer.getInstance().getConfig().getFirewall().getWhitehost();
    for (Map.Entry<String, List<UserConfig>> entry : map.entrySet()) {
        List<UserConfig> userConfigs = entry.getValue();
        StringBuilder users = new StringBuilder();
        for (int i = 0; i < userConfigs.size(); i++) {
            if (i > 0) {
                users.append(",");
            }
            users.append(userConfigs.get(i).getName());
        }
        RowDataPacket row = getRow(entry.getKey(), users.toString(), 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 : 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) List(java.util.List) FieldPacket(com.actiontech.dble.net.mysql.FieldPacket) Map(java.util.Map)

Example 64 with RowDataPacket

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

the class ConfFileHandler method listConfigFiles.

private static PackageBufINf listConfigFiles(ManagerConnection c, ByteBuffer buffer, byte packetId) {
    PackageBufINf bufINf = new PackageBufINf();
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    try {
        int i = 1;
        File[] file = new File(SystemConfig.getHomePath(), "conf").listFiles();
        if (file != null) {
            for (File f : file) {
                if (f.isFile()) {
                    RowDataPacket row = new RowDataPacket(FIELD_COUNT);
                    row.add(StringUtil.encode((i++) + " : " + f.getName() + "  time:" + df.format(new Date(f.lastModified())), c.getCharset().getResults()));
                    row.setPacketId(++packetId);
                    buffer = row.write(buffer, c, true);
                }
            }
        }
        bufINf.setBuffer(buffer);
        bufINf.setPacketId(packetId);
        return bufINf;
    } catch (Exception e) {
        LOGGER.info("listConfigFilesError", e);
        RowDataPacket row = new RowDataPacket(FIELD_COUNT);
        row.add(StringUtil.encode(e.toString(), c.getCharset().getResults()));
        row.setPacketId(++packetId);
        buffer = row.write(buffer, c, true);
        bufINf.setBuffer(buffer);
    }
    bufINf.setPacketId(packetId);
    return bufINf;
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException)

Example 65 with RowDataPacket

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

the class AggregatorDistinct method endup.

@Override
public void endup() {
    if (endupDone)
        return;
    itemSum.clear();
    if (distinctRows != null) {
        distinctRows.done();
        if (!endupDone) {
            useDistinctValues = true;
            RowDataPacket row = null;
            while ((row = distinctRows.next()) != null) {
                // @bug1072 see argIsNull()
                FieldUtil.initFields(itemSum.sourceFields, row.fieldValues);
                field.setPtr(itemSum.getArg(0).getRowPacketByte());
                if (itemSum.isPushDown)
                    itemSum.pushDownAdd(row);
                else
                    itemSum.add(row, null);
            }
            useDistinctValues = false;
        }
        endupDone = true;
    }
}
Also used : RowDataPacket(com.actiontech.dble.net.mysql.RowDataPacket)

Aggregations

RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)141 EOFPacket (com.actiontech.dble.net.mysql.EOFPacket)59 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)59 ByteBuffer (java.nio.ByteBuffer)59 ServerConfig (com.actiontech.dble.config.ServerConfig)8 NIOProcessor (com.actiontech.dble.net.NIOProcessor)8 Map (java.util.Map)8 PhysicalDBPool (com.actiontech.dble.backend.datasource.PhysicalDBPool)7 PhysicalDatasource (com.actiontech.dble.backend.datasource.PhysicalDatasource)7 MySQLConnection (com.actiontech.dble.backend.mysql.nio.MySQLConnection)7 LocalResult (com.actiontech.dble.backend.mysql.store.LocalResult)6 UnSortedLocalResult (com.actiontech.dble.backend.mysql.store.UnSortedLocalResult)6 DBHeartbeat (com.actiontech.dble.backend.heartbeat.DBHeartbeat)5 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)5 UserStat (com.actiontech.dble.statistic.stat.UserStat)5 BackendConnection (com.actiontech.dble.backend.BackendConnection)4 SchemaConfig (com.actiontech.dble.config.model.SchemaConfig)4 FrontendConnection (com.actiontech.dble.net.FrontendConnection)4 ResultSetHeaderPacket (com.actiontech.dble.net.mysql.ResultSetHeaderPacket)4 LinkedList (java.util.LinkedList)4