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 13:46:58 UTC
[incubator-servicecomb-saga] branch SCB-212_tx_timeout updated:
SCB-212 replaced completable future with executor to avoid test failures in
maven
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 870264a SCB-212 replaced completable future with executor to avoid test failures in maven
870264a is described below
commit 870264a301624917140dfc36c3d59cd89d530de7
Author: seanyinx <se...@huawei.com>
AuthorDate: Thu Jan 11 21:46:22 2018 +0800
SCB-212 replaced completable future with executor to avoid test failures in maven
Signed-off-by: seanyinx <se...@huawei.com>
---
.../apache/servicecomb/saga/alpha/core/TxConsistentService.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxConsistentService.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxConsistentService.java
index 87cdc60..55de6b7 100644
--- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxConsistentService.java
+++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxConsistentService.java
@@ -28,9 +28,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.function.Consumer;
public class TxConsistentService {
@@ -46,6 +47,7 @@ public class TxConsistentService {
}};
private final Map<String, Set<String>> eventsToCompensate = new ConcurrentHashMap<>();
+ private final ExecutorService executor = Executors.newSingleThreadExecutor();
public TxConsistentService(TxEventRepository eventRepository, OmegaCallback omegaCallback) {
this.eventRepository = eventRepository;
@@ -55,7 +57,7 @@ public class TxConsistentService {
public void handle(TxEvent event) {
eventRepository.save(event);
- CompletableFuture.runAsync(() -> {
+ executor.execute(() -> {
if (isTxEndedEvent(event) && isGlobalTxAborted(event)) {
omegaCallback.compensate(event);
}
@@ -66,12 +68,12 @@ public class TxConsistentService {
private void compensate(TxEvent event) {
List<TxEvent> events = eventRepository.findTransactions(event.globalTxId(), TxStartedEvent.name());
- events.forEach(omegaCallback::compensate);
eventsToCompensate.computeIfAbsent(event.globalTxId(), (v) -> {
Set<String> eventSet = new ConcurrentSkipListSet<>();
events.forEach(e -> eventSet.add(e.localTxId()));
return eventSet;
});
+ events.forEach(omegaCallback::compensate);
}
private void updateCompensateStatus(TxEvent event) {
--
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].