use of io.mycat.net.mysql.EOFPacket in project Mycat-Server by MyCATApache.
the class ShowBackend 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.packetId;
String charset = c.getCharset();
for (NIOProcessor p : MycatServer.getInstance().getProcessors()) {
for (BackendConnection bc : p.getBackends().values()) {
if (bc != null) {
RowDataPacket row = getRow(bc, charset);
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
}
}
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
c.write(buffer);
}
use of io.mycat.net.mysql.EOFPacket in project Mycat-Server by MyCATApache.
the class MyCATSequnceProcessor method outRawData.
private void outRawData(ServerConnection sc, String value) {
byte packetId = 0;
int fieldCount = 1;
ByteBuffer byteBuf = sc.allocate();
ResultSetHeaderPacket headerPkg = new ResultSetHeaderPacket();
headerPkg.fieldCount = fieldCount;
headerPkg.packetId = ++packetId;
byteBuf = headerPkg.write(byteBuf, sc, true);
FieldPacket fieldPkg = new FieldPacket();
fieldPkg.packetId = ++packetId;
fieldPkg.name = StringUtil.encode("SEQUNCE", sc.getCharset());
byteBuf = fieldPkg.write(byteBuf, sc, true);
EOFPacket eofPckg = new EOFPacket();
eofPckg.packetId = ++packetId;
byteBuf = eofPckg.write(byteBuf, sc, true);
RowDataPacket rowDataPkg = new RowDataPacket(fieldCount);
rowDataPkg.packetId = ++packetId;
rowDataPkg.add(StringUtil.encode(value, sc.getCharset()));
byteBuf = rowDataPkg.write(byteBuf, sc, true);
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
byteBuf = lastEof.write(byteBuf, sc, true);
// write buffer
sc.write(byteBuf);
}
use of io.mycat.net.mysql.EOFPacket in project Mycat-Server by MyCATApache.
the class Explain2Handler method showerror.
private static void showerror(String stmt, ServerConnection c, String msg) {
ByteBuffer buffer = c.allocate();
// write header
ResultSetHeaderPacket header = PacketUtil.getHeader(FIELD_COUNT);
byte packetId = header.packetId;
buffer = header.write(buffer, c, true);
// write fields
for (FieldPacket field : fields) {
field.packetId = ++packetId;
buffer = field.write(buffer, c, true);
}
// write eof
EOFPacket eof = new EOFPacket();
eof.packetId = ++packetId;
buffer = eof.write(buffer, c, true);
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(stmt, c.getCharset()));
row.add(StringUtil.encode(msg, c.getCharset()));
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// post write
c.write(buffer);
}
use of io.mycat.net.mysql.EOFPacket in project Mycat-Server by MyCATApache.
the class ShowCache 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.packetId;
CacheService cacheService = MycatServer.getInstance().getCacheService();
for (Map.Entry<String, CachePool> entry : cacheService.getAllCachePools().entrySet()) {
String cacheName = entry.getKey();
CachePool cachePool = entry.getValue();
if (cachePool instanceof LayerCachePool) {
for (Map.Entry<String, CacheStatic> staticsEntry : ((LayerCachePool) cachePool).getAllCacheStatic().entrySet()) {
RowDataPacket row = getRow(cacheName + '.' + staticsEntry.getKey(), staticsEntry.getValue(), c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
} else {
RowDataPacket row = getRow(cacheName, cachePool.getCacheStatic(), c.getCharset());
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
}
// write last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// write buffer
c.write(buffer);
}
use of io.mycat.net.mysql.EOFPacket in project Mycat-Server by MyCATApache.
the class ShowMyCATCluster method response.
public static void response(ServerConnection c) {
ByteBuffer buffer = c.allocate();
// write header
buffer = header.write(buffer, c, true);
// write field
for (FieldPacket field : fields) {
buffer = field.write(buffer, c, true);
}
// write eof
buffer = eof.write(buffer, c, true);
// write rows
byte packetId = eof.packetId;
for (RowDataPacket row : getRows(c)) {
row.packetId = ++packetId;
buffer = row.write(buffer, c, true);
}
// last eof
EOFPacket lastEof = new EOFPacket();
lastEof.packetId = ++packetId;
buffer = lastEof.write(buffer, c, true);
// post write
c.write(buffer);
}
Aggregations