use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class SelectSessionAutoIncrement 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;
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.packetId = ++packetId;
row.add(LongUtil.toBytes(1));
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.RowDataPacket in project cobar by alibaba.
the class SelectVersionComment 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;
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(VERSION_COMMENT);
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.RowDataPacket in project cobar by alibaba.
the class ShowBackend method execute.
public static void execute(ManagerConnection c) {
ByteBuffer buffer = c.allocate();
buffer = header.write(buffer, c);
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
buffer = eof.write(buffer, c);
byte packetId = eof.packetId;
String charset = c.getCharset();
for (NIOProcessor p : CobarServer.getInstance().getProcessors()) {
for (BackendConnection bc : p.getBackends().values()) {
if (bc != null) {
RowDataPacket row = getRow(bc, charset);
row.packetId = ++packetId;
buffer = row.write(buffer, c);
}
}
}
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c);
c.write(buffer);
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowDataSources method getRow.
private static RowDataPacket getRow(MySQLDataNode node, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(node.getName(), charset));
MySQLDataSource ds = node.getSource();
if (ds != null) {
DataSourceConfig dsc = ds.getConfig();
row.add(StringUtil.encode(dsc.getType(), charset));
row.add(StringUtil.encode(dsc.getHost(), charset));
row.add(IntegerUtil.toBytes(dsc.getPort()));
row.add(StringUtil.encode(dsc.getDatabase(), charset));
} else {
row.add(null);
row.add(null);
row.add(null);
row.add(null);
}
return row;
}
use of com.alibaba.cobar.net.mysql.RowDataPacket in project cobar by alibaba.
the class ShowDataSources method response.
public static void response(ServerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c);
// write field
for (FieldPacket field : fields) {
buffer = field.write(buffer, c);
}
// write eof
buffer = eof.write(buffer, c);
// write rows
byte packetId = eof.packetId;
Map<String, MySQLDataNode> nodes = CobarServer.getInstance().getConfig().getDataNodes();
for (MySQLDataNode node : nodes.values()) {
RowDataPacket row = getRow(node, 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);
}
Aggregations