Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature : SAGA annotation mode #4577

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
aa9f275
feature : SAGA annotation mode
Apr 30, 2022
ff77aea
format codes
sunrui1225 May 5, 2022
6370d38
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 May 7, 2022
7f05fbf
Merge remote-tracking branch 'origin/develop' into feature_saga_annot…
sunrui1225 May 10, 2022
a9fe9d7
Merge remote-tracking branch 'origin/develop' into feature_saga_annot…
sunrui1225 May 17, 2022
f6f1b9e
solve spring and tcc dependency issue
sunrui1225 May 26, 2022
3b116b5
Merge branch 'develop' into feature_spring_tcc_dependency
sunrui1225 May 26, 2022
444e478
add Copyright
sunrui1225 May 28, 2022
a675613
Merge branch 'feature_spring_tcc_dependency' into feature_saga_annota…
sunrui1225 May 31, 2022
3fe3f82
Merge remote-tracking branch 'origin/develop' into feature_saga_annot…
sunrui1225 Jun 14, 2022
bcf3aaa
saga annotation mode actual plan
sunrui1225 Jun 15, 2022
bd6a2c0
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jun 15, 2022
475ebdb
fix saga module problem
sunrui1225 Jun 15, 2022
7e173a3
Merge remote-tracking branch 'origin/feature_saga_annotation_mode' in…
sunrui1225 Jun 15, 2022
b6c271e
avoid use '.*' import
sunrui1225 Jun 15, 2022
f2e32d3
fix check style
sunrui1225 Jun 15, 2022
9af0ee1
fix check style
sunrui1225 Jun 15, 2022
7d30bdb
fix check style
sunrui1225 Jun 15, 2022
114737b
fix check style
sunrui1225 Jun 15, 2022
4e06ffc
fix check style
sunrui1225 Jun 15, 2022
5b0a5b3
fix add SAGA branch type in saga interceptor
sunrui1225 Jun 16, 2022
dfffdc8
fix add SagaTransactionAutoProxy SPI
sunrui1225 Jun 16, 2022
6b8e7f9
add local service remoting parser test.
sunrui1225 Jun 17, 2022
feb5238
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jun 17, 2022
1898049
add test in spring : local service remoting parser test.
sunrui1225 Jun 17, 2022
71e1d13
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jun 22, 2022
82e0216
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jun 25, 2022
ccc0e44
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jun 29, 2022
c580b63
add local service remoting parser test
sunrui1225 Jul 1, 2022
b2ef990
add saga annotation resource manager. rename tcc to saga.
sunrui1225 Jul 1, 2022
88a770e
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jul 1, 2022
3af72e0
Merge remote-tracking branch 'origin/feature_saga_annotation_mode' in…
sunrui1225 Jul 1, 2022
100fbe5
add saga annotation build jar in pom
sunrui1225 Jul 2, 2022
7bb7f8e
fix add final in static method.
sunrui1225 Jul 5, 2022
1dafb3a
Merge remote-tracking branch 'origin/develop' into feature_saga_annot…
sunrui1225 Jul 9, 2022
9d1ae03
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jul 14, 2022
aa08f63
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jul 15, 2022
97add4a
Merge remote-tracking branch 'origin/feature_saga_annotation_mode' in…
sunrui1225 Jul 15, 2022
06de501
bug fix
sunrui1225 Jul 23, 2022
ac489eb
bug fix
sunrui1225 Jul 23, 2022
4ab2487
bug fix branch type
sunrui1225 Jul 23, 2022
cec9e46
bug fix saga annotation resource id
sunrui1225 Jul 23, 2022
533280f
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jul 23, 2022
72c102e
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Jul 29, 2022
779a34c
Merge branch 'develop' into feature_saga_annotation_mode
sunrui1225 Aug 3, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions common/src/main/java/io/seata/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,10 @@ public interface Constants {
* The constant SKIP_CHECK_LOCK
*/
String SKIP_CHECK_LOCK = "skipCheckLock";

/**
* The constant MODE_TYPE
*/
String MODE_TYPE = "modeType";

}
9 changes: 9 additions & 0 deletions tcc/src/main/java/io/seata/rm/tcc/TCCResourceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import io.seata.core.model.Resource;
import io.seata.rm.AbstractResourceManager;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.ModeType;

/**
* TCC resource manager
Expand Down Expand Up @@ -97,6 +98,14 @@ public BranchStatus branchCommit(BranchType branchType, String xid, long branchI
//BusinessActionContext
BusinessActionContext businessActionContext = getBusinessActionContext(xid, branchId, resourceId,
applicationData);

// if the TwoPhaseBusinessAction annotation's mode is SAGA, cancel the commit
ModeType modeType = (ModeType) businessActionContext.getActionContext(Constants.MODE_TYPE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefaultCore#doGlobalCommit 直接处理即可

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我再看一下这里DefaultCore#doGlobalCommit ,如果结合新的注解Compensable来处理

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外ActionInterceptorHandler#doTccActionLogStore 中应该传递branchtype注册至tc,否则到tc还是认为是tcc分支

确实要改成SAGA的branchtype,所以对于ActionInterceptorHandler来处理SAGA,我想可能新增一个doSagaActionLogStore来处理,或者考虑可重用来在内部兼容处理SAGA的branchtype注册至tc

if(modeType != null && modeType.equals( ModeType.SAGA)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码格式化一下

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果spring cloud用户使用注解式SAGA的话,需要打上@LocalTCC的注解,对于用户来说这个其实比较困惑

Copy link
Contributor Author

@sunrui1225 sunrui1225 May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

您好,已经格式提交。
确实@LocalTCC会让用户迷惑,所以我定义了一个新的注解Compensable和 LocalSAGA 与TCC区分,请见#4577 (comment)
此注解也定义了向前重试机制

LOGGER.info("TwoPhaseBusinessAction's ModeType is SAGA, cancel the commit, xid: {}, branchId: {}, resourceId: {}", xid, branchId, resourceId);
return BranchStatus.PhaseTwo_Committed;
}

Object[] args = this.getTwoPhaseCommitArgs(tccResource, businessActionContext);
Object ret;
boolean result;
Expand Down
18 changes: 18 additions & 0 deletions tcc/src/main/java/io/seata/rm/tcc/api/ModeType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.seata.rm.tcc.api;

/**
* The enum ModeType
*
* @author ruishan
*/
public enum ModeType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要使用新类,直接使用BranchType 枚举类

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经去掉ModeType,改成BranchType


/**
* TCC Mode
*/
TCC,
/**
* SAGA Mode
*/
SAGA;
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,11 @@
* @return the Class[]
*/
Class<?>[] rollbackArgsClasses() default {BusinessActionContext.class};

/**
* Define TCC or SAGA mode
*
* @return the mode
*/
ModeType modeType() default ModeType.TCC;
}
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ protected void initBusinessContext(Map<String, Object> context, Method method,
context.put(Constants.ROLLBACK_METHOD, businessAction.rollbackMethod());
context.put(Constants.ACTION_NAME, businessAction.name());
context.put(Constants.USE_TCC_FENCE, businessAction.useTCCFence());
context.put(Constants.MODE_TYPE, businessAction.modeType());
}
}

Expand Down