use of com.actiontech.dble.net.mysql.FieldPacket 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);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class PreparedStmtResponse method response.
public static void response(PreparedStatement pStmt, FrontendConnection c) {
byte packetId = 0;
// write preparedOk packet
PreparedOkPacket preparedOk = new PreparedOkPacket();
preparedOk.setPacketId(++packetId);
preparedOk.setStatementId(pStmt.getId());
preparedOk.setColumnsNumber(pStmt.getColumnsNumber());
preparedOk.setParametersNumber(pStmt.getParametersNumber());
ByteBuffer buffer = preparedOk.write(c.allocate(), c, true);
// write parameter field packet
int parametersNumber = preparedOk.getParametersNumber();
if (parametersNumber > 0) {
for (int i = 0; i < parametersNumber; i++) {
FieldPacket field = new FieldPacket();
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
}
// write column field packet
int columnsNumber = preparedOk.getColumnsNumber();
if (columnsNumber > 0) {
for (int i = 0; i < columnsNumber; i++) {
FieldPacket field = new FieldPacket();
field.setPacketId(++packetId);
buffer = field.write(buffer, c, true);
}
EOFPacket eof = new EOFPacket();
eof.setPacketId(++packetId);
buffer = eof.write(buffer, c, true);
}
// send buffer
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class SelectDatabase 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(StringUtil.encode(c.getSchema(), 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.FieldPacket in project dble by actiontech.
the class ShowSysParam 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.getPacketId();
SystemConfig sysConfig = DbleServer.getInstance().getConfig().getSystem();
List<String> paramValues = new ArrayList<>();
paramValues.add(sysConfig.getProcessors() + "");
paramValues.add(sysConfig.getBackendProcessors() + "");
paramValues.add(sysConfig.getBufferPoolChunkSize() + "B");
paramValues.add(sysConfig.getBufferPoolPageSize() + "B");
paramValues.add(sysConfig.getBufferPoolPageNumber() + "B");
paramValues.add(sysConfig.getProcessorExecutor() + "");
paramValues.add(sysConfig.getBackendProcessorExecutor() + "");
paramValues.add(sysConfig.getBindIp() + "");
paramValues.add(sysConfig.getServerPort() + "");
paramValues.add(sysConfig.getManagerPort() + "");
paramValues.add(sysConfig.getFakeMySQLVersion());
paramValues.add(sysConfig.getUsingAIO() + "");
paramValues.add(sysConfig.getUseCompression() + "");
paramValues.add(sysConfig.getServerNodeId() + "");
paramValues.add(sysConfig.isUseZKSwitch() + "");
paramValues.add(sysConfig.getSequnceHandlerType() > 4 || sysConfig.getSequnceHandlerType() < 1 ? "Incorrect Sequence Type" : SEQUENCES[sysConfig.getSequnceHandlerType()]);
paramValues.add(sysConfig.getMaxPacketSize() / 1024 / 1024 + "M");
paramValues.add(sysConfig.getServerBacklog() + "");
paramValues.add(sysConfig.getIdleTimeout() / 1000 / 60 + " Minutes");
paramValues.add(sysConfig.getCharset() + "");
paramValues.add(sysConfig.getTxIsolation() > 4 || sysConfig.getTxIsolation() < 1 ? "Incorrect isolation" : ISOLATION_LEVELS[sysConfig.getTxIsolation()]);
paramValues.add(sysConfig.getSqlExecuteTimeout() + " Seconds");
paramValues.add(sysConfig.getProcessorCheckPeriod() / 1000 + " Seconds");
paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() / 1000 + " Seconds");
paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() / 1000 + " Seconds");
paramValues.add(sysConfig.getBackSocketSoRcvbuf() + "B");
paramValues.add(sysConfig.getBackSocketSoSndbuf() + "B");
paramValues.add(sysConfig.getBackSocketNoDelay() + "");
paramValues.add(sysConfig.getFrontSocketSoRcvbuf() + "B");
paramValues.add(sysConfig.getFrontSocketSoSndbuf() + "B");
paramValues.add(sysConfig.getFrontSocketNoDelay() + "");
paramValues.add(sysConfig.getBufferUsagePercent() + "%");
paramValues.add(sysConfig.getUseSqlStat() + "");
paramValues.add(sysConfig.getClearBigSqLResultSetMapMs() + "ms");
paramValues.add(sysConfig.getSqlRecordCount() + "");
paramValues.add(sysConfig.getMaxResultSet() + "B");
paramValues.add(sysConfig.getShowBinlogStatusTimeout() + "ms");
paramValues.add(sysConfig.getCheckTableConsistency() + "");
paramValues.add(sysConfig.getCheckTableConsistencyPeriod() + "ms");
paramValues.add(sysConfig.getUseGlobleTableCheck() + "");
paramValues.add(sysConfig.getGlableTableCheckPeriod() + "ms");
paramValues.add(sysConfig.getDataNodeIdleCheckPeriod() + "ms");
paramValues.add(sysConfig.getDataNodeHeartbeatPeriod() + "ms");
paramValues.add(sysConfig.getRecordTxn() + "");
paramValues.add(sysConfig.getTransactionLogBaseDir());
paramValues.add(sysConfig.getTransactionLogBaseName());
paramValues.add(sysConfig.getTransactionRatateSize() + "M");
paramValues.add(sysConfig.getXaRecoveryLogBaseDir());
paramValues.add(sysConfig.getXaRecoveryLogBaseName());
paramValues.add(sysConfig.getXaSessionCheckPeriod() + "ms");
paramValues.add(sysConfig.getXaLogCleanPeriod() + "ms");
paramValues.add(sysConfig.isUseJoinStrategy() + "");
paramValues.add(sysConfig.getNestLoopConnSize() + "");
paramValues.add(sysConfig.getNestLoopRowsSize() + "");
paramValues.add(sysConfig.getViewPersistenceConfBaseDir());
paramValues.add(sysConfig.getViewPersistenceConfBaseName());
paramValues.add(sysConfig.getComplexExecutor() + "");
paramValues.add(sysConfig.getOtherMemSize() + "M");
paramValues.add(sysConfig.getOrderMemSize() + "M");
paramValues.add(sysConfig.getJoinMemSize() + "M");
paramValues.add(sysConfig.getCostTimeStat() + "");
paramValues.add(sysConfig.getMaxCostStatSize() + "");
paramValues.add(sysConfig.getCostSamplePercent() + "");
paramValues.add(sysConfig.getUseThreadUsageStat() + "");
paramValues.add(sysConfig.getUsePerformanceMode() + "");
for (int i = 0; i < PARAM_NAMES.length; i++) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(PARAM_NAMES[i], c.getCharset().getResults()));
row.add(StringUtil.encode(paramValues.get(i), c.getCharset().getResults()));
row.add(StringUtil.encode(PARAM_DESCRIPTION[i], 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);
// write buffer
c.write(buffer);
}
use of com.actiontech.dble.net.mysql.FieldPacket in project dble by actiontech.
the class ShowTableAlgorithm method execute.
public static void execute(ManagerConnection c, String tableInfo) {
Matcher ma = PATTERN_FOR_TABLE_INFO.matcher(tableInfo);
if (!ma.matches()) {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_ERROR, "The Correct Query Format Is:show @@algorithm where schema=? and table =?");
return;
}
String schemaName = ma.group(2);
String tableName = ma.group(4);
if (DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames()) {
schemaName = schemaName.toLowerCase();
tableName = tableName.toLowerCase();
}
SchemaConfig schemaConfig = DbleServer.getInstance().getConfig().getSchemas().get(schemaName);
TableType tableType;
TableConfig tableConfig = null;
if (schemaConfig == null) {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_ERROR, "the schema [" + schemaName + "] does not exists");
return;
} else if (schemaConfig.isNoSharding()) {
tableType = TableType.BASE;
} else {
tableConfig = schemaConfig.getTables().get(tableName);
if (tableConfig == null) {
if (schemaConfig.getDataNode() == null) {
c.writeErrMessage(ErrorCode.ER_UNKNOWN_ERROR, "the table [" + tableName + "] in schema [" + schemaName + "] does not exists");
return;
} else {
tableType = TableType.BASE;
}
} else if (tableConfig.isGlobalTable()) {
tableType = TableType.GLOBAL;
} else if (tableConfig.getParentTC() != null) {
tableType = TableType.CHILD;
} else if (tableConfig.getRule() == null) {
tableType = TableType.SHARDING_SINGLE;
} else {
tableType = TableType.SHARDING;
}
}
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();
for (RowDataPacket row : getRows(tableConfig, tableType, 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);
}
Aggregations