use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.
the class ShowCommand 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();
for (NIOProcessor p : DbleServer.getInstance().getFrontProcessors()) {
RowDataPacket row = getRow(p);
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.EOFPacket in project dble by actiontech.
the class ShowConnectionCount 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();
RowDataPacket row = getRow();
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.EOFPacket in project dble by actiontech.
the class ShowCostTimeStat method execute.
public static void execute(ManagerConnection 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();
QueryTimeCost[] recorders = QueryTimeCostContainer.getInstance().getRecorders();
int realPos = QueryTimeCostContainer.getInstance().getRealPos();
int start = 0;
int end = realPos;
if (realPos != recorders.length - 1 && recorders[realPos + 1] != null) {
start = realPos + 1;
end = realPos + recorders.length;
}
for (int i = start; i <= end; i++) {
RowDataPacket row = getRow(recorders[i % recorders.length], 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);
}
use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.
the class ShowDataSource method execute.
public static void execute(ManagerConnection c, String name) {
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();
if (null != name) {
PhysicalDBNode dn = conf.getDataNodes().get(name);
for (PhysicalDatasource w : dn.getDbPool().getAllDataSources()) {
RowDataPacket row = getRow(w, c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
}
} else {
// add all
for (Map.Entry<String, PhysicalDBPool> entry : conf.getDataHosts().entrySet()) {
PhysicalDBPool dataHost = entry.getValue();
for (int i = 0; i < dataHost.getSources().length; i++) {
RowDataPacket row = getRow(dataHost.getSources()[i], c.getCharset().getResults());
row.setPacketId(++packetId);
buffer = row.write(buffer, c, true);
if (dataHost.getrReadSources().get(i) != null) {
for (PhysicalDatasource w : dataHost.getrReadSources().get(i)) {
RowDataPacket sRow = getRow(w, c.getCharset().getResults());
sRow.setPacketId(++packetId);
buffer = sRow.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.EOFPacket in project dble by actiontech.
the class ShowDatasourceCluster method response.
public static void response(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();
for (RowDataPacket row : getRows(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);
}
Aggregations