use of com.actiontech.dble.net.mysql.EOFPacket in project dble by actiontech.
the class ShowTables method writeRowEof.
private static void writeRowEof(ByteBuffer buffer, ServerConnection c, byte packetId) {
// 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 SelectVersion method response.
public static void response(ServerConnection 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();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(Versions.getServerVersion());
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 SessionIsolation method response.
public static void response(ServerConnection 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();
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
String value = "";
switch(c.getTxIsolation()) {
case Isolations.READ_COMMITTED:
value = "READ-COMMITTED";
break;
case Isolations.READ_UNCOMMITTED:
value = "READ-UNCOMMITTED";
break;
case Isolations.REPEATABLE_READ:
value = "REPEATABLE-READ";
break;
case Isolations.SERIALIZABLE:
value = "SERIALIZABLE";
break;
default:
break;
}
row.add(StringUtil.encode(value, 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 ShowDatabases method response.
public static void response(ServerConnection 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();
ServerConfig conf = DbleServer.getInstance().getConfig();
Map<String, UserConfig> users = conf.getUsers();
UserConfig user = users == null ? null : users.get(c.getUser());
if (user != null) {
TreeSet<String> schemaSet = new TreeSet<>();
Set<String> schemaList = user.getSchemas();
if (schemaList == null || schemaList.size() == 0) {
schemaSet.addAll(conf.getSchemas().keySet());
} else {
for (String schema : schemaList) {
schemaSet.add(schema);
}
}
for (String name : schemaSet) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(name, 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.EOFPacket in project dble by actiontech.
the class InformationSchemaProfiling method response.
/**
* response method.
*
* @param c
*/
public static void response(ServerConnection c) {
int i = 0;
byte packetId = 0;
HEADER.setPacketId(++packetId);
FIELDS[i] = PacketUtil.getField("State", Fields.FIELD_TYPE_VAR_STRING);
FIELDS[i].setPacketId(++packetId);
FIELDS[i + 1] = PacketUtil.getField("Duration", Fields.FIELD_TYPE_DECIMAL);
FIELDS[i + 1].setPacketId(++packetId);
FIELDS[i + 2] = PacketUtil.getField("Percentage", Fields.FIELD_TYPE_DECIMAL);
FIELDS[i + 2].setPacketId(++packetId);
EOF.setPacketId(++packetId);
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
packetId = EOF.getPacketId();
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.setPacketId(++packetId);
buffer = lastEof.write(buffer, c, true);
// post write
c.write(buffer);
}
Aggregations