use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class SequenceVal method rowResponse.
@Override
public void rowResponse(byte[] row, BackendConnection conn) {
RowDataPacket rowDataPkg = new RowDataPacket(1);
rowDataPkg.read(row);
byte[] columnData = rowDataPkg.fieldValues.get(0);
String columnVal = new String(columnData);
SequenceVal seqVal = (SequenceVal) conn.getAttachment();
if (IncrSequenceMySQLHandler.errSeqResult.equals(columnVal)) {
seqVal.dbretVal = IncrSequenceMySQLHandler.errSeqResult;
LOGGER.warn(" sequnce sql returned err value ,sequence:" + seqVal.seqName + " " + columnVal + " sql:" + seqVal.sql);
} else {
seqVal.dbretVal = columnVal;
}
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class MysqlInformationSchemaHandler method querySessionVariables.
/**
* @param c
* @param charset
*/
private static void querySessionVariables(ServerConnection c, String charset) {
int field_count = 2;
FieldPacket[] fields = new FieldPacket[field_count];
fields[0] = PacketUtil.getField("VARIABLE_NAME", Fields.FIELD_TYPE_VAR_STRING);
fields[1] = PacketUtil.getField("VARIABLE_VALUE", Fields.FIELD_TYPE_VAR_STRING);
RowDataPacket[] rows = new RowDataPacket[1];
RowDataPacket row = new RowDataPacket(field_count);
row.add(StringUtil.encode("TIME_ZONE", charset));
row.add(StringUtil.encode("system ", charset));
rows[0] = row;
Result rs = new Result();
rs.fields = fields;
rs.rows = rows;
doWrite(rs, c);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class MysqlInformationSchemaHandler method queryCollations.
/**
* @param c
* @param charset
*/
private static void queryCollations(ServerConnection c, String charset) {
int field_count = 6;
FieldPacket[] fields = new FieldPacket[field_count];
fields[0] = PacketUtil.getField("COLLATION_NAME", Fields.FIELD_TYPE_VAR_STRING);
fields[1] = PacketUtil.getField("CHARACTER_SET_NAME", Fields.FIELD_TYPE_VAR_STRING);
fields[2] = PacketUtil.getField("ID", Fields.FIELD_TYPE_VAR_STRING);
fields[3] = PacketUtil.getField("IS_DEFAULT", Fields.FIELD_TYPE_VAR_STRING);
fields[4] = PacketUtil.getField("IS_COMPILED", Fields.FIELD_TYPE_VAR_STRING);
fields[5] = PacketUtil.getField("SORTLEN", Fields.FIELD_TYPE_VAR_STRING);
RowDataPacket[] rows = new RowDataPacket[1];
RowDataPacket row = new RowDataPacket(field_count);
row.add(StringUtil.encode("utf8_bin", charset));
row.add(StringUtil.encode("utf8 ", charset));
row.add(StringUtil.encode("196", charset));
row.add(StringUtil.encode("", charset));
row.add(StringUtil.encode("YES ", charset));
row.add(StringUtil.encode("8", charset));
rows[0] = row;
Result rs = new Result();
rs.fields = fields;
rs.rows = rows;
doWrite(rs, c);
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
the class ShowCache method getRow.
private static RowDataPacket getRow(String poolName, CacheStatic cacheStatic, String charset) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(poolName, charset));
// max size
row.add(LongUtil.toBytes(cacheStatic.getMaxSize()));
row.add(LongUtil.toBytes(cacheStatic.getItemSize()));
row.add(LongUtil.toBytes(cacheStatic.getAccessTimes()));
row.add(LongUtil.toBytes(cacheStatic.getHitTimes()));
row.add(LongUtil.toBytes(cacheStatic.getPutTimes()));
row.add(LongUtil.toBytes(cacheStatic.getLastAccesTime()));
row.add(LongUtil.toBytes(cacheStatic.getLastPutTime()));
return row;
}
use of io.mycat.net.mysql.RowDataPacket in project Mycat_plus by coderczp.
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);
}
Aggregations