use of com.actiontech.dble.config.model.TableConfig in project dble by actiontech.
the class GlobalTableUtil method getGlobalTable.
private static void getGlobalTable() {
ServerConfig config = DbleServer.getInstance().getConfig();
for (Map.Entry<String, SchemaConfig> entry : config.getSchemas().entrySet()) {
for (TableConfig table : entry.getValue().getTables().values()) {
if (table.isGlobalTable()) {
String tableName = table.getName();
if (DbleServer.getInstance().getSystemVariables().isLowerCaseTableNames()) {
tableName = tableName.toLowerCase();
}
globalTableMap.put(entry.getKey() + "." + tableName, table);
}
}
}
}
use of com.actiontech.dble.config.model.TableConfig 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