You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/08/28 02:15:21 UTC

[GitHub] cherrylzhao commented on a change in pull request #268: SCB-856 Implement reaction of the event in Alpha Server

cherrylzhao commented on a change in pull request #268: SCB-856 Implement reaction of the event in Alpha Server
URL: https://github.com/apache/incubator-servicecomb-saga/pull/268#discussion_r213167306
 
 

 ##########
 File path: alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java
 ##########
 @@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.servicecomb.saga.alpha.server.tcc.callback;
+
+import java.lang.invoke.MethodHandles;
+import org.apache.servicecomb.saga.alpha.server.tcc.registry.TransactionEventRegistry;
+import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
+import org.apache.servicecomb.saga.common.TransactionStatus;
+import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TccCallbackEngine implements CallbackEngine {
+
+  private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  private final OmegaCallbackWrapper omegaCallbackWrapper;
+
+  public TccCallbackEngine(OmegaCallbackWrapper omegaCallbackWrapper) {
+    this.omegaCallbackWrapper = omegaCallbackWrapper;
+  }
+
+  @Override
+  public boolean execute(GrpcTccTransactionEndedEvent request) {
+    boolean result = true;
+    for (ParticipatedEvent event : TransactionEventRegistry.retrieve(request.getGlobalTxId())) {
+      try {
+        omegaCallbackWrapper.invoke(event, TransactionStatus.valueOf(request.getStatus()));
+      } catch (Exception ex) {
+        logError(event, ex);
+        result = false;
 
 Review comment:
   result was returned in GrpcOmegaTccCallback, please check it.

----------------------------------------------------------------
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