use of io.seata.core.model.GlobalStatus in project seata by seata.
the class DefaultCoreTest method rollBackTest.
/**
* Roll back test.
*
* @param xid the xid
* @throws Exception the exception
*/
@ParameterizedTest
@MethodSource("xidProvider")
public void rollBackTest(String xid) throws Exception {
GlobalStatus globalStatus = core.rollback(xid);
Assertions.assertEquals(globalStatus, GlobalStatus.Rollbacked);
}
use of io.seata.core.model.GlobalStatus in project seata by seata.
the class DefaultCoreTest method commitTest.
/**
* Commit test.
*
* @param xid the xid
* @throws Exception the exception
*/
@ParameterizedTest
@MethodSource("xidProvider")
public void commitTest(String xid) throws Exception {
GlobalStatus globalStatus = core.commit(xid);
Assertions.assertNotEquals(globalStatus, GlobalStatus.Begin);
}
use of io.seata.core.model.GlobalStatus in project seata by seata.
the class GlobalSession method queueToRetryRollback.
public void queueToRetryRollback() throws TransactionException {
this.addSessionLifecycleListener(SessionHolder.getRetryRollbackingSessionManager());
SessionHolder.getRetryRollbackingSessionManager().addGlobalSession(this);
GlobalStatus currentStatus = this.getStatus();
if (SessionHelper.isTimeoutGlobalStatus(currentStatus)) {
this.changeStatus(GlobalStatus.TimeoutRollbackRetrying);
} else {
this.changeStatus(GlobalStatus.RollbackRetrying);
}
}
use of io.seata.core.model.GlobalStatus in project seata by seata.
the class SessionHolder method reload.
// region reload
/**
* Reload.
*/
protected static void reload(StoreMode storeMode) {
if (ROOT_SESSION_MANAGER instanceof Reloadable) {
((Reloadable) ROOT_SESSION_MANAGER).reload();
}
Collection<GlobalSession> allSessions = ROOT_SESSION_MANAGER.allSessions();
if (CollectionUtils.isNotEmpty(allSessions)) {
List<GlobalSession> removeGlobalSessions = new ArrayList<>();
Iterator<GlobalSession> iterator = allSessions.iterator();
while (iterator.hasNext()) {
GlobalSession globalSession = iterator.next();
GlobalStatus globalStatus = globalSession.getStatus();
switch(globalStatus) {
case UnKnown:
case Committed:
case CommitFailed:
case Rollbacked:
case RollbackFailed:
case TimeoutRollbacked:
case TimeoutRollbackFailed:
case Finished:
removeGlobalSessions.add(globalSession);
break;
case AsyncCommitting:
if (storeMode == StoreMode.FILE) {
queueToAsyncCommitting(globalSession);
}
break;
default:
{
if (storeMode == StoreMode.FILE) {
lockBranchSessions(globalSession.getSortedBranches());
switch(globalStatus) {
case Committing:
case CommitRetrying:
queueToRetryCommit(globalSession);
break;
case Rollbacking:
case RollbackRetrying:
case TimeoutRollbacking:
case TimeoutRollbackRetrying:
queueToRetryRollback(globalSession);
break;
case Begin:
globalSession.setActive(true);
break;
default:
throw new ShouldNeverHappenException("NOT properly handled " + globalStatus);
}
}
break;
}
}
}
for (GlobalSession globalSession : removeGlobalSessions) {
removeInErrorState(globalSession);
}
}
}
use of io.seata.core.model.GlobalStatus in project seata by seata.
the class SessionHelper method endRollbackFailed.
/**
* End rollback failed.
*
* @param globalSession the global session
* @throws TransactionException the transaction exception
*/
public static void endRollbackFailed(GlobalSession globalSession) throws TransactionException {
GlobalStatus currentStatus = globalSession.getStatus();
if (isTimeoutGlobalStatus(currentStatus)) {
globalSession.changeStatus(GlobalStatus.TimeoutRollbackFailed);
} else {
globalSession.changeStatus(GlobalStatus.RollbackFailed);
}
globalSession.end();
}
Aggregations