use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class PhysicalDatasource method closeByIdleMany.
private void closeByIdleMany(int idleCloseCount, int idleCons) {
LOGGER.info("too many ilde cons ,close some for datasouce " + name + " want close :" + idleCloseCount + " total idle " + idleCons);
List<BackendConnection> readyCloseCons = new ArrayList<BackendConnection>(idleCloseCount);
for (ConQueue queue : conMap.getAllConQueue()) {
int closeNumber = (queue.getManCommitCons().size() + queue.getAutoCommitCons().size()) * idleCloseCount / idleCons;
readyCloseCons.addAll(queue.getIdleConsToClose(closeNumber));
}
for (BackendConnection idleCon : readyCloseCons) {
if (idleCon.isBorrowed()) {
LOGGER.info("find idle con is using " + idleCon);
}
idleCon.close("too many idle con");
}
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class NormalAutoRollbackNodesHandler method rollback.
@Override
public void rollback() {
if (errConnection != null && nodes.length == errConnection.size()) {
for (BackendConnection conn : errConnection) {
conn.quit();
}
errConnection.clear();
session.getSource().write(sendData);
return;
}
if (errConnection != null && errConnection.size() > 0) {
for (RouteResultsetNode node : nodes) {
final BackendConnection conn = session.getTarget(node);
if (errConnection.contains(conn)) {
session.getTargetMap().remove(node);
conn.quit();
}
}
errConnection.clear();
}
super.rollback();
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class XAAutoRollbackNodesHandler method rollback.
@Override
public void rollback() {
if (errConnection != null && nodes.length == errConnection.size()) {
for (BackendConnection conn : errConnection) {
conn.quit();
}
errConnection.clear();
session.getSource().write(sendData);
return;
}
if (errConnection != null && errConnection.size() > 0) {
for (RouteResultsetNode node : nodes) {
final BackendConnection conn = session.getTarget(node);
if (errConnection.contains(conn)) {
session.getTargetMap().remove(node);
conn.quit();
}
}
errConnection.clear();
}
super.rollback();
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class ReloadConfig method recycleOldBackendConnections.
private static void recycleOldBackendConnections(ServerConfig config, boolean closeFrontCon) {
/* 2.4 put the old connection into a queue */
Map<String, PhysicalDBPool> oldDataHosts = config.getBackupDataHosts();
for (PhysicalDBPool dbPool : oldDataHosts.values()) {
dbPool.stopHeartbeat();
for (PhysicalDatasource ds : dbPool.getAllDataSources()) {
for (NIOProcessor processor : DbleServer.getInstance().getBackendProcessors()) {
for (BackendConnection con : processor.getBackends().values()) {
if (con instanceof MySQLConnection) {
MySQLConnection mysqlCon = (MySQLConnection) con;
if (mysqlCon.getPool() == ds) {
if (con.isBorrowed()) {
if (closeFrontCon) {
findAndcloseFrontCon(con);
} else {
NIOProcessor.BACKENDS_OLD.add(con);
}
} else {
con.close("old idle conn for reload");
}
}
}
}
}
}
}
LOGGER.info("the size of old backend connection to be recycled is: " + NIOProcessor.BACKENDS_OLD.size());
}
use of com.actiontech.dble.backend.BackendConnection in project dble by actiontech.
the class ShowBackendOld method execute.
public static void execute(ManagerConnection 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();
for (BackendConnection bc : NIOProcessor.BACKENDS_OLD) {
if (bc != null) {
RowDataPacket row = getRow(bc, 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);
}
Aggregations