use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineDBTests method doTestStateMachineTransTimeoutAsync.
private void doTestStateMachineTransTimeoutAsync(Map<String, Object> paramMap) throws Exception {
long start = System.currentTimeMillis();
String stateMachineName = "simpleCompensationStateMachine";
StateMachineInstance inst = stateMachineEngine.startAsync(stateMachineName, null, paramMap, callback);
waittingForFinish(inst);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
GlobalTransaction globalTransaction = getGlobalTransaction(inst);
Assertions.assertNotNull(globalTransaction);
System.out.println("====== GlobalStatus: " + globalTransaction.getStatus());
// waiting for global transaction recover
while (!ExecutionStatus.SU.equals(inst.getCompensationStatus())) {
System.out.println("====== GlobalStatus: " + globalTransaction.getStatus());
Thread.sleep(2000);
inst = stateMachineEngine.getStateMachineConfig().getStateLogStore().getStateMachineInstance(inst.getId());
}
Assertions.assertTrue(ExecutionStatus.UN.equals(inst.getStatus()) || ExecutionStatus.SU.equals(inst.getStatus()));
Assertions.assertTrue(ExecutionStatus.SU.equals(inst.getCompensationStatus()));
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineDBTests method testSimpleStateMachineWithLoop.
@Test
public void testSimpleStateMachineWithLoop() {
long start = System.currentTimeMillis();
List<Integer> loopList = new ArrayList<>();
for (int i = 0; i < 10; i++) {
loopList.add(i);
}
Map<String, Object> paramMap = new HashMap<>(2);
paramMap.put("a", 1);
paramMap.put("collection", loopList);
String stateMachineName = "simpleLoopTestStateMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertEquals(inst.getStatus(), ExecutionStatus.SU);
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineDBTests method testSimpleRetryStateMachine.
@Test
public void testSimpleRetryStateMachine() {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleRetryStateMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertNotNull(inst.getException());
Assertions.assertTrue(ExecutionStatus.FA.equals(inst.getStatus()));
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineDBTests method testSimpleRetryStateAsUpdateMode.
@Test
public void testSimpleRetryStateAsUpdateMode() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 1);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleUpdateStateMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertNotNull(inst.getException());
Assertions.assertEquals(inst.getStatus(), ExecutionStatus.UN);
Thread.sleep(sleepTime);
inst = stateMachineEngine.getStateMachineConfig().getStateLogStore().getStateMachineInstance(inst.getId());
Assertions.assertEquals(inst.getStateList().size(), 2);
}
use of io.seata.saga.statelang.domain.StateMachineInstance in project seata by seata.
the class StateMachineDBTests method testSimpleSubCompensateStateAsUpdateMode.
@Test
public void testSimpleSubCompensateStateAsUpdateMode() throws Exception {
long start = System.currentTimeMillis();
Map<String, Object> paramMap = new HashMap<>(1);
paramMap.put("a", 4);
paramMap.put("barThrowException", "true");
String stateMachineName = "simpleStateMachineWithCompensationAndSubMachine";
StateMachineInstance inst = stateMachineEngine.start(stateMachineName, null, paramMap);
long cost = System.currentTimeMillis() - start;
System.out.println("====== cost :" + cost);
Assertions.assertEquals(inst.getStatus(), ExecutionStatus.UN);
Thread.sleep(sleepTime);
inst = stateMachineEngine.getStateMachineConfig().getStateLogStore().getStateMachineInstance(inst.getId());
Assertions.assertEquals(inst.getStateList().size(), 2);
}
Aggregations