use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class UnLockTablesHandler method execute.
public void execute() {
Map<RouteResultsetNode, BackendConnection> lockedCons = session.getTargetMap();
this.reset(lockedCons.size());
// if client just send an unlock tables, theres is no lock tables statement, just send back OK
if (lockedCons.size() == 0) {
LOGGER.info("find no locked backend connection!" + session.getSource());
OkPacket ok = new OkPacket();
ok.setPacketId(++packetId);
// the size of unlock table's response OK packet is 7
ok.setPacketLength(7);
ok.setServerStatus(session.getSource().isAutocommit() ? 2 : 1);
ok.write(session.getSource());
return;
}
for (Map.Entry<RouteResultsetNode, BackendConnection> entry : lockedCons.entrySet()) {
RouteResultsetNode dataNode = entry.getKey();
RouteResultsetNode node = new RouteResultsetNode(dataNode.getName(), ServerParse.UNLOCK, srcStatement);
BackendConnection conn = lockedCons.get(dataNode);
if (clearIfSessionClosed(session)) {
return;
}
conn.setResponseHandler(this);
conn.setSession(session);
try {
conn.execute(node, session.getSource(), autocommit);
} catch (Exception e) {
connectionError(e, conn);
}
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class PhysicalDatasource method getConnection.
public BackendConnection getConnection(String schema, boolean autocommit) throws IOException {
BackendConnection con = this.conMap.tryTakeCon(schema, autocommit);
if (con == null) {
// the max active
int activeCons = this.getActiveCount();
if (activeCons + 1 > size) {
LOGGER.warn(AlarmCode.CORE_PERFORMANCE_WARN + "the max activeConnnections size can not be max than maxconnections");
throw new IOException("the max activeConnnections size can not be max than maxconnections");
} else {
// create connection
LOGGER.info("no ilde connection in pool,create new connection for " + this.name + " of schema " + schema);
NewConnectionRespHandler simpleHandler = new NewConnectionRespHandler();
this.createNewConnection(simpleHandler, schema);
con = simpleHandler.getBackConn();
}
}
return takeCon(con, schema);
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class LockTablesHandler method execute.
public void execute() throws Exception {
super.reset(this.rrs.getNodes().length);
for (final RouteResultsetNode node : rrs.getNodes()) {
BackendConnection conn = session.getTarget(node);
if (session.tryExistsCon(conn, node)) {
innerExecute(conn, node);
} else {
// create new connection
PhysicalDBNode dn = DbleServer.getInstance().getConfig().getDataNodes().get(node.getName());
dn.getConnection(dn.getDatabase(), session.getSource().isTxStart(), autocommit, node, this, node);
}
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class PhysicalDatasource method getConnection.
public void getConnection(String schema, boolean autocommit, final ResponseHandler handler, final Object attachment) throws IOException {
if (dying.get()) {
closeByDyingAll();
LOGGER.info(this.name + "will to die");
throw new IOException(this.name + "will to die");
}
BackendConnection con = this.conMap.tryTakeCon(schema, autocommit);
if (con != null) {
takeCon(con, handler, attachment, schema);
return;
} else {
int activeCons = this.getActiveCount();
if (activeCons + 1 > size) {
LOGGER.warn(AlarmCode.CORE_PERFORMANCE_WARN + "the max activeConnnections size can not be max than maxconnections");
throw new IOException("the max activeConnnections size can not be max than maxconnections");
} else {
// create connection
LOGGER.info("no idle connection in pool,create new connection for " + this.name + " of schema " + schema);
createNewConnection(handler, attachment, schema);
}
}
}
Aggregations