You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2017/12/28 06:11:54 UTC

[GitHub] WillemJiang commented on a change in pull request #92: SCB-140 compensated only distinct events

WillemJiang commented on a change in pull request #92: SCB-140 compensated only distinct events
URL: https://github.com/apache/incubator-servicecomb-saga/pull/92#discussion_r158901227
 
 

 ##########
 File path: omega/omega-context/src/main/java/io/servicecomb/saga/omega/context/OmegaContext.java
 ##########
 @@ -73,26 +78,27 @@ public void setParentTxId(String parentTxId) {
   }
 
   // TODO: 2017/12/23 remove this context entry by the end of its corresponding global tx
-  public void addContext(String id, Object target, String compensationMethod, Object... args) {
-    compensationContexts.put(id, new CompensationContext(target, compensationMethod, args));
+  public void addContext(String globalTxId, String localTxId, Object target, String compensationMethod, Object... args) {
+    compensationContexts.computeIfAbsent(globalTxId, k -> new ConcurrentHashMap<>())
+        .put(localTxId, new CompensationContext(target, compensationMethod, args));
   }
 
   public boolean containsContext(String globalTxId) {
     return compensationContexts.containsKey(globalTxId);
   }
 
   public void compensate(String globalTxId) {
-    CompensationContext compensationContext = compensationContexts.get(globalTxId);
-
-    try {
-      invokeMethod(compensationContext);
-    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
-      throw new IllegalStateException(
-          "Pre-checking for compensate method " + compensationContext.compensationMethod
-              + " was somehow skipped, did you forget to configure compensable method checking on service startup?",
-          e);
-    } finally {
-      compensationContexts.remove(globalTxId);
+    Map<String, CompensationContext> contexts = compensationContexts.remove(globalTxId);
 
 Review comment:
   If the process is crashed this time,  we will lose all the compensation contexts.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services