Search in sources :

Example 1 with NonBlockingSession

use of com.actiontech.dble.server.NonBlockingSession in project dble by actiontech.

the class XASessionCheck method checkRollbackSession.

private void checkRollbackSession() {
    for (NonBlockingSession session : rollbackSession.values()) {
        this.rollbackSession.remove(session.getSource().getId());
        session.rollback();
    }
}
Also used : NonBlockingSession(com.actiontech.dble.server.NonBlockingSession)

Example 2 with NonBlockingSession

use of com.actiontech.dble.server.NonBlockingSession in project dble by actiontech.

the class ShowBinlogStatus method waitAllSession.

public static boolean waitAllSession() {
    logger.info("waiting all sessions of distributed transaction which are not finished.");
    long timeout = DbleServer.getInstance().getConfig().getSystem().getShowBinlogStatusTimeout();
    long beginTime = TimeUtil.currentTimeMillis();
    List<NonBlockingSession> fcList = getNeedWaitSession();
    while (!fcList.isEmpty()) {
        LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
        Iterator<NonBlockingSession> sListIterator = fcList.iterator();
        while (sListIterator.hasNext()) {
            NonBlockingSession session = sListIterator.next();
            if (!session.isNeedWaitFinished()) {
                sListIterator.remove();
            }
        }
        if ((TimeUtil.currentTimeMillis() > beginTime + timeout)) {
            logger.info("wait session finished timeout");
            return false;
        }
    }
    logger.info("all sessions of distributed transaction  are paused.");
    return true;
}
Also used : NonBlockingSession(com.actiontech.dble.server.NonBlockingSession)

Example 3 with NonBlockingSession

use of com.actiontech.dble.server.NonBlockingSession in project dble by actiontech.

the class ShowBinlogStatus method waitAllSession.

private static boolean waitAllSession(ManagerConnection c, long timeout, long beginTime) {
    logger.info("waiting all sessions of distributed transaction which are not finished.");
    List<NonBlockingSession> fcList = getNeedWaitSession();
    while (!fcList.isEmpty()) {
        LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
        Iterator<NonBlockingSession> sListIterator = fcList.iterator();
        while (sListIterator.hasNext()) {
            NonBlockingSession session = sListIterator.next();
            if (!session.isNeedWaitFinished()) {
                sListIterator.remove();
            }
        }
        if (c.isClosed()) {
            errMsg = "client closed while waiting for unfinished distributed transactions.";
            logger.info(errMsg);
            return false;
        }
        if (TimeUtil.currentTimeMillis() > beginTime + timeout) {
            errMsg = "timeout while waiting for unfinished distributed transactions.";
            logger.info(errMsg);
            return false;
        }
    }
    logger.info("all sessions of distributed transaction  are paused.");
    return true;
}
Also used : NonBlockingSession(com.actiontech.dble.server.NonBlockingSession)

Example 4 with NonBlockingSession

use of com.actiontech.dble.server.NonBlockingSession in project dble by actiontech.

the class ShowBinlogStatus method getNeedWaitSession.

private static List<NonBlockingSession> getNeedWaitSession() {
    List<NonBlockingSession> fcList = new ArrayList<>();
    for (NIOProcessor process : DbleServer.getInstance().getFrontProcessors()) {
        for (FrontendConnection front : process.getFrontends().values()) {
            if (!(front instanceof ServerConnection)) {
                continue;
            }
            ServerConnection sc = (ServerConnection) front;
            NonBlockingSession session = sc.getSession2();
            if (session.isNeedWaitFinished()) {
                fcList.add(session);
            }
        }
    }
    return fcList;
}
Also used : FrontendConnection(com.actiontech.dble.net.FrontendConnection) NonBlockingSession(com.actiontech.dble.server.NonBlockingSession) ServerConnection(com.actiontech.dble.server.ServerConnection) NIOProcessor(com.actiontech.dble.net.NIOProcessor)

Example 5 with NonBlockingSession

use of com.actiontech.dble.server.NonBlockingSession in project dble by actiontech.

the class XASessionCheck method checkCommitSession.

private void checkCommitSession() {
    for (NonBlockingSession session : commitSession.values()) {
        if (session.getXaState() == TxState.TX_COMMIT_FAILED_STATE) {
            this.commitSession.remove(session.getSource().getId());
            session.commit();
        }
    }
}
Also used : NonBlockingSession(com.actiontech.dble.server.NonBlockingSession)

Aggregations

NonBlockingSession (com.actiontech.dble.server.NonBlockingSession)6 BackendConnection (com.actiontech.dble.backend.BackendConnection)1 FrontendConnection (com.actiontech.dble.net.FrontendConnection)1 NIOProcessor (com.actiontech.dble.net.NIOProcessor)1 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)1 ServerConnection (com.actiontech.dble.server.ServerConnection)1