[
https://issues.apache.org/jira/browse/SCB-856?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16611792#comment-16611792
]
ASF GitHub Bot commented on SCB-856:
------------------------------------
WillemJiang closed pull request #291: SCB-856 Alpha TCC data persistence WIP
URL: https://github.com/apache/incubator-servicecomb-saga/pull/291
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
index d332be20..585f7d9f 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java
@@ -37,6 +37,8 @@
import org.apache.servicecomb.saga.alpha.server.tcc.GrpcTccEventService;
import
org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbackWrapper;
import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccCallbackEngine;
+import org.apache.servicecomb.saga.alpha.server.tcc.TransactionEventService;
+import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
@@ -99,12 +101,31 @@ TxConsistentService txConsistentService(
return consistentService;
}
+ @Bean
+ TransactionEventService transactionEventService(
+ @Value("${alpha.server.storage:rdb}") String storage,
+ @Qualifier("defaultTransactionEventService") TransactionEventService
defaultTransactionEventService,
+ @Qualifier("rdbTransactionEventService") TransactionEventService
rdbTransactionEventService) {
+ return "rdb".equals(storage) ? rdbTransactionEventService :
defaultTransactionEventService;
+ }
+
+ @Bean
+ TccCallbackEngine tccCallbackEngine(TransactionEventService
transactionEventService) {
+ return new TccCallbackEngine(new OmegaCallbackWrapper(),
transactionEventService);
+ }
+
+ @Bean
+ GrpcTccEventService grpcTccEventService(
+ TransactionEventService transactionEventService,
+ TccCallbackEngine tccCallbackEngine) {
+ return new GrpcTccEventService(tccCallbackEngine, transactionEventService);
+ }
+
@Bean
ServerStartable serverStartable(GrpcServerConfig serverConfig,
TxConsistentService txConsistentService,
- Map<String, Map<String, OmegaCallback>> omegaCallbacks) {
+ Map<String, Map<String, OmegaCallback>> omegaCallbacks,
GrpcTccEventService grpcTccEventService) {
ServerStartable bootstrap = new GrpcStartable(serverConfig,
- new GrpcTxEventEndpointImpl(txConsistentService, omegaCallbacks),
- new GrpcTccEventService(new TccCallbackEngine(new
OmegaCallbackWrapper())));
+ new GrpcTxEventEndpointImpl(txConsistentService, omegaCallbacks),
grpcTccEventService);
new Thread(bootstrap::start).start();
return bootstrap;
}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/TransactionEventRegistry.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/DefaultTransactionEventService.java
similarity index 75%
rename from
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/TransactionEventRegistry.java
rename to
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/DefaultTransactionEventService.java
index d135a8b4..6ea6346c 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/TransactionEventRegistry.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/DefaultTransactionEventService.java
@@ -15,32 +15,35 @@
* limitations under the License.
*/
-package org.apache.servicecomb.saga.alpha.server.tcc.registry;
+package org.apache.servicecomb.saga.alpha.server.tcc;
import java.lang.invoke.MethodHandles;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Component;
/**
* Manage TCC transaction event.
*/
-public final class TransactionEventRegistry {
+@Component("defaultTransactionEventService")
+public final class DefaultTransactionEventService implements
TransactionEventService {
private static final Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
- private final static Map<String, Set<ParticipatedEvent>> REGISTRY = new
ConcurrentHashMap<>();
+ private final Map<String, Set<ParticipatedEvent>> REGISTRY = new
ConcurrentHashMap<>();
/**
* Register participate event.
*
* @param participateEvent participate event
*/
- public static void register(ParticipatedEvent participateEvent) {
+ @Override
+ public boolean addEvent(ParticipatedEvent participateEvent) {
REGISTRY
.computeIfAbsent(participateEvent.getGlobalTxId(), key -> new
LinkedHashSet<>())
.add(participateEvent);
@@ -50,6 +53,7 @@ public static void register(ParticipatedEvent
participateEvent) {
participateEvent.getGlobalTxId(), participateEvent.getLocalTxId(),
participateEvent.getParentTxId(),
participateEvent.getConfirmMethod(),
participateEvent.getCancelMethod(), participateEvent.getStatus(),
participateEvent.getServiceName(), participateEvent.getInstanceId());
+ return true;
}
/**
@@ -58,7 +62,12 @@ public static void register(ParticipatedEvent
participateEvent) {
* @param globalTxId global transaction id
* @return participate events
*/
- public static Set<ParticipatedEvent> retrieve(String globalTxId) {
+ @Override
+ public Set<ParticipatedEvent> getEventByGlobalTxId(String globalTxId) {
return REGISTRY.get(globalTxId);
}
+
+ @Override
+ public void migration(String globalTxId, String localTxId) {
+ }
}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/GrpcTccEventService.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/GrpcTccEventService.java
index 0eaf9563..6f248725 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/GrpcTccEventService.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/GrpcTccEventService.java
@@ -21,9 +21,8 @@
import java.lang.invoke.MethodHandles;
import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallback;
import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccCallbackEngine;
-import
org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipateEventFactory;
-import
org.apache.servicecomb.saga.alpha.server.tcc.registry.OmegaCallbacksRegistry;
-import
org.apache.servicecomb.saga.alpha.server.tcc.registry.TransactionEventRegistry;
+import
org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipateEventFactory;
+import
org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcAck;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand;
@@ -48,9 +47,12 @@
private final TccCallbackEngine tccCallbackEngine;
- public GrpcTccEventService(
- TccCallbackEngine tccCallbackEngine) {
+ private final TransactionEventService transactionEventService;
+
+ public GrpcTccEventService(TccCallbackEngine tccCallbackEngine,
+ TransactionEventService transactionEventService) {
this.tccCallbackEngine = tccCallbackEngine;
+ this.transactionEventService = transactionEventService;
}
@Override
@@ -68,8 +70,8 @@ public void
onTccTransactionStarted(GrpcTccTransactionStartedEvent request, Stre
@Override
public void participate(GrpcTccParticipatedEvent request,
StreamObserver<GrpcAck> responseObserver) {
- TransactionEventRegistry.register(ParticipateEventFactory.create(request));
- responseObserver.onNext(ALLOW);
+ boolean ok =
transactionEventService.addEvent(ParticipateEventFactory.create(request));
+ responseObserver.onNext(ok ? ALLOW : REJECT);
responseObserver.onCompleted();
}
@@ -86,6 +88,7 @@ public void onTccCoordinated(GrpcTccCoordinatedEvent request,
StreamObserver<Grp
+ "method: {}, status: {}, service [{}] instanceId [{}]",
request.getGlobalTxId(), request.getLocalTxId(),
request.getParentTxId(),
request.getMethodName(), request.getStatus(),
request.getServiceName(), request.getInstanceId());
+ transactionEventService.migration(request.getGlobalTxId(),
request.getLocalTxId());
responseObserver.onNext(ALLOW);
responseObserver.onCompleted();
}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbTransactionEventService.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbTransactionEventService.java
new file mode 100644
index 00000000..ffaca676
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbTransactionEventService.java
@@ -0,0 +1,84 @@
+/*
+ * 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;
+
+import com.google.common.collect.Sets;
+import java.lang.invoke.MethodHandles;
+import java.util.List;
+import java.util.Optional;
+import java.util.Set;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.FinishedEvent;
+import
org.apache.servicecomb.saga.alpha.server.tcc.jpa.FinishedEventRepository;
+import
org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipateEventRepository;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+@Component("rdbTransactionEventService")
+public class RdbTransactionEventService implements TransactionEventService {
+
+ @Autowired
+ private ParticipateEventRepository participateEventRepository;
+
+ @Autowired
+ private FinishedEventRepository finishedEventRepository;
+
+ private static final Logger LOG =
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @Override
+ public boolean addEvent(ParticipatedEvent event) {
+ try {
+ if (!participateEventRepository.findByGlobalTxIdAndLocalTxId(
+ event.getGlobalTxId(), event.getLocalTxId()).isPresent()) {
+ participateEventRepository.save(event);
+ }
+ } catch (Exception ex) {
+ LOG.warn("add event triggered exception: ", ex);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Set<ParticipatedEvent> getEventByGlobalTxId(String globalTxId) {
+ Optional<List<ParticipatedEvent>> list =
participateEventRepository.findByGlobalTxId(globalTxId);
+ return list.map(Sets::newHashSet).orElseGet(Sets::newHashSet);
+ }
+
+ @Override
+ @Transactional
+ public void migration(String globalTxId, String localTxId) {
+ participateEventRepository.findByGlobalTxIdAndLocalTxId(globalTxId,
localTxId).ifPresent( e -> {
+ participateEventRepository.delete(e.getId());
+ FinishedEvent finishedEvent = new FinishedEvent(
+ e.getGlobalTxId(),
+ e.getLocalTxId(),
+ e.getParentTxId(),
+ e.getServiceName(),
+ e.getInstanceId(),
+ e.getConfirmMethod(),
+ e.getCancelMethod(),
+ e.getStatus()
+ );
+ finishedEventRepository.save(finishedEvent);
+ });
+ }
+}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/TransactionEventService.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/TransactionEventService.java
new file mode 100644
index 00000000..23c84c49
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/TransactionEventService.java
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+import java.util.Set;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
+
+public interface TransactionEventService {
+
+ boolean addEvent(ParticipatedEvent participateEvent);
+
+ Set<ParticipatedEvent> getEventByGlobalTxId(String globalTxId);
+
+ void migration(String globalTxId, String localTxId);
+
+}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/GrpcOmegaTccCallback.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/GrpcOmegaTccCallback.java
index cf8eb8d1..a2cf1352 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/GrpcOmegaTccCallback.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/GrpcOmegaTccCallback.java
@@ -18,8 +18,7 @@
package org.apache.servicecomb.saga.alpha.server.tcc.callback;
import io.grpc.stub.StreamObserver;
-import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallback;
-import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
import org.apache.servicecomb.saga.common.TransactionStatus;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand;
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallback.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallback.java
index 02ae7a69..982bb92f 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallback.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallback.java
@@ -17,7 +17,7 @@
package org.apache.servicecomb.saga.alpha.server.tcc.callback;
-import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
import org.apache.servicecomb.saga.common.TransactionStatus;
public interface OmegaCallback {
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbackWrapper.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbackWrapper.java
index dd98b1a8..fdda5338 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbackWrapper.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbackWrapper.java
@@ -17,8 +17,7 @@
package org.apache.servicecomb.saga.alpha.server.tcc.callback;
-import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
-import
org.apache.servicecomb.saga.alpha.server.tcc.registry.OmegaCallbacksRegistry;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
import org.apache.servicecomb.saga.common.TransactionStatus;
public class OmegaCallbackWrapper implements OmegaCallback {
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/OmegaCallbacksRegistry.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java
similarity index 98%
rename from
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/OmegaCallbacksRegistry.java
rename to
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java
index feb9026d..3b87e7d2 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/registry/OmegaCallbacksRegistry.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.servicecomb.saga.alpha.server.tcc.registry;
+package org.apache.servicecomb.saga.alpha.server.tcc.callback;
import static java.util.Collections.emptyMap;
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java
index bcdca6df..82c5ba66 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java
@@ -18,8 +18,8 @@
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.alpha.server.tcc.jpa.ParticipatedEvent;
+import org.apache.servicecomb.saga.alpha.server.tcc.TransactionEventService;
import org.apache.servicecomb.saga.common.TransactionStatus;
import
org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent;
import org.slf4j.Logger;
@@ -31,14 +31,19 @@
private final OmegaCallbackWrapper omegaCallbackWrapper;
- public TccCallbackEngine(OmegaCallbackWrapper omegaCallbackWrapper) {
+ private final TransactionEventService transactionEventService;
+
+ public TccCallbackEngine(
+ OmegaCallbackWrapper omegaCallbackWrapper,
+ TransactionEventService transactionEventService) {
this.omegaCallbackWrapper = omegaCallbackWrapper;
+ this.transactionEventService = transactionEventService;
}
@Override
public boolean execute(GrpcTccTransactionEndedEvent request) {
boolean result = true;
- for (ParticipatedEvent event :
TransactionEventRegistry.retrieve(request.getGlobalTxId())) {
+ for (ParticipatedEvent event :
transactionEventService.getEventByGlobalTxId(request.getGlobalTxId())) {
try {
omegaCallbackWrapper.invoke(event,
TransactionStatus.valueOf(request.getStatus()));
} catch (Exception ex) {
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipatedEvent.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipatedEvent.java
deleted file mode 100644
index 40270c25..00000000
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipatedEvent.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.event;
-
-import org.apache.servicecomb.saga.common.TransactionStatus;
-
-public class ParticipatedEvent {
-
- private String globalTxId;
- private String localTxId;
- private String parentTxId;
- private String serviceName;
- private String instanceId;
- private String confirmMethod;
- private String cancelMethod;
- private TransactionStatus status;
-
- public ParticipatedEvent(String globalTxId, String localTxId, String
parentTxId, String serviceName,
- String instanceId, String confirmMethod, String cancelMethod,
TransactionStatus status) {
- this.globalTxId = globalTxId;
- this.localTxId = localTxId;
- this.parentTxId = parentTxId;
- this.serviceName = serviceName;
- this.instanceId = instanceId;
- this.confirmMethod = confirmMethod;
- this.cancelMethod = cancelMethod;
- this.status = status;
- }
-
- public String getGlobalTxId() {
- return globalTxId;
- }
-
- public String getLocalTxId() {
- return localTxId;
- }
-
- public String getParentTxId() {
- return parentTxId;
- }
-
- public String getServiceName() {
- return serviceName;
- }
-
- public String getInstanceId() {
- return instanceId;
- }
-
- public String getConfirmMethod() {
- return confirmMethod;
- }
-
- public String getCancelMethod() {
- return cancelMethod;
- }
-
- public TransactionStatus getStatus() {
- return status;
- }
-}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEvent.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEvent.java
new file mode 100644
index 00000000..17c14f10
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEvent.java
@@ -0,0 +1,61 @@
+/*
+ * 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.jpa;
+
+import java.util.Date;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "TccFinishedEvent")
+public class FinishedEvent {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+ private String globalTxId;
+ private String localTxId;
+ private String parentTxId;
+ private String serviceName;
+ private String instanceId;
+ private String confirmMethod;
+ private String cancelMethod;
+ private String status;
+ private Date creationTime;
+ private Date lastModified;
+
+ private FinishedEvent() {
+ }
+
+ public FinishedEvent(String globalTxId, String localTxId, String parentTxId,
String serviceName,
+ String instanceId, String confirmMethod, String cancelMethod, String
status) {
+ this.globalTxId = globalTxId;
+ this.localTxId = localTxId;
+ this.parentTxId = parentTxId;
+ this.serviceName = serviceName;
+ this.instanceId = instanceId;
+ this.confirmMethod = confirmMethod;
+ this.cancelMethod = cancelMethod;
+ this.status = status;
+ this.creationTime = new Date();
+ this.lastModified = new Date();
+ }
+}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEventRepository.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEventRepository.java
new file mode 100644
index 00000000..f4370765
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/FinishedEventRepository.java
@@ -0,0 +1,23 @@
+/*
+ * 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.jpa;
+
+import org.springframework.data.repository.CrudRepository;
+
+public interface FinishedEventRepository extends CrudRepository<FinishedEvent,
Long> {
+}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipateEventFactory.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventFactory.java
similarity index 62%
rename from
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipateEventFactory.java
rename to
alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventFactory.java
index 7964be5e..8a41521f 100644
---
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/event/ParticipateEventFactory.java
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventFactory.java
@@ -6,18 +6,17 @@
* (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
+ * 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.
+ * 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.event;
+package org.apache.servicecomb.saga.alpha.server.tcc.jpa;
-import org.apache.servicecomb.saga.common.TransactionStatus;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent;
public class ParticipateEventFactory {
@@ -31,7 +30,7 @@ public static ParticipatedEvent
create(GrpcTccParticipatedEvent request) {
request.getInstanceId(),
request.getConfirmMethod(),
request.getCancelMethod(),
- TransactionStatus.valueOf(request.getStatus())
+ request.getStatus()
);
}
}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventRepository.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventRepository.java
new file mode 100644
index 00000000..ebe546c8
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipateEventRepository.java
@@ -0,0 +1,32 @@
+/*
+ * 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.jpa;
+
+import java.util.List;
+import java.util.Optional;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.CrudRepository;
+
+public interface ParticipateEventRepository extends
CrudRepository<ParticipatedEvent, Long> {
+
+ @Query(value = "SELECT t FROM ParticipatedEvent AS t WHERE t.globalTxId =
?1")
+ Optional<List<ParticipatedEvent>> findByGlobalTxId(String globalTxId);
+
+ @Query(value = "SELECT t FROM ParticipatedEvent AS t WHERE t.globalTxId = ?1
and t.localTxId = ?2")
+ Optional<ParticipatedEvent> findByGlobalTxIdAndLocalTxId(String globalTxId,
String localTxId);
+}
diff --git
a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEvent.java
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEvent.java
new file mode 100644
index 00000000..ac4a8ea4
--- /dev/null
+++
b/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEvent.java
@@ -0,0 +1,143 @@
+/*
+ * 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.jpa;
+
+import java.util.Date;
+import java.util.Objects;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+@Entity
+@Table(name = "TccParticipateEvent")
+public class ParticipatedEvent {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long id;
+ private String globalTxId;
+ private String localTxId;
+ private String parentTxId;
+ private String serviceName;
+ private String instanceId;
+ private String confirmMethod;
+ private String cancelMethod;
+ private String status;
+ private Date creationTime;
+ private Date lastModified;
+
+ private ParticipatedEvent() {
+ }
+
+ public ParticipatedEvent(String globalTxId, String localTxId, String
parentTxId, String serviceName,
+ String instanceId, String confirmMethod, String cancelMethod, String
status) {
+ this.globalTxId = globalTxId;
+ this.localTxId = localTxId;
+ this.parentTxId = parentTxId;
+ this.serviceName = serviceName;
+ this.instanceId = instanceId;
+ this.confirmMethod = confirmMethod;
+ this.cancelMethod = cancelMethod;
+ this.status = status;
+ this.creationTime = new Date();
+ this.lastModified = new Date();
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getGlobalTxId() {
+ return globalTxId;
+ }
+
+ public String getLocalTxId() {
+ return localTxId;
+ }
+
+ public String getParentTxId() {
+ return parentTxId;
+ }
+
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ public String getInstanceId() {
+ return instanceId;
+ }
+
+ public String getConfirmMethod() {
+ return confirmMethod;
+ }
+
+ public String getCancelMethod() {
+ return cancelMethod;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public Date getCreationTime() {
+ return creationTime;
+ }
+
+ public void setCreationTime(Date creationTime) {
+ this.creationTime = creationTime;
+ }
+
+ public Date getLastModified() {
+ return lastModified;
+ }
+
+ public void setLastModified(Date lastModified) {
+ this.lastModified = lastModified;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ParticipatedEvent that = (ParticipatedEvent) o;
+ return Objects.equals(globalTxId, that.globalTxId) &&
+ Objects.equals(localTxId, that.localTxId) &&
+ Objects.equals(parentTxId, that.parentTxId) &&
+ Objects.equals(serviceName, that.serviceName) &&
+ Objects.equals(instanceId, that.instanceId) &&
+ Objects.equals(confirmMethod, that.confirmMethod) &&
+ Objects.equals(cancelMethod, that.cancelMethod) &&
+ Objects.equals(status, that.status);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects
+ .hash(globalTxId, localTxId, parentTxId, serviceName, instanceId,
confirmMethod, cancelMethod, status);
+ }
+}
diff --git a/alpha/alpha-server/src/main/resources/schema-mysql.sql
b/alpha/alpha-server/src/main/resources/schema-mysql.sql
index 85522a7a..d28a16b2 100644
--- a/alpha/alpha-server/src/main/resources/schema-mysql.sql
+++ b/alpha/alpha-server/src/main/resources/schema-mysql.sql
@@ -66,3 +66,35 @@ CREATE TABLE IF NOT EXISTS TxTimeout (
PRIMARY KEY (surrogateId),
INDEX saga_timeouts_index (surrogateId, expiryTime, globalTxId, localTxId,
status)
) DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS TccParticipateEvent (
+ id bigint NOT NULL AUTO_INCREMENT,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ lastModified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (id),
+ UNIQUE INDEX tcc_participate_event_index (globalTxId, localTxId, parentTxId)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
+CREATE TABLE IF NOT EXISTS TccFinishedEvent (
+ id bigint NOT NULL AUTO_INCREMENT,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ lastModified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ PRIMARY KEY (id),
+ UNIQUE INDEX tcc_finished_event_index (globalTxId, localTxId, parentTxId)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
diff --git a/alpha/alpha-server/src/main/resources/schema-postgresql.sql
b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
index bf8244b4..07c2b9f2 100644
--- a/alpha/alpha-server/src/main/resources/schema-postgresql.sql
+++ b/alpha/alpha-server/src/main/resources/schema-postgresql.sql
@@ -68,3 +68,35 @@ CREATE TABLE IF NOT EXISTS TxTimeout (
);
CREATE INDEX IF NOT EXISTS saga_timeouts_index ON TxTimeout (surrogateId,
expiryTime, globalTxId, localTxId, status);
+
+CREATE TABLE IF NOT EXISTS TccParticipateEvent (
+ id BIGSERIAL PRIMARY KEY,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ lastModified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX IF NOT EXISTS tcc_participate_event_index ON
TccParticipateEvent (globalTxId, localTxId, parentTxId);
+
+CREATE TABLE IF NOT EXISTS TccFinishedEvent (
+ id BIGSERIAL PRIMARY KEY,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ lastModified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
+);
+
+CREATE UNIQUE INDEX IF NOT EXISTS tcc_finished_event_index ON TccFinishedEvent
(globalTxId, localTxId, parentTxId);
diff --git
a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/AlphaTccServerTest.java
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/AlphaTccServerTest.java
index 68597145..5d32513b 100644
---
a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/AlphaTccServerTest.java
+++
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/AlphaTccServerTest.java
@@ -31,10 +31,9 @@
import java.util.concurrent.ConcurrentLinkedQueue;
import org.apache.servicecomb.saga.alpha.server.AlphaApplication;
import
org.apache.servicecomb.saga.alpha.server.tcc.callback.GrpcOmegaTccCallback;
-import org.apache.servicecomb.saga.alpha.server.tcc.event.ParticipatedEvent;
-import
org.apache.servicecomb.saga.alpha.server.tcc.registry.OmegaCallbacksRegistry;
-import
org.apache.servicecomb.saga.alpha.server.tcc.registry.TransactionEventRegistry;
-import org.apache.servicecomb.saga.common.TransactionStatus;
+import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent;
+import
org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry;
+import org.apache.servicecomb.saga.alpha.server.tcc.TransactionEventService;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcAck;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig;
import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand;
@@ -50,6 +49,7 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -58,10 +58,15 @@
properties = {
"alpha.server.host=0.0.0.0",
"alpha.server.port=8090"
+// "spring.profiles.active=mysql",
+//
"spring.datasource.url=jdbc:mysql://localhost:3306/saga?useSSL=false",
+// "spring.datasource.username=root",
+// "spring.datasource.password="
})
public class AlphaTccServerTest {
private static final int port = 8090;
+
protected static ManagedChannel clientChannel;
private final TccEventServiceStub asyncStub =
TccEventServiceGrpc.newStub(clientChannel);
@@ -88,6 +93,9 @@
.setInstanceId(instanceId)
.build();
+ @Autowired
+ private TransactionEventService transactionEventService;
+
@BeforeClass
public static void setupClientChannel() {
clientChannel = NettyChannelBuilder.forAddress("localhost",
port).usePlaintext().build();
@@ -133,15 +141,16 @@ public void assertOnParticipated() {
asyncStub.onConnected(serviceConfig, commandStreamObserver);
awaitUntilConnected();
blockingStub.participate(newParticipatedEvent("Succeed"));
- assertThat(TransactionEventRegistry.retrieve(globalTxId).size(), is(1));
- ParticipatedEvent event =
TransactionEventRegistry.retrieve(globalTxId).iterator().next();
+ blockingStub.participate(newParticipatedEvent("Succeed"));
+
assertThat(transactionEventService.getEventByGlobalTxId(globalTxId).size(),
is(1));
+ ParticipatedEvent event =
transactionEventService.getEventByGlobalTxId(globalTxId).iterator().next();
assertThat(event.getGlobalTxId(), is(globalTxId));
assertThat(event.getLocalTxId(), is(localTxId));
assertThat(event.getInstanceId(), is(instanceId));
assertThat(event.getServiceName(), is(serviceName));
assertThat(event.getConfirmMethod(), is(confirmMethod));
assertThat(event.getCancelMethod(), is(cancelMethod));
- assertThat(event.getStatus(), is(TransactionStatus.Succeed));
+ assertThat(event.getStatus(), is("Succeed"));
}
@Test
@@ -271,7 +280,6 @@ private GrpcTccCoordinatedEvent newCoordinatedEvent(String
status, String method
.build();
}
-
private GrpcAck onReceivedCoordinateCommand(GrpcTccCoordinateCommand
command) {
return GrpcAck.newBuilder().setAborted(false).build();
}
diff --git
a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/MemoryAlphaTccServerTest.java
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/MemoryAlphaTccServerTest.java
new file mode 100644
index 00000000..49ab0eb2
--- /dev/null
+++
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/MemoryAlphaTccServerTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.tcc.server;
+
+import org.apache.servicecomb.saga.alpha.server.AlphaApplication;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {AlphaApplication.class},
+ properties = {
+ "alpha.server.host=0.0.0.0",
+ "alpha.server.port=8090",
+ "alpha.server.storage=local"
+ })
+public class MemoryAlphaTccServerTest extends AlphaTccServerTest{
+
+}
diff --git
a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/RdbAlphaTccServerTest.java
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/RdbAlphaTccServerTest.java
new file mode 100644
index 00000000..25f1b8d8
--- /dev/null
+++
b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/tcc/server/RdbAlphaTccServerTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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.tcc.server;
+
+import org.apache.servicecomb.saga.alpha.server.AlphaApplication;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {AlphaApplication.class},
+ properties = {
+ "alpha.server.host=0.0.0.0",
+ "alpha.server.port=8090",
+ "alpha.server.storage=rdb"
+ })
+public class RdbAlphaTccServerTest extends AlphaTccServerTest{
+}
diff --git a/alpha/alpha-server/src/test/resources/schema.sql
b/alpha/alpha-server/src/test/resources/schema.sql
index 0da26860..b464de1d 100644
--- a/alpha/alpha-server/src/test/resources/schema.sql
+++ b/alpha/alpha-server/src/test/resources/schema.sql
@@ -59,3 +59,31 @@ CREATE TABLE IF NOT EXISTS TxTimeout (
status varchar(12),
version bigint NOT NULL
);
+
+CREATE TABLE IF NOT EXISTS TccParticipateEvent (
+ id bigint GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1)
PRIMARY KEY,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
+);
+
+CREATE TABLE IF NOT EXISTS TccFinishedEvent (
+ id bigint GENERATED BY DEFAULT AS IDENTITY(START WITH 1, INCREMENT BY 1)
PRIMARY KEY,
+ serviceName varchar(36) NOT NULL,
+ instanceId varchar(36) NOT NULL,
+ globalTxId varchar(36) NOT NULL,
+ localTxId varchar(36) NOT NULL,
+ parentTxId varchar(36) DEFAULT NULL,
+ confirmMethod varchar(256) NOT NULL,
+ cancelMethod varchar(256) NOT NULL,
+ status varchar(50) NOT NULL,
+ creationTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
+ lastModified TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
+);
----------------------------------------------------------------
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:
[email protected]
> Implement reaction of the event in Alpha Server
> ------------------------------------------------
>
> Key: SCB-856
> URL: https://issues.apache.org/jira/browse/SCB-856
> Project: Apache ServiceComb
> Issue Type: Sub-task
> Components: Saga
> Reporter: Willem Jiang
> Assignee: cherrylzhao
> Priority: Major
> Fix For: saga-0.3.0
>
>
> Alpha Server create a tracker when the TransactionStartEvent is received,
> and record the register of other participate once the participate event is
> received.
> When AlphaServer received the TransactionEndEvent, it sends the
> CoordinateCommand to the participant client with cancel or confirmation
> message type.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)