use of com.actiontech.dble.config.ServerConfig in project dble by actiontech.
the class NonBlockingSession method kill.
protected void kill() {
AtomicInteger count = new AtomicInteger(0);
Map<RouteResultsetNode, BackendConnection> toKilled = new HashMap<>();
for (Map.Entry<RouteResultsetNode, BackendConnection> entry : target.entrySet()) {
BackendConnection c = entry.getValue();
if (c != null && !c.isDDL()) {
toKilled.put(entry.getKey(), c);
count.incrementAndGet();
} else if (c != null && c.isDDL()) {
// if the sql executing is a ddl,do not kill the query,just close the connection
this.terminate();
return;
}
}
for (Entry<RouteResultsetNode, BackendConnection> en : toKilled.entrySet()) {
KillConnectionHandler kill = new KillConnectionHandler(en.getValue(), this);
ServerConfig conf = DbleServer.getInstance().getConfig();
PhysicalDBNode dn = conf.getDataNodes().get(en.getKey().getName());
try {
dn.getConnectionFromSameSource(en.getValue().getSchema(), true, en.getValue(), kill, en.getKey());
} catch (Exception e) {
LOGGER.info("get killer connection failed for " + en.getKey(), e);
kill.connectionError(e, null);
}
}
}
use of com.actiontech.dble.config.ServerConfig 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.ServerConfig in project dble by actiontech.
the class ShowDatabases method response.
public static void response(ServerConnection 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();
ServerConfig conf = DbleServer.getInstance().getConfig();
Map<String, UserConfig> users = conf.getUsers();
UserConfig user = users == null ? null : users.get(c.getUser());
if (user != null) {
TreeSet<String> schemaSet = new TreeSet<>();
Set<String> schemaList = user.getSchemas();
if (schemaList == null || schemaList.size() == 0) {
schemaSet.addAll(conf.getSchemas().keySet());
} else {
for (String schema : schemaList) {
schemaSet.add(schema);
}
}
for (String name : schemaSet) {
RowDataPacket row = new RowDataPacket(FIELD_COUNT);
row.add(StringUtil.encode(name, 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);
}
use of com.actiontech.dble.config.ServerConfig in project dble by actiontech.
the class SingleNodeHandler method execute.
public void execute() throws Exception {
startTime = System.currentTimeMillis();
ServerConnection sc = session.getSource();
waitingResponse = true;
this.packetId = 0;
final BackendConnection conn = session.getTarget(node);
node.setRunOnSlave(rrs.getRunOnSlave());
if (session.tryExistsCon(conn, node)) {
execute(conn);
} else {
// create new connection
node.setRunOnSlave(rrs.getRunOnSlave());
ServerConfig conf = DbleServer.getInstance().getConfig();
PhysicalDBNode dn = conf.getDataNodes().get(node.getName());
dn.getConnection(dn.getDatabase(), session.getSource().isTxStart(), sc.isAutocommit(), node, this, node);
}
}
Aggregations