You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by se...@apache.org on 2018/01/11 06:19:16 UTC
[incubator-servicecomb-saga] branch SCB-212_tx_timeout updated:
SCB-212 better readability
This is an automated email from the ASF dual-hosted git repository.
seanyinx pushed a commit to branch SCB-212_tx_timeout
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
The following commit(s) were added to refs/heads/SCB-212_tx_timeout by this push:
new f5e6e48 SCB-212 better readability
f5e6e48 is described below
commit f5e6e488646394a768437c269e64e631b57bbb61
Author: seanyinx <se...@huawei.com>
AuthorDate: Thu Jan 11 14:19:05 2018 +0800
SCB-212 better readability
Signed-off-by: seanyinx <se...@huawei.com>
---
.../omega/transaction/SagaStartAnnotationProcessor.java | 14 +++++---------
.../transaction/SagaStartAnnotationProcessorTest.java | 2 +-
2 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java
index 6e8556b..0aa8fab 100644
--- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java
+++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java
@@ -31,15 +31,13 @@ class SagaStartAnnotationProcessor implements EventAwareInterceptor {
@Override
public void preIntercept(String parentTxId, String compensationMethod, Object... message) {
- String globalTxId = globalTxId();
- // reuse the globalTxId as localTxId to differ localTxId in SagaStartedEvent and the first TxStartedEvent
- sender.send(new SagaStartedEvent(globalTxId, globalTxId));
+ initializeOmegaContext();
+ sender.send(new SagaStartedEvent(omegaContext.globalTxId(), omegaContext.localTxId()));
}
@Override
public void postIntercept(String parentTxId, String compensationMethod) {
- String globalTxId = omegaContext.globalTxId();
- sender.send(new SagaEndedEvent(globalTxId, globalTxId));
+ sender.send(new SagaEndedEvent(omegaContext.globalTxId(), omegaContext.localTxId()));
omegaContext.clear();
}
@@ -50,9 +48,7 @@ class SagaStartAnnotationProcessor implements EventAwareInterceptor {
omegaContext.clear();
}
- private String globalTxId() {
- String globalTxId = omegaContext.newGlobalTxId();
- omegaContext.setLocalTxId(globalTxId);
- return globalTxId;
+ private void initializeOmegaContext() {
+ omegaContext.setLocalTxId(omegaContext.newGlobalTxId());
}
}
diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java
index 8fa3568..e857356 100644
--- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java
+++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java
@@ -70,8 +70,8 @@ public class SagaStartAnnotationProcessorTest {
@Test
public void sendsSagaEndedEvent() {
- context.clear();
context.setGlobalTxId(globalTxId);
+ context.setLocalTxId(globalTxId);
sagaStartAnnotationProcessor.postIntercept(null, null);
--
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].