use of io.seata.core.store.GlobalTransactionDO in project seata by seata.
the class DataBaseTransactionStoreManager method readSession.
/**
* Read session global session.
*
* @param xid the xid
* @param withBranchSessions the withBranchSessions
* @return the global session
*/
@Override
public GlobalSession readSession(String xid, boolean withBranchSessions) {
// global transaction
GlobalTransactionDO globalTransactionDO = logStore.queryGlobalTransactionDO(xid);
if (globalTransactionDO == null) {
return null;
}
// branch transactions
List<BranchTransactionDO> branchTransactionDOs = null;
// reduce rpc with db when branchRegister and getGlobalStatus
if (withBranchSessions) {
branchTransactionDOs = logStore.queryBranchTransactionDO(globalTransactionDO.getXid());
}
return getGlobalSession(globalTransactionDO, branchTransactionDOs);
}
use of io.seata.core.store.GlobalTransactionDO in project seata by seata.
the class DataBaseTransactionStoreManager method readSession.
/**
* Read session global session.
*
* @param transactionId the transaction id
* @return the global session
*/
public GlobalSession readSession(Long transactionId) {
// global transaction
GlobalTransactionDO globalTransactionDO = logStore.queryGlobalTransactionDO(transactionId);
if (globalTransactionDO == null) {
return null;
}
// branch transactions
List<BranchTransactionDO> branchTransactionDOs = logStore.queryBranchTransactionDO(globalTransactionDO.getXid());
return getGlobalSession(globalTransactionDO, branchTransactionDOs);
}
use of io.seata.core.store.GlobalTransactionDO in project XHuiCloud by sindaZeng.
the class DataBaseTransactionStoreManager method readSession.
/**
* Read session global session.
*
* @param xid the xid
* @param withBranchSessions the withBranchSessions
* @return the global session
*/
@Override
public GlobalSession readSession(String xid, boolean withBranchSessions) {
// global transaction
GlobalTransactionDO globalTransactionDO = logStore.queryGlobalTransactionDO(xid);
if (globalTransactionDO == null) {
return null;
}
// branch transactions
List<BranchTransactionDO> branchTransactionDOs = null;
// reduce rpc with db when branchRegister and getGlobalStatus
if (withBranchSessions) {
branchTransactionDOs = logStore.queryBranchTransactionDO(globalTransactionDO.getXid());
}
return getGlobalSession(globalTransactionDO, branchTransactionDOs);
}
use of io.seata.core.store.GlobalTransactionDO in project XHuiCloud by sindaZeng.
the class SessionConverter method convertGlobalTransactionDO.
public static GlobalTransactionDO convertGlobalTransactionDO(SessionStorable session) {
if (session == null || !(session instanceof GlobalSession)) {
throw new IllegalArgumentException("The parameter of SessionStorable is not available, SessionStorable:" + StringUtils.toString(session));
}
GlobalSession globalSession = (GlobalSession) session;
GlobalTransactionDO globalTransactionDO = new GlobalTransactionDO();
globalTransactionDO.setXid(globalSession.getXid());
globalTransactionDO.setStatus(globalSession.getStatus().getCode());
globalTransactionDO.setApplicationId(globalSession.getApplicationId());
globalTransactionDO.setBeginTime(globalSession.getBeginTime());
globalTransactionDO.setTimeout(globalSession.getTimeout());
globalTransactionDO.setTransactionId(globalSession.getTransactionId());
globalTransactionDO.setTransactionName(globalSession.getTransactionName());
globalTransactionDO.setTransactionServiceGroup(globalSession.getTransactionServiceGroup());
globalTransactionDO.setApplicationData(globalSession.getApplicationData());
return globalTransactionDO;
}
use of io.seata.core.store.GlobalTransactionDO in project seata by seata.
the class SessionConverterTest method testConvertGlobalTransactionDONotNull.
@Test
public void testConvertGlobalTransactionDONotNull() {
Date date = new Date();
long now = date.getTime();
GlobalSession globalSession = new GlobalSession("application1", "fsp_tx", "createOrder", 60);
globalSession.setXid("192.168.158.80:8091:39372760251957248");
globalSession.setTransactionId(39372760251957248L);
globalSession.setStatus(GlobalStatus.Begin);
globalSession.setBeginTime(now);
globalSession.setApplicationData("id=1,product=2");
GlobalTransactionDO globalTransactionDO = SessionConverter.convertGlobalTransactionDO(globalSession);
Assertions.assertEquals(globalSession.getXid(), globalTransactionDO.getXid());
Assertions.assertEquals(globalSession.getTransactionId(), globalTransactionDO.getTransactionId());
Assertions.assertEquals(globalSession.getStatus().getCode(), globalTransactionDO.getStatus());
Assertions.assertEquals(globalSession.getTransactionName(), globalTransactionDO.getTransactionName());
Assertions.assertEquals(globalSession.getApplicationId(), globalTransactionDO.getApplicationId());
Assertions.assertEquals(globalSession.getTransactionServiceGroup(), globalTransactionDO.getTransactionServiceGroup());
Assertions.assertEquals(globalSession.getTransactionName(), globalTransactionDO.getTransactionName());
Assertions.assertEquals(globalSession.getTimeout(), globalTransactionDO.getTimeout());
Assertions.assertEquals(globalSession.getBeginTime(), globalTransactionDO.getBeginTime());
Assertions.assertEquals(globalSession.getApplicationData(), globalTransactionDO.getApplicationData());
}
Aggregations