use of com.alibaba.cobar.net.mysql.FieldPacket in project cobar by alibaba.
the class ShowHelp method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
for (String key : keys) {
RowDataPacket row = getRow(key, helps.get(key), c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// post write
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.FieldPacket in project cobar by alibaba.
the class ShowRouter method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
RowDataPacket row = getRow(p, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.FieldPacket in project cobar by alibaba.
the class ShowSQLDetail method execute.
public static void execute(ManagerConnection c, long sql) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
for (int i = 0; i < 3; i++) {
RowDataPacket row = getRow(sql, c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.FieldPacket in project cobar by alibaba.
the class ShowSQLExecute method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write fields
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
for (int i = 0; i < 3; i++) {
RowDataPacket row = getRow(1000 * (i + 1), c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.FieldPacket in project cobar by alibaba.
the class SampleResponseHandler method response.
public static void response(SampleConnection c, String message) {
byte packetId = 0;
ByteBuffer buffer = c.allocate();
// header
ResultSetHeaderPacket header = new ResultSetHeaderPacket();
header.packetId = ++packetId;
header.fieldCount = 1;
buffer = header.write(buffer, c);
// fields
FieldPacket[] fields = new FieldPacket[header.fieldCount];
for (FieldPacket field : fields) {
field = new FieldPacket();
field.packetId = ++packetId;
field.charsetIndex = CharsetUtil.getIndex("Cp1252");
field.name = "SampleServer".getBytes();
field.type = Fields.FIELD_TYPE_VAR_STRING;
buffer = field.write(buffer, c);
}
// eof
EOFPacket eof = new EOFPacket();
eof.packetId = ++packetId;
buffer = eof.write(buffer, c);
// rows
RowDataPacket row = new RowDataPacket(header.fieldCount);
row.add(message != null ? encode(message, c.getCharset()) : encode("HelloWorld!", c.getCharset()));
row.packetId = ++packetId;
buffer = row.write(buffer, c);
// write lastEof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
// write buffer
c.write(buffer);
}
Aggregations