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);
}
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;
}
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);
}
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;
}
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;
}
}
Aggregations