[ https://issues.apache.org/jira/browse/SCB-232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16326120#comment-16326120 ]
ASF GitHub Bot commented on SCB-232: ------------------------------------ seanyinx closed pull request #118: SCB-232 EventType should be same between omega and alpha URL: https://github.com/apache/incubator-servicecomb-saga/pull/118 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-core/pom.xml b/alpha/alpha-core/pom.xml index 2fee5ab7..4a6c1b01 100644 --- a/alpha/alpha-core/pom.xml +++ b/alpha/alpha-core/pom.xml @@ -30,6 +30,10 @@ <name>Saga::Alpha::Core</name> <dependencies> + <dependency> + <groupId>org.apache.servicecomb.saga</groupId> + <artifactId>pack-common</artifactId> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> 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 55de6b7d..bddba36d 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 @@ -17,11 +17,11 @@ package org.apache.servicecomb.saga.alpha.core; -import static org.apache.servicecomb.saga.alpha.core.EventType.SagaEndedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxAbortedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxCompensatedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxEndedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxStartedEvent; +import static org.apache.servicecomb.saga.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; import java.util.Date; import java.util.HashMap; diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java index fd380613..5cda4c54 100644 --- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java +++ b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java @@ -19,7 +19,7 @@ import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxStartedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -33,6 +33,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import org.apache.servicecomb.saga.common.EventType; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java index febbfaf3..a44f16da 100644 --- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java +++ b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java @@ -19,12 +19,12 @@ import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.servicecomb.saga.alpha.core.EventType.SagaEndedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.SagaStartedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxAbortedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxCompensatedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxEndedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxStartedEvent; +import static org.apache.servicecomb.saga.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.saga.common.EventType.SagaStartedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -39,6 +39,7 @@ import java.util.UUID; import java.util.stream.Collectors; +import org.apache.servicecomb.saga.common.EventType; import org.junit.Test; public class TxConsistentServiceTest { diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxEventMaker.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxEventMaker.java index 21a08677..68c33a91 100644 --- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxEventMaker.java +++ b/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxEventMaker.java @@ -15,7 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core;import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; +package org.apache.servicecomb.saga.alpha.core; + +import org.apache.servicecomb.saga.common.EventType; + +import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import java.util.Date; import java.util.UUID; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java index 9f13a8f7..a501f759 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java @@ -19,9 +19,9 @@ import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxAbortedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxEndedEvent; -import static org.apache.servicecomb.saga.alpha.core.EventType.TxStartedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.notNullValue; @@ -34,7 +34,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.servicecomb.saga.alpha.core.EventType; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.alpha.core.OmegaCallback; import org.apache.servicecomb.saga.alpha.core.TxConsistentService; import org.apache.servicecomb.saga.alpha.core.TxEvent; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java index d5f432fb..1fdfd2e7 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalancedClusterMessageSenderTest.java @@ -39,6 +39,7 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.ServiceConfig; import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; import org.apache.servicecomb.saga.omega.transaction.MessageHandler; @@ -94,7 +95,7 @@ private final String localTxId = uniquify("localTxId"); private final String parentTxId = uniquify("parentTxId"); private final String compensationMethod = getClass().getCanonicalName(); - private final TxEvent event = new TxEvent(TxEvent.EventType.TxStartedEvent, globalTxId, localTxId, parentTxId, compensationMethod, "blah"); + private final TxEvent event = new TxEvent(EventType.TxStartedEvent, globalTxId, localTxId, parentTxId, compensationMethod, "blah"); private final String serviceName = uniquify("serviceName"); private final String[] addresses = {"localhost:8080", "localhost:8090"}; @@ -324,7 +325,7 @@ public void onConnected(GrpcServiceConfig request, StreamObserver<GrpcCompensate @Override public void onTxEvent(GrpcTxEvent request, StreamObserver<GrpcAck> responseObserver) { events.offer(new TxEvent( - TxEvent.EventType.valueOf(request.getType()), + EventType.valueOf(request.getType()), request.getGlobalTxId(), request.getLocalTxId(), request.getParentTxId(), @@ -333,7 +334,7 @@ public void onTxEvent(GrpcTxEvent request, StreamObserver<GrpcAck> responseObser sleep(); - if (TxEvent.EventType.TxAbortedEvent.name().equals(request.getType())) { + if (EventType.TxAbortedEvent.name().equals(request.getType())) { this.responseObserver.onNext(GrpcCompensateCommand .newBuilder() .setGlobalTxId(request.getGlobalTxId()) diff --git a/omega/omega-transaction/pom.xml b/omega/omega-transaction/pom.xml index 1aa77fbc..a2bf2932 100644 --- a/omega/omega-transaction/pom.xml +++ b/omega/omega-transaction/pom.xml @@ -30,6 +30,10 @@ <name>Saga::Omega::Transaction</name> <dependencies> + <dependency> + <groupId>org.apache.servicecomb.saga</groupId> + <artifactId>pack-common</artifactId> + </dependency> <dependency> <groupId>org.apache.servicecomb.saga</groupId> <artifactId>omega-context</artifactId> diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaEndedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaEndedEvent.java index 8a0c3ebe..7074d8fd 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaEndedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaEndedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + public class SagaEndedEvent extends TxEvent { public SagaEndedEvent(String globalTxId, String localTxId) { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartedEvent.java index d5bf70c9..54f61e41 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + public class SagaStartedEvent extends TxEvent { public SagaStartedEvent(String globalTxId, String localTxId) { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java index af6ba84b..13df2f73 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + import java.io.PrintWriter; import java.io.StringWriter; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxCompensatedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxCompensatedEvent.java index 089d4a8f..dbbaeab5 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxCompensatedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxCompensatedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + public class TxCompensatedEvent extends TxEvent { public TxCompensatedEvent(String globalTxId, String localTxId, String parentTxId, String compensationMethod) { super(EventType.TxCompensatedEvent, globalTxId, localTxId, parentTxId, compensationMethod); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEndedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEndedEvent.java index d03155a9..4e587c85 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEndedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEndedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + public class TxEndedEvent extends TxEvent { public TxEndedEvent(String globalTxId, String localTxId, String parentTxId, String compensationMethod) { super(EventType.TxEndedEvent, globalTxId, localTxId, parentTxId, compensationMethod); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEvent.java index 58c79c61..1398d3ea 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEvent.java @@ -17,17 +17,11 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + import java.util.Arrays; public class TxEvent { - public enum EventType { - SagaStartedEvent, - SagaEndedEvent, - TxStartedEvent, - TxEndedEvent, - TxAbortedEvent, - TxCompensatedEvent - }; private final long timestamp; private final EventType type; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxStartedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxStartedEvent.java index bd72cd3c..ce93ea3e 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxStartedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxStartedEvent.java @@ -17,6 +17,8 @@ package org.apache.servicecomb.saga.omega.transaction; +import org.apache.servicecomb.saga.common.EventType; + public class TxStartedEvent extends TxEvent { public TxStartedEvent(String globalTxId, String localTxId, String parentTxId, String compensationMethod, Object... payloads) { diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptorTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptorTest.java index a7aa4569..d4bfef67 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptorTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptorTest.java @@ -27,6 +27,7 @@ import java.util.List; import java.util.UUID; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.IdGenerator; import org.apache.servicecomb.saga.omega.context.OmegaContext; import org.junit.Before; @@ -65,7 +66,7 @@ public void sendsTxStartedEventBefore() throws Exception { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(localTxId)); assertThat(event.parentTxId(), is(parentTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxStartedEvent)); + assertThat(event.type(), is(EventType.TxStartedEvent)); assertThat(event.compensationMethod(), is(compensationMethod)); assertThat(asList(event.payloads()), contains(message)); } @@ -79,7 +80,7 @@ public void sendsTxEndedEventAfter() throws Exception { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(localTxId)); assertThat(event.parentTxId(), is(parentTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxEndedEvent)); + assertThat(event.type(), is(EventType.TxEndedEvent)); assertThat(event.compensationMethod(), is(compensationMethod)); assertThat(event.payloads().length, is(0)); } @@ -93,7 +94,7 @@ public void sendsTxAbortedEventOnError() throws Exception { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(localTxId)); assertThat(event.parentTxId(), is(parentTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxAbortedEvent)); + assertThat(event.type(), is(EventType.TxAbortedEvent)); assertThat(event.compensationMethod(), is(compensationMethod)); } } diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandlerTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandlerTest.java index 08278337..bc126ae7 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandlerTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandlerTest.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.List; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.CompensationContext; import org.junit.Test; @@ -53,7 +54,7 @@ public void sendsEventOnCompensationCompleted() throws Exception { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(localTxId)); assertThat(event.parentTxId(), is(parentTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxCompensatedEvent)); + assertThat(event.type(), is(EventType.TxCompensatedEvent)); assertThat(event.compensationMethod(), is(getClass().getCanonicalName())); assertThat(event.payloads().length, is(0)); diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java index 48399b46..c146f5bf 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.UUID; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.IdGenerator; import org.apache.servicecomb.saga.omega.context.OmegaContext; import org.junit.Before; @@ -65,7 +66,7 @@ public void sendsSagaStartedEvent() { assertThat(event.localTxId(), is(globalTxId)); assertThat(event.parentTxId(), is(nullValue())); assertThat(event.compensationMethod().isEmpty(), is(true)); - assertThat(event.type(), is(TxEvent.EventType.SagaStartedEvent)); + assertThat(event.type(), is(EventType.SagaStartedEvent)); assertThat(event.payloads().length, is(0)); } @@ -79,7 +80,7 @@ public void sendsSagaEndedEvent() { assertThat(event.localTxId(), is(globalTxId)); assertThat(event.parentTxId(), is(nullValue())); assertThat(event.compensationMethod().isEmpty(), is(true)); - assertThat(event.type(), is(TxEvent.EventType.SagaEndedEvent)); + assertThat(event.type(), is(EventType.SagaEndedEvent)); assertThat(event.payloads().length, is(0)); } } diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspectTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspectTest.java index 23703256..6d2e1a6d 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspectTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspectTest.java @@ -33,6 +33,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.IdGenerator; import org.apache.servicecomb.saga.omega.context.OmegaContext; import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; @@ -77,14 +78,14 @@ public void newGlobalTxIdInSagaStart() throws Throwable { assertThat(startedEvent.globalTxId(), is(globalTxId)); assertThat(startedEvent.localTxId(), is(globalTxId)); assertThat(startedEvent.parentTxId(), is(nullValue())); - assertThat(startedEvent.type(), is(TxEvent.EventType.SagaStartedEvent)); + assertThat(startedEvent.type(), is(EventType.SagaStartedEvent)); TxEvent endedEvent = messages.get(1); assertThat(endedEvent.globalTxId(), is(globalTxId)); assertThat(endedEvent.localTxId(), is(globalTxId)); assertThat(endedEvent.parentTxId(), is(nullValue())); - assertThat(endedEvent.type(), is(TxEvent.EventType.SagaEndedEvent)); + assertThat(endedEvent.type(), is(EventType.SagaEndedEvent)); assertThat(omegaContext.globalTxId(), is(nullValue())); assertThat(omegaContext.localTxId(), is(nullValue())); @@ -109,7 +110,7 @@ public void clearContextOnSagaStartError() throws Throwable { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(globalTxId)); assertThat(event.parentTxId(), is(nullValue())); - assertThat(event.type(), is(TxEvent.EventType.SagaStartedEvent)); + assertThat(event.type(), is(EventType.SagaStartedEvent)); assertThat(omegaContext.globalTxId(), is(nullValue())); assertThat(omegaContext.localTxId(), is(nullValue())); @@ -140,7 +141,7 @@ public void sendsAbortEventOnTimeout() throws Throwable { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(globalTxId)); assertThat(event.parentTxId(), is(nullValue())); - assertThat(event.type(), is(TxEvent.EventType.TxAbortedEvent)); + assertThat(event.type(), is(EventType.TxAbortedEvent)); latch.countDown(); diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspectTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspectTest.java index 2d92d0f0..63cdff06 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspectTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspectTest.java @@ -32,6 +32,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import org.apache.servicecomb.saga.common.EventType; import org.apache.servicecomb.saga.omega.context.IdGenerator; import org.apache.servicecomb.saga.omega.context.OmegaContext; import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; @@ -83,14 +84,14 @@ public void newLocalTxIdInCompensable() throws Throwable { assertThat(startedEvent.globalTxId(), is(globalTxId)); assertThat(startedEvent.localTxId(), is(newLocalTxId)); assertThat(startedEvent.parentTxId(), is(localTxId)); - assertThat(startedEvent.type(), is(TxEvent.EventType.TxStartedEvent)); + assertThat(startedEvent.type(), is(EventType.TxStartedEvent)); TxEvent endedEvent = messages.get(1); assertThat(endedEvent.globalTxId(), is(globalTxId)); assertThat(endedEvent.localTxId(), is(newLocalTxId)); assertThat(endedEvent.parentTxId(), is(localTxId)); - assertThat(endedEvent.type(), is(TxEvent.EventType.TxEndedEvent)); + assertThat(endedEvent.type(), is(EventType.TxEndedEvent)); assertThat(omegaContext.globalTxId(), is(globalTxId)); assertThat(omegaContext.localTxId(), is(localTxId)); @@ -114,7 +115,7 @@ public void restoreContextOnCompensableError() throws Throwable { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(newLocalTxId)); assertThat(event.parentTxId(), is(localTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxAbortedEvent)); + assertThat(event.type(), is(EventType.TxAbortedEvent)); assertThat(omegaContext.globalTxId(), is(globalTxId)); assertThat(omegaContext.localTxId(), is(localTxId)); @@ -149,7 +150,7 @@ public void sendsAbortEventOnTimeout() throws Throwable { assertThat(event.globalTxId(), is(globalTxId)); assertThat(event.localTxId(), is(newLocalTxId)); assertThat(event.parentTxId(), is(localTxId)); - assertThat(event.type(), is(TxEvent.EventType.TxAbortedEvent)); + assertThat(event.type(), is(EventType.TxAbortedEvent)); latch.countDown(); diff --git a/pack-common/pom.xml b/pack-common/pom.xml new file mode 100644 index 00000000..0fa64392 --- /dev/null +++ b/pack-common/pom.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>saga</artifactId> + <groupId>org.apache.servicecomb.saga</groupId> + <version>0.0.3-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>pack-common</artifactId> + <name>Saga::Pack Common</name> + +</project> diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventType.java b/pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java similarity index 95% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventType.java rename to pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java index 34062942..d7743d90 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventType.java +++ b/pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.saga.common; public enum EventType { SagaStartedEvent, diff --git a/pom.xml b/pom.xml index c3919b66..1d41a456 100755 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,7 @@ <module>omega</module> <module>alpha</module> <module>pack-contracts</module> + <module>pack-common</module> <module>integration-tests</module> </modules> @@ -201,6 +202,11 @@ <artifactId>pack-contract-grpc</artifactId> <version>0.0.3-SNAPSHOT</version> </dependency> + <dependency> + <groupId>org.apache.servicecomb.saga</groupId> + <artifactId>pack-common</artifactId> + <version>0.0.3-SNAPSHOT</version> + </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> ---------------------------------------------------------------- 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: us...@infra.apache.org > EventType should be same between omega and alpha > ------------------------------------------------ > > Key: SCB-232 > URL: https://issues.apache.org/jira/browse/SCB-232 > Project: Apache ServiceComb > Issue Type: Improvement > Components: Saga > Reporter: Zheng Feng > Assignee: Zheng Feng > Priority: Major > Fix For: saga-0.3.0 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)