You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/01/13 14:58:06 UTC
[incubator-servicecomb-saga] 15/15: 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.
ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-saga.git
commit 160badefe6896cb9fa3bd52c615ad3ab499ade81
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>.