use of io.seata.server.session.SessionCondition in project seata by seata.
the class FileTransactionStoreManager method findTimeoutAndSave.
private boolean findTimeoutAndSave() throws IOException {
List<GlobalSession> globalSessionsOverMaxTimeout = sessionManager.findGlobalSessions(new SessionCondition(MAX_TRX_TIMEOUT_MILLS));
if (CollectionUtils.isEmpty(globalSessionsOverMaxTimeout)) {
return true;
}
for (GlobalSession globalSession : globalSessionsOverMaxTimeout) {
TransactionWriteStore globalWriteStore = new TransactionWriteStore(globalSession, LogOperation.GLOBAL_ADD);
byte[] data = globalWriteStore.encode();
if (!writeDataFrame(data)) {
return false;
}
List<BranchSession> branchSessIonsOverMaXTimeout = globalSession.getSortedBranches();
if (branchSessIonsOverMaXTimeout != null) {
for (BranchSession branchSession : branchSessIonsOverMaXTimeout) {
try {
MDC.put(MDC_KEY_BRANCH_ID, String.valueOf(branchSession.getBranchId()));
TransactionWriteStore branchWriteStore = new TransactionWriteStore(branchSession, LogOperation.BRANCH_ADD);
data = branchWriteStore.encode();
if (!writeDataFrame(data)) {
return false;
}
} finally {
MDC.remove(MDC_KEY_BRANCH_ID);
}
}
}
}
if (flushWriteBuffer(writeBuffer)) {
currFileChannel.force(false);
return true;
}
return false;
}
use of io.seata.server.session.SessionCondition in project XHuiCloud by sindaZeng.
the class FileTransactionStoreManager method findTimeoutAndSave.
private boolean findTimeoutAndSave() throws IOException {
List<GlobalSession> globalSessionsOverMaxTimeout = sessionManager.findGlobalSessions(new SessionCondition(MAX_TRX_TIMEOUT_MILLS));
if (CollectionUtils.isEmpty(globalSessionsOverMaxTimeout)) {
return true;
}
for (GlobalSession globalSession : globalSessionsOverMaxTimeout) {
TransactionWriteStore globalWriteStore = new TransactionWriteStore(globalSession, LogOperation.GLOBAL_ADD);
byte[] data = globalWriteStore.encode();
if (!writeDataFrame(data)) {
return false;
}
List<BranchSession> branchSessIonsOverMaXTimeout = globalSession.getSortedBranches();
if (branchSessIonsOverMaXTimeout != null) {
for (BranchSession branchSession : branchSessIonsOverMaXTimeout) {
TransactionWriteStore branchWriteStore = new TransactionWriteStore(branchSession, LogOperation.BRANCH_ADD);
data = branchWriteStore.encode();
if (!writeDataFrame(data)) {
return false;
}
}
}
}
if (flushWriteBuffer(writeBuffer)) {
currFileChannel.force(false);
return true;
}
return false;
}
Aggregations