diff --git a/acceptance-tests/acceptance-pack-dubbo-demo/pom.xml b/acceptance-tests/acceptance-pack-dubbo-demo/pom.xml index b64a0bad2..f256fe32e 100644 --- a/acceptance-tests/acceptance-pack-dubbo-demo/pom.xml +++ b/acceptance-tests/acceptance-pack-dubbo-demo/pom.xml @@ -21,11 +21,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> acceptance-tests - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - Saga:Acceptance Tests::Pack::Dubbo + Pack:Acceptance Tests::Dubbo acceptance-pack-dubbo diff --git a/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/DubboDemoStepdefs.java b/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/DubboDemoStepdefs.java similarity index 99% rename from acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/DubboDemoStepdefs.java rename to acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/DubboDemoStepdefs.java index af7b04471..810073f4a 100644 --- a/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/DubboDemoStepdefs.java +++ b/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/DubboDemoStepdefs.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.acceptance.dubbodemo; +package org.apache.servicecomb.pack.acceptance.dubbodemo; import static io.restassured.RestAssured.given; import static java.util.concurrent.TimeUnit.SECONDS; diff --git a/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/RunCucumberIT.java b/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/RunCucumberIT.java similarity index 94% rename from acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/RunCucumberIT.java rename to acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/RunCucumberIT.java index cab33beb2..d1131b7fb 100644 --- a/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/saga/acceptance/dubbodemo/RunCucumberIT.java +++ b/acceptance-tests/acceptance-pack-dubbo-demo/src/test/java/org/apache/servicecomb/pack/acceptance/dubbodemo/RunCucumberIT.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.acceptance.dubbodemo; +package org.apache.servicecomb.pack.acceptance.dubbodemo; import org.junit.runner.RunWith; diff --git a/acceptance-tests/acceptance-pack-spring-demo/pom.xml b/acceptance-tests/acceptance-pack-spring-demo/pom.xml index 87bfe9abc..e81aab993 100644 --- a/acceptance-tests/acceptance-pack-spring-demo/pom.xml +++ b/acceptance-tests/acceptance-pack-spring-demo/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> acceptance-tests - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 acceptance-pack-spring - Saga:Acceptance Tests::Pack::Spring + Pack:Acceptance Tests::Spring diff --git a/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java b/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java similarity index 99% rename from acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java rename to acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java index fd84819a5..711edd2d4 100644 --- a/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java +++ b/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga; +package org.apache.servicecomb.pack; import static io.restassured.RestAssured.given; import static java.util.concurrent.TimeUnit.SECONDS; diff --git a/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java b/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java similarity index 96% rename from acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java rename to acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java index d4fc9ee3c..c8415cee8 100644 --- a/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java +++ b/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga; +package org.apache.servicecomb.pack; import org.junit.runner.RunWith; diff --git a/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_exception.btm b/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_exception.btm index 074bb4689..5afea45b7 100644 --- a/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_exception.btm +++ b/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_exception.btm @@ -19,7 +19,7 @@ ############################################################### RULE throw exception -CLASS org.apache.servicecomb.saga.demo.pack.booking.BookingController +CLASS org.apache.servicecomb.pack.demo.booking.BookingController METHOD postCarBooking AT ENTRY IF TRUE diff --git a/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_timeout.btm b/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_timeout.btm index 2deab518c..829e7bae2 100644 --- a/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_timeout.btm +++ b/acceptance-tests/acceptance-pack-spring-demo/src/test/resources/booking_timeout.btm @@ -19,7 +19,7 @@ ############################################################### RULE set the saga timeout to 5s -INTERFACE org.apache.servicecomb.saga.omega.context.annotations.SagaStart +INTERFACE org.apache.servicecomb.pack.omega.context.annotations.SagaStart METHOD timeout AT EXIT IF TRUE @@ -27,7 +27,7 @@ DO RETURN 5 ENDRULE RULE sleep when postBooking until timeout happens -CLASS org.apache.servicecomb.saga.demo.pack.booking.BookingController +CLASS org.apache.servicecomb.pack.demo.booking.BookingController METHOD postBooking AT ENTRY IF TRUE diff --git a/acceptance-tests/acceptance-pack-tcc-spring-demo/pom.xml b/acceptance-tests/acceptance-pack-tcc-spring-demo/pom.xml index 1126e3cac..2503b8abd 100644 --- a/acceptance-tests/acceptance-pack-tcc-spring-demo/pom.xml +++ b/acceptance-tests/acceptance-pack-tcc-spring-demo/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> acceptance-tests - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 acceptance-pack-tcc-spring-demo - Saga:Acceptance Tests::Pack::TCC::Spring + Pack:Acceptance Tests::TCC::Spring diff --git a/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java b/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java similarity index 99% rename from acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java rename to acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java index 7c56eab1c..74493e93f 100644 --- a/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/saga/PackStepdefs.java +++ b/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/PackStepdefs.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga; +package org.apache.servicecomb.pack; import static io.restassured.RestAssured.given; import static java.util.concurrent.TimeUnit.SECONDS; diff --git a/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java b/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java similarity index 96% rename from acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java rename to acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java index d4fc9ee3c..c8415cee8 100644 --- a/acceptance-tests/acceptance-pack-spring-demo/src/test/java/org/apache/servicecomb/saga/RunCucumberIT.java +++ b/acceptance-tests/acceptance-pack-tcc-spring-demo/src/test/java/org/apache/servicecomb/pack/RunCucumberIT.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga; +package org.apache.servicecomb.pack; import org.junit.runner.RunWith; diff --git a/acceptance-tests/pom.xml b/acceptance-tests/pom.xml index d6dc00b25..dd3534a72 100644 --- a/acceptance-tests/pom.xml +++ b/acceptance-tests/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 acceptance-tests - Saga:Acceptance Tests + Pack:Acceptance Tests pom acceptance-pack-dubbo-demo diff --git a/alpha/README.md b/alpha/README.md index 6c63cb243..613aed977 100644 --- a/alpha/README.md +++ b/alpha/README.md @@ -1,7 +1,7 @@ # alpha-server The alpha-server works as the pack leader to keep the consistency of transactions. -For more information, see [saga pack design](https://github.com/apache/servicecomb-saga/blob/master/docs/design.md) +For more information, see [pack design](https://github.com/apache/servicecomb-pack/blob/master/docs/design.md) ## Build and Run diff --git a/alpha/alpha-core/pom.xml b/alpha/alpha-core/pom.xml index 57c631f53..bc154bb5f 100644 --- a/alpha/alpha-core/pom.xml +++ b/alpha/alpha-core/pom.xml @@ -21,17 +21,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> alpha - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 alpha-core - Saga::Alpha::Core + Pack::Alpha::Core - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/AlphaException.java similarity index 95% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/AlphaException.java index a7bb7564f..df91911a5 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/AlphaException.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/AlphaException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; public class AlphaException extends RuntimeException { public AlphaException(String cause) { diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/Command.java similarity index 95% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/Command.java index 6c8f37084..c2890fb32 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/Command.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/Command.java @@ -15,9 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; - -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.NEW; +package org.apache.servicecomb.pack.alpha.core; import java.util.Date; @@ -85,7 +83,7 @@ public Command(long id, String compensationMethod, byte[] payloads) { - this(id, serviceName, instanceId, globalTxId, localTxId, parentTxId, compensationMethod, payloads, NEW.name()); + this(id, serviceName, instanceId, globalTxId, localTxId, parentTxId, compensationMethod, payloads, TaskStatus.NEW.name()); } public Command(TxEvent event) { diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CommandRepository.java similarity index 95% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CommandRepository.java index 2bbea7742..f36932057 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CommandRepository.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CommandRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import java.util.List; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CompositeOmegaCallback.java similarity index 97% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CompositeOmegaCallback.java index 0da3fd4c4..283744ca1 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallback.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/CompositeOmegaCallback.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static java.util.Collections.emptyMap; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/EventScanner.java similarity index 94% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/EventScanner.java index 0a15ad0e2..06e7aa20e 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/EventScanner.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/EventScanner.java @@ -15,14 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.NEW; -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.TxEndedEvent; -import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import java.lang.invoke.MethodHandles; import java.util.List; @@ -235,6 +234,6 @@ private TxTimeout txTimeoutOf(TxEvent event) { event.parentTxId(), event.type(), event.expiryTime(), - NEW.name()); + TaskStatus.NEW.name()); } } diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/OmegaCallback.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/OmegaCallback.java similarity index 94% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/OmegaCallback.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/OmegaCallback.java index f60a44dd8..aab7faa88 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/OmegaCallback.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/OmegaCallback.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; public interface OmegaCallback { void compensate(TxEvent event); diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunner.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunner.java similarity index 97% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunner.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunner.java index aafa42fdc..04d026040 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunner.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunner.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallback.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallback.java similarity index 97% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallback.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallback.java index 9556d7caa..094085557 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallback.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallback.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import java.lang.invoke.MethodHandles; import java.util.concurrent.BlockingQueue; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TaskStatus.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TaskStatus.java similarity index 94% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TaskStatus.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TaskStatus.java index 442213b37..c6617f271 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TaskStatus.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TaskStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; public enum TaskStatus { NEW, 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/pack/alpha/core/TxConsistentService.java similarity index 89% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxConsistentService.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxConsistentService.java index ad084407d..52357ec04 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/pack/alpha/core/TxConsistentService.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; -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.TxStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import java.lang.invoke.MethodHandles; import java.util.Arrays; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEvent.java similarity index 99% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEvent.java index 17b059ce1..9d672590f 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEvent.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEvent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static java.util.concurrent.TimeUnit.SECONDS; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEventRepository.java similarity index 97% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEventRepository.java index f2cccca76..a6e3b9b92 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxEventRepository.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxEventRepository.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; /** * Repository for {@link TxEvent} diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeout.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeout.java similarity index 98% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeout.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeout.java index 342321fd5..62b0f4820 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeout.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeout.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import java.util.Date; diff --git a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeoutRepository.java b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeoutRepository.java similarity index 95% rename from alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeoutRepository.java rename to alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeoutRepository.java index 97387a363..a7fc88d0e 100644 --- a/alpha/alpha-core/src/main/java/org/apache/servicecomb/saga/alpha/core/TxTimeoutRepository.java +++ b/alpha/alpha-core/src/main/java/org/apache/servicecomb/pack/alpha/core/TxTimeoutRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import java.util.List; 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/pack/alpha/core/CompositeOmegaCallbackTest.java similarity index 87% rename from alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/CompositeOmegaCallbackTest.java rename to alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/CompositeOmegaCallbackTest.java index 4ded48af2..c183dde5a 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/pack/alpha/core/CompositeOmegaCallbackTest.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -32,7 +32,8 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -78,8 +79,8 @@ public void compensateCorrespondingOmegaInstanceOnly() throws Exception { verify(callback2One).compensate(event); verify(callback2Two, never()).compensate(event); - assertThat(callbacks.get(serviceName1).values(), containsInAnyOrder(callback1One, callback1Two)); - assertThat(callbacks.get(serviceName2).values(), containsInAnyOrder(callback2One, callback2Two)); + assertThat(callbacks.get(serviceName1).values(), Matchers.containsInAnyOrder(callback1One, callback1Two)); + assertThat(callbacks.get(serviceName2).values(), Matchers.containsInAnyOrder(callback2One, callback2Two)); } @Test @@ -94,7 +95,7 @@ public void compensateOtherOmegaInstance_IfTheRequestedIsUnreachable() throws Ex verify(callback2One, never()).compensate(event); verify(callback2Two).compensate(event); - assertThat(callbacks.get(serviceName1).values(), containsInAnyOrder(callback1One, callback1Two)); + assertThat(callbacks.get(serviceName1).values(), Matchers.containsInAnyOrder(callback1One, callback1Two)); assertThat(callbacks.get(serviceName2).values(), containsInAnyOrder(callback2Two)); } @@ -115,7 +116,7 @@ public void blowsUpIfNoSuchServiceIsReachable() throws Exception { verify(callback2One, never()).compensate(event); verify(callback2Two, never()).compensate(event); - assertThat(callbacks.get(serviceName1).values(), containsInAnyOrder(callback1One, callback1Two)); + assertThat(callbacks.get(serviceName1).values(), Matchers.containsInAnyOrder(callback1One, callback1Two)); assertThat(callbacks.get(serviceName2).isEmpty(), is(true)); } @@ -136,7 +137,7 @@ public void blowsUpIfNoSuchServiceFound() throws Exception { verify(callback2One, never()).compensate(event); verify(callback2Two, never()).compensate(event); - assertThat(callbacks.get(serviceName1).values(), containsInAnyOrder(callback1One, callback1Two)); + assertThat(callbacks.get(serviceName1).values(), Matchers.containsInAnyOrder(callback1One, callback1Two)); assertThat(callbacks.containsKey(serviceName2), is(false)); } @@ -152,7 +153,7 @@ public void removeCallbackOnException() throws Exception { } assertThat(callbacks.get(serviceName1).values(), containsInAnyOrder(callback1One)); - assertThat(callbacks.get(serviceName2).values(), containsInAnyOrder(callback2One, callback2Two)); + assertThat(callbacks.get(serviceName2).values(), Matchers.containsInAnyOrder(callback2One, callback2Two)); } private TxEvent eventOf(String serviceName, String instanceId, EventType eventType) { diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunnerTest.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunnerTest.java similarity index 97% rename from alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunnerTest.java rename to alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunnerTest.java index 7c3e7ba7d..05e0e0bc6 100644 --- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PendingTaskRunnerTest.java +++ b/alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PendingTaskRunnerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.awaitility.Awaitility.await; diff --git a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallbackTest.java b/alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallbackTest.java similarity index 95% rename from alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallbackTest.java rename to alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallbackTest.java index 521232caa..4d0676c91 100644 --- a/alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/PushBackOmegaCallbackTest.java +++ b/alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/PushBackOmegaCallbackTest.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; -import static org.apache.servicecomb.saga.alpha.core.TxEventMaker.someEvent; +import static org.apache.servicecomb.pack.alpha.core.TxEventMaker.someEvent; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.doThrow; 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/pack/alpha/core/TxConsistentServiceTest.java similarity index 91% rename from alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxConsistentServiceTest.java rename to alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/TxConsistentServiceTest.java index b0c19c880..2c9a3b5ad 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/pack/alpha/core/TxConsistentServiceTest.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Collections.emptyList; -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.apache.servicecomb.pack.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import static org.hamcrest.Matchers.contains; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -36,7 +36,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.stream.Collectors; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; import org.junit.Before; import org.junit.Test; 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/pack/alpha/core/TxEventMaker.java similarity index 91% rename from alpha/alpha-core/src/test/java/org/apache/servicecomb/saga/alpha/core/TxEventMaker.java rename to alpha/alpha-core/src/test/java/org/apache/servicecomb/pack/alpha/core/TxEventMaker.java index c14ffd9e8..3a1734a0e 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/pack/alpha/core/TxEventMaker.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.core; +package org.apache.servicecomb.pack.alpha.core; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import java.util.UUID; diff --git a/alpha/alpha-server/pom.xml b/alpha/alpha-server/pom.xml index 2a6856afc..ae8114596 100644 --- a/alpha/alpha-server/pom.xml +++ b/alpha/alpha-server/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> alpha - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 alpha-server - Saga::Alpha::Server + Pack::Alpha::Server @@ -63,15 +63,15 @@ grpc-netty - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-contract-grpc - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-core - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common @@ -89,8 +89,8 @@ spring-boot-starter-log4j2 - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa org.postgresql diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaApplication.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaApplication.java similarity index 96% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaApplication.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaApplication.java index 72bf5fbd9..ba8d1fc87 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaApplication.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaApplication.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import javax.annotation.PreDestroy; 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/pack/alpha/server/AlphaConfig.java similarity index 84% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaConfig.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaConfig.java index 47feb1fc6..7ba3343a4 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/pack/alpha/server/AlphaConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.util.Map; import java.util.concurrent.BlockingQueue; @@ -25,19 +25,19 @@ import java.util.concurrent.ScheduledExecutorService; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; -import org.apache.servicecomb.saga.alpha.core.CommandRepository; -import org.apache.servicecomb.saga.alpha.core.CompositeOmegaCallback; -import org.apache.servicecomb.saga.alpha.core.EventScanner; -import org.apache.servicecomb.saga.alpha.core.OmegaCallback; -import org.apache.servicecomb.saga.alpha.core.PendingTaskRunner; -import org.apache.servicecomb.saga.alpha.core.PushBackOmegaCallback; -import org.apache.servicecomb.saga.alpha.core.TxConsistentService; -import org.apache.servicecomb.saga.alpha.core.TxEventRepository; -import org.apache.servicecomb.saga.alpha.core.TxTimeoutRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.GrpcTccEventService; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccPendingTaskRunner; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccEventScanner; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventService; +import org.apache.servicecomb.pack.alpha.core.CommandRepository; +import org.apache.servicecomb.pack.alpha.core.CompositeOmegaCallback; +import org.apache.servicecomb.pack.alpha.core.EventScanner; +import org.apache.servicecomb.pack.alpha.core.OmegaCallback; +import org.apache.servicecomb.pack.alpha.core.PendingTaskRunner; +import org.apache.servicecomb.pack.alpha.core.PushBackOmegaCallback; +import org.apache.servicecomb.pack.alpha.core.TxConsistentService; +import org.apache.servicecomb.pack.alpha.core.TxEventRepository; +import org.apache.servicecomb.pack.alpha.core.TxTimeoutRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.GrpcTccEventService; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.TccPendingTaskRunner; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccEventScanner; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; @@ -45,7 +45,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha") +@EntityScan(basePackages = "org.apache.servicecomb.pack.alpha") @Configuration class AlphaConfig { private static final Logger LOG = LoggerFactory.getLogger(AlphaConfig.class); diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaEventController.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaEventController.java similarity index 96% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaEventController.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaEventController.java index 8c73a57d6..0303ead4f 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/AlphaEventController.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/AlphaEventController.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.lang.invoke.MethodHandles; import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.apache.servicecomb.saga.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Profile; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/CommandEntityRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/CommandEntityRepository.java similarity index 92% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/CommandEntityRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/CommandEntityRepository.java index 53110bf5e..60fd28bb3 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/CommandEntityRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/CommandEntityRepository.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.util.List; import javax.persistence.LockModeType; import javax.transaction.Transactional; -import org.apache.servicecomb.saga.alpha.core.Command; +import org.apache.servicecomb.pack.alpha.core.Command; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -33,7 +33,7 @@ public interface CommandEntityRepository extends CrudRepository { @Transactional @Modifying(clearAutomatically = true) - @Query("UPDATE org.apache.servicecomb.saga.alpha.core.Command c " + @Query("UPDATE org.apache.servicecomb.pack.alpha.core.Command c " + "SET c.status = :toStatus " + "WHERE c.globalTxId = :globalTxId " + " AND c.localTxId = :localTxId " @@ -46,7 +46,7 @@ void updateStatusByGlobalTxIdAndLocalTxId( @Transactional @Modifying(clearAutomatically = true) - @Query("UPDATE org.apache.servicecomb.saga.alpha.core.Command c " + @Query("UPDATE org.apache.servicecomb.pack.alpha.core.Command c " + "SET c.status = :status " + "WHERE c.globalTxId = :globalTxId " + " AND c.localTxId = :localTxId") diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcOmegaCallback.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcOmegaCallback.java similarity index 87% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcOmegaCallback.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcOmegaCallback.java index a54fa66c8..97b7b6148 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcOmegaCallback.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcOmegaCallback.java @@ -18,11 +18,11 @@ * */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; -import org.apache.servicecomb.saga.alpha.core.OmegaCallback; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand; +import org.apache.servicecomb.pack.alpha.core.OmegaCallback; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand; import com.google.protobuf.ByteString; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcServerConfig.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcServerConfig.java similarity index 97% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcServerConfig.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcServerConfig.java index e1368c431..4e96783cc 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcServerConfig.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcServerConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcStartable.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java similarity index 98% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcStartable.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java index a59996724..5941ae373 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcStartable.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcStartable.java @@ -18,7 +18,7 @@ * */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.io.IOException; import java.io.InputStream; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcTxEventEndpointImpl.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcTxEventEndpointImpl.java similarity index 84% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcTxEventEndpointImpl.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcTxEventEndpointImpl.java index 677fa8734..a2298922d 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/GrpcTxEventEndpointImpl.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/GrpcTxEventEndpointImpl.java @@ -18,7 +18,7 @@ * */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import static java.util.Collections.emptyMap; @@ -28,14 +28,14 @@ import kamon.annotation.EnableKamon; import kamon.annotation.Trace; -import org.apache.servicecomb.saga.alpha.core.OmegaCallback; -import org.apache.servicecomb.saga.alpha.core.TxConsistentService; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcAck; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceImplBase; +import org.apache.servicecomb.pack.alpha.core.OmegaCallback; +import org.apache.servicecomb.pack.alpha.core.TxConsistentService; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceImplBase; import io.grpc.stub.StreamObserver; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/ServerStartable.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/ServerStartable.java similarity index 94% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/ServerStartable.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/ServerStartable.java index 41dfdbdd3..9024bf40d 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/ServerStartable.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/ServerStartable.java @@ -18,7 +18,7 @@ * */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; public interface ServerStartable { void start(); diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringCommandRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringCommandRepository.java similarity index 89% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringCommandRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringCommandRepository.java index f7078c24b..e9755b31e 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringCommandRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringCommandRepository.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.DONE; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.NEW; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.PENDING; +import static org.apache.servicecomb.pack.alpha.core.TaskStatus.DONE; +import static org.apache.servicecomb.pack.alpha.core.TaskStatus.NEW; +import static org.apache.servicecomb.pack.alpha.core.TaskStatus.PENDING; import java.lang.invoke.MethodHandles; import java.util.LinkedHashMap; @@ -28,9 +28,9 @@ import javax.transaction.Transactional; -import org.apache.servicecomb.saga.alpha.core.Command; -import org.apache.servicecomb.saga.alpha.core.CommandRepository; -import org.apache.servicecomb.saga.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.Command; +import org.apache.servicecomb.pack.alpha.core.CommandRepository; +import org.apache.servicecomb.pack.alpha.core.TxEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxEventRepository.java similarity index 93% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxEventRepository.java index 0394f829c..173125d9f 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxEventRepository.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; -import static org.apache.servicecomb.saga.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxCompensatedEvent; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.alpha.core.TxEventRepository; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEventRepository; import org.springframework.data.domain.PageRequest; import kamon.annotation.EnableKamon; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxTimeoutRepository.java similarity index 90% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxTimeoutRepository.java index 6b756b5ad..896661622 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/SpringTxTimeoutRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/SpringTxTimeoutRepository.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.PENDING; +import static org.apache.servicecomb.pack.alpha.core.TaskStatus.PENDING; import java.lang.invoke.MethodHandles; import java.util.List; import javax.transaction.Transactional; -import org.apache.servicecomb.saga.alpha.core.TxTimeout; -import org.apache.servicecomb.saga.alpha.core.TxTimeoutRepository; +import org.apache.servicecomb.pack.alpha.core.TxTimeout; +import org.apache.servicecomb.pack.alpha.core.TxTimeoutRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.PageRequest; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxEventEnvelopeRepository.java similarity index 98% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxEventEnvelopeRepository.java index ebb761020..6e843838b 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxEventEnvelopeRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxEventEnvelopeRepository.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.util.List; import java.util.Optional; import javax.transaction.Transactional; -import org.apache.servicecomb.saga.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEvent; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; @@ -64,7 +64,7 @@ public interface TxEventEnvelopeRepository extends CrudRepository + " AND t.type = 'TxStartedEvent'") Optional findFirstStartedEventByGlobalTxIdAndLocalTxId(String globalTxId, String localTxId); - @Query("SELECT DISTINCT new org.apache.servicecomb.saga.alpha.core.TxEvent(" + @Query("SELECT DISTINCT new org.apache.servicecomb.pack.alpha.core.TxEvent(" + "t.serviceName, t.instanceId, t.globalTxId, t.localTxId, t.parentTxId, " + "t.type, t.compensationMethod, t.payloads " + ") FROM TxEvent t " diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxTimeoutEntityRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxTimeoutEntityRepository.java similarity index 93% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxTimeoutEntityRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxTimeoutEntityRepository.java index f0e264a4a..158495231 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/TxTimeoutEntityRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/TxTimeoutEntityRepository.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.util.List; import javax.persistence.LockModeType; import javax.transaction.Transactional; -import org.apache.servicecomb.saga.alpha.core.TxTimeout; +import org.apache.servicecomb.pack.alpha.core.TxTimeout; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.Lock; import org.springframework.data.jpa.repository.Modifying; @@ -34,7 +34,7 @@ interface TxTimeoutEntityRepository extends CrudRepository { @Transactional @Modifying(clearAutomatically = true) - @Query("UPDATE org.apache.servicecomb.saga.alpha.core.TxTimeout t " + @Query("UPDATE org.apache.servicecomb.pack.alpha.core.TxTimeout t " + "SET t.status = :status " + "WHERE t.globalTxId = :globalTxId " + " AND t.localTxId = :localTxId") diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsController.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsController.java similarity index 97% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsController.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsController.java index bafb25d6c..b4675d211 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsController.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsController.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.console.saga; +package org.apache.servicecomb.pack.alpha.server.console.saga; import com.fasterxml.jackson.annotation.JsonAutoDetect; import kamon.annotation.EnableKamon; import kamon.annotation.Trace; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.alpha.server.TxEventEnvelopeRepository; -import org.apache.servicecomb.saga.alpha.server.console.saga.model.Stats; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.server.TxEventEnvelopeRepository; +import org.apache.servicecomb.pack.alpha.server.console.saga.model.Stats; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.PageRequest; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/model/Stats.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/model/Stats.java similarity index 97% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/model/Stats.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/model/Stats.java index d2ed520f4..a4a0a6ad1 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/console/saga/model/Stats.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/console/saga/model/Stats.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.console.saga.model; +package org.apache.servicecomb.pack.alpha.server.console.saga.model; import java.util.Date; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventController.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventController.java similarity index 91% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventController.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventController.java index 8c62f4571..0b0d5f947 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventController.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventController.java @@ -15,16 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import java.lang.invoke.MethodHandles; import java.util.Collection; import java.util.LinkedList; import java.util.List; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEventDBRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Profile; 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/pack/alpha/server/tcc/GrpcTccEventService.java similarity index 82% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/GrpcTccEventService.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/GrpcTccEventService.java index 9c8840c3f..d92c55ac3 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/pack/alpha/server/tcc/GrpcTccEventService.java @@ -15,22 +15,22 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import io.grpc.stub.StreamObserver; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallback; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.EventConverter; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventService; -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; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.OmegaCallback; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.OmegaCallbacksRegistry; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.EventConverter; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventService; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/CallbackEngine.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/CallbackEngine.java similarity index 87% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/CallbackEngine.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/CallbackEngine.java index f262f52c2..5aaa4f06d 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/CallbackEngine.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/CallbackEngine.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; public interface CallbackEngine { 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/pack/alpha/server/tcc/callback/GrpcOmegaTccCallback.java similarity index 87% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/GrpcOmegaTccCallback.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/GrpcOmegaTccCallback.java index a2cf13525..3de49665d 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/pack/alpha/server/tcc/callback/GrpcOmegaTccCallback.java @@ -15,12 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; import io.grpc.stub.StreamObserver; -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; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; /** * Grpc omega callback for TCC workflow. 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/pack/alpha/server/tcc/callback/OmegaCallback.java similarity index 83% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallback.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/OmegaCallback.java index 982bb92f3..7d57d8e5a 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/pack/alpha/server/tcc/callback/OmegaCallback.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.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/pack/alpha/server/tcc/callback/OmegaCallbackWrapper.java similarity index 90% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbackWrapper.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/OmegaCallbackWrapper.java index 475489dc6..fb5d37f9c 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/pack/alpha/server/tcc/callback/OmegaCallbackWrapper.java @@ -15,11 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; import java.util.concurrent.BlockingQueue; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.common.TransactionStatus; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.springframework.stereotype.Component; @Component diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/OmegaCallbacksRegistry.java similarity index 88% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/OmegaCallbacksRegistry.java index 3b87e7d2c..61a509cb7 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/OmegaCallbacksRegistry.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/OmegaCallbacksRegistry.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; import static java.util.Collections.emptyMap; @@ -23,11 +23,9 @@ import java.lang.invoke.MethodHandles; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.servicecomb.saga.alpha.core.AlphaException; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.GrpcOmegaTccCallback; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallback; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.alpha.core.AlphaException; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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/pack/alpha/server/tcc/callback/TccCallbackEngine.java similarity index 88% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccCallbackEngine.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/TccCallbackEngine.java index dfd1e363e..8c65f40d1 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/pack/alpha/server/tcc/callback/TccCallbackEngine.java @@ -15,14 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; import java.lang.invoke.MethodHandles; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventRepository; -import org.apache.servicecomb.saga.common.TransactionStatus; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventRepository; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccPendingTaskRunner.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/TccPendingTaskRunner.java similarity index 96% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccPendingTaskRunner.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/TccPendingTaskRunner.java index b847f6504..a248e044b 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/callback/TccPendingTaskRunner.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/callback/TccPendingTaskRunner.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.callback; +package org.apache.servicecomb.pack.alpha.server.tcc.callback; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverter.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverter.java similarity index 92% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverter.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverter.java index df8b6a028..179e70a39 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverter.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverter.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; public class EventConverter { diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEvent.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEvent.java similarity index 98% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEvent.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEvent.java index 451e88e99..96c8055a9 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEvent.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEvent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.Date; import java.util.Objects; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEventRepository.java similarity index 97% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEventRepository.java index 8c3023b1b..3dc172dd9 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/GlobalTxEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/GlobalTxEventRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.Date; import java.util.List; 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/pack/alpha/server/tcc/jpa/ParticipatedEvent.java similarity index 98% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEvent.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/ParticipatedEvent.java index b0868c5c1..e669c4ef2 100644 --- 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/pack/alpha/server/tcc/jpa/ParticipatedEvent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.Date; import java.util.Objects; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/ParticipatedEventRepository.java similarity index 96% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/ParticipatedEventRepository.java index b43aaa634..c9f110619 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/ParticipatedEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/ParticipatedEventRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.List; import java.util.Optional; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEvent.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEvent.java similarity index 98% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEvent.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEvent.java index e1d96549f..af06a0e3e 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEvent.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEvent.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.Date; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEventDBRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEventDBRepository.java similarity index 91% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEventDBRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEventDBRepository.java index 172a5547c..4b865dc95 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxEventDBRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxEventDBRepository.java @@ -15,12 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxType.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxType.java similarity index 93% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxType.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxType.java index b1527d3ce..c8007ec27 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/TccTxType.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/TccTxType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; public enum TccTxType { STARTED, diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryTxEventRepository.java similarity index 91% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryTxEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryTxEventRepository.java index 3bdd873d4..91309110a 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryTxEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryTxEventRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import java.lang.invoke.MethodHandles; import java.util.ArrayList; @@ -27,11 +27,12 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.EventConverter; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.EventConverter; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Profile; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/RDBTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/RDBTxEventRepository.java similarity index 87% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/RDBTxEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/RDBTxEventRepository.java index 9e24a3699..b48e984ba 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/RDBTxEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/RDBTxEventRepository.java @@ -15,19 +15,20 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import java.util.Date; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.EventConverter; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEventDBRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.EventConverter; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEventDBRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.data.domain.Pageable; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccEventScanner.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccEventScanner.java similarity index 97% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccEventScanner.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccEventScanner.java index f5c930fe8..581241486 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccEventScanner.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccEventScanner.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static java.util.concurrent.TimeUnit.SECONDS; diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventRepository.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventRepository.java similarity index 84% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventRepository.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventRepository.java index ebc19ce4d..f7afccc8f 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventRepository.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventRepository.java @@ -15,15 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import java.util.Date; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; import org.springframework.data.domain.Pageable; public interface TccTxEventRepository { diff --git a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventService.java b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventService.java similarity index 92% rename from alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventService.java rename to alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventService.java index a109a826f..99a608352 100644 --- a/alpha/alpha-server/src/main/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventService.java +++ b/alpha/alpha-server/src/main/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventService.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import java.lang.invoke.MethodHandles; import java.util.Date; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccCallbackEngine; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.common.TransactionStatus; + +import org.apache.servicecomb.pack.alpha.server.tcc.callback.TccCallbackEngine; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.PageRequest; @@ -129,4 +130,4 @@ public void handleTimeoutTx(Date deadLine, int size) { public void clearCompletedGlobalTx(int size) { tccTxEventRepository.clearCompletedGlobalTx(new PageRequest(0, size)); } -} \ No newline at end of file +} diff --git a/alpha/alpha-server/src/main/resources/META-INF/aop.xml b/alpha/alpha-server/src/main/resources/META-INF/aop.xml index c48103637..ff93fd9c5 100644 --- a/alpha/alpha-server/src/main/resources/META-INF/aop.xml +++ b/alpha/alpha-server/src/main/resources/META-INF/aop.xml @@ -19,7 +19,7 @@ - + diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaEventControllerTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaEventControllerTest.java similarity index 94% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaEventControllerTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaEventControllerTest.java index ee2c44431..d6005637a 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaEventControllerTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaEventControllerTest.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Collections.singletonList; -import static org.apache.servicecomb.saga.common.EventType.TxStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.core.Is.is; import static org.mockito.Mockito.when; @@ -29,7 +29,7 @@ import java.util.UUID; -import org.apache.servicecomb.saga.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEvent; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; 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/pack/alpha/server/AlphaIntegrationTest.java similarity index 93% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationTest.java index 8f5122b23..51c9ce7f3 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/pack/alpha/server/AlphaIntegrationTest.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.servicecomb.saga.alpha.core.TaskStatus.DONE; -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.apache.servicecomb.pack.alpha.core.TaskStatus.DONE; +import static org.apache.servicecomb.pack.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import static org.awaitility.Awaitility.await; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.notNullValue; @@ -44,22 +44,22 @@ import java.util.concurrent.Executors; import java.util.function.Consumer; import javax.annotation.PostConstruct; -import org.apache.servicecomb.saga.alpha.core.CommandRepository; -import org.apache.servicecomb.saga.alpha.core.EventScanner; -import org.apache.servicecomb.saga.alpha.core.OmegaCallback; -import org.apache.servicecomb.saga.alpha.core.TxConsistentService; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.alpha.core.TxEventRepository; -import org.apache.servicecomb.saga.alpha.core.TxTimeout; -import org.apache.servicecomb.saga.alpha.core.TxTimeoutRepository; -import org.apache.servicecomb.saga.common.EventType; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcAck; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceBlockingStub; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceStub; +import org.apache.servicecomb.pack.alpha.core.CommandRepository; +import org.apache.servicecomb.pack.alpha.core.EventScanner; +import org.apache.servicecomb.pack.alpha.core.OmegaCallback; +import org.apache.servicecomb.pack.alpha.core.TxConsistentService; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEventRepository; +import org.apache.servicecomb.pack.alpha.core.TxTimeout; +import org.apache.servicecomb.pack.alpha.core.TxTimeoutRepository; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceBlockingStub; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceStub; import org.hamcrest.core.Is; import org.junit.After; import org.junit.AfterClass; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationWithSSLTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationWithSSLTest.java similarity index 98% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationWithSSLTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationWithSSLTest.java index 8a2df82d3..02f37df07 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/AlphaIntegrationWithSSLTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/AlphaIntegrationWithSSLTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server; +package org.apache.servicecomb.pack.alpha.server; import java.io.File; import java.util.Arrays; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsControllerTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsControllerTest.java similarity index 93% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsControllerTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsControllerTest.java index a4ce9831c..b07fc6d46 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/console/saga/SagaTransactionsControllerTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/console/saga/SagaTransactionsControllerTest.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.console.saga; +package org.apache.servicecomb.pack.alpha.server.console.saga; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Collections.singletonList; -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.apache.servicecomb.pack.common.EventType.SagaEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxAbortedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxCompensatedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxEndedEvent; +import static org.apache.servicecomb.pack.common.EventType.TxStartedEvent; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; import static org.hamcrest.core.Is.is; import static org.mockito.Mockito.when; @@ -36,8 +36,8 @@ import java.util.List; import java.util.UUID; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.alpha.server.TxEventEnvelopeRepository; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.server.TxEventEnvelopeRepository; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -195,4 +195,4 @@ private TxEvent populateEvents(String type) { this.getClass().getCanonicalName(), uniquify("blah").getBytes()); } -} \ No newline at end of file +} diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventControllerTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventControllerTest.java similarity index 89% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventControllerTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventControllerTest.java index 21d75d57c..94627df3f 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccEventControllerTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccEventControllerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Collections.singletonList; @@ -26,11 +26,10 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEventDBRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventRepository; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventRepository; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccServerTestBase.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccServerTestBase.java similarity index 89% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccServerTestBase.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccServerTestBase.java index 8fe995819..e26b78757 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/AlphaTccServerTestBase.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/AlphaTccServerTestBase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; @@ -32,23 +32,24 @@ import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.GrpcOmegaTccCallback; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.EventConverter; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventRepository; -import org.apache.servicecomb.saga.common.TransactionStatus; -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; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceBlockingStub; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceStub; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.GrpcOmegaTccCallback; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.OmegaCallbacksRegistry; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.EventConverter; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventRepository; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceBlockingStub; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceStub; +import org.hamcrest.core.Is; import org.junit.After; import org.junit.AfterClass; import org.junit.Test; @@ -137,7 +138,7 @@ public void assertOnTransactionStart() { assertThat(event.getLocalTxId(), is(localTxId)); assertThat(event.getInstanceId(), is(instanceId)); assertThat(event.getServiceName(), is(serviceName)); - assertThat(event.getTxType(), is(TccTxType.STARTED.name())); + assertThat(event.getTxType(), Is.is(TccTxType.STARTED.name())); assertThat(event.getStatus(), is(TransactionStatus.Succeed.name())); event = iterator.next(); diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/MemoryAlphaTccServerTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/MemoryAlphaTccServerTest.java similarity index 96% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/MemoryAlphaTccServerTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/MemoryAlphaTccServerTest.java index c7da54d12..e42af58f2 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/MemoryAlphaTccServerTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/MemoryAlphaTccServerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import io.grpc.netty.NettyChannelBuilder; import org.junit.BeforeClass; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbAlphaTccServerTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/RdbAlphaTccServerTest.java similarity index 96% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbAlphaTccServerTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/RdbAlphaTccServerTest.java index f4cd431f8..3e7e25879 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/RdbAlphaTccServerTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/RdbAlphaTccServerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import io.grpc.netty.NettyChannelBuilder; import org.junit.BeforeClass; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccApplication.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccApplication.java similarity index 91% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccApplication.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccApplication.java index d24425ccd..5bf5afa44 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccApplication.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccApplication.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; -import org.apache.servicecomb.saga.alpha.server.GrpcServerConfig; +import org.apache.servicecomb.pack.alpha.server.GrpcServerConfig; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCallbackEngineTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCallbackEngineTest.java similarity index 90% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCallbackEngineTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCallbackEngineTest.java index 1d0859781..d8f2bdac6 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCallbackEngineTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCallbackEngineTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.Matchers.is; @@ -27,14 +27,15 @@ import io.grpc.stub.StreamObserver; import java.util.UUID; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccCallbackEngine; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventService; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.OmegaCallbacksRegistry; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.TccCallbackEngine; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventService; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccConfiguration.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccConfiguration.java similarity index 83% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccConfiguration.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccConfiguration.java index fd9341918..a83cb27b1 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccConfiguration.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccConfiguration.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; -import org.apache.servicecomb.saga.alpha.server.GrpcServerConfig; -import org.apache.servicecomb.saga.alpha.server.GrpcStartable; -import org.apache.servicecomb.saga.alpha.server.ServerStartable; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.TccPendingTaskRunner; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccEventScanner; -import org.apache.servicecomb.saga.alpha.server.tcc.service.TccTxEventService; +import org.apache.servicecomb.pack.alpha.server.GrpcServerConfig; +import org.apache.servicecomb.pack.alpha.server.GrpcStartable; +import org.apache.servicecomb.pack.alpha.server.ServerStartable; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.TccPendingTaskRunner; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccEventScanner; +import org.apache.servicecomb.pack.alpha.server.tcc.service.TccTxEventService; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCoordinateCommandStreamObserver.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCoordinateCommandStreamObserver.java similarity index 92% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCoordinateCommandStreamObserver.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCoordinateCommandStreamObserver.java index 5c4143aa3..b768de21e 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/TccCoordinateCommandStreamObserver.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/TccCoordinateCommandStreamObserver.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc; +package org.apache.servicecomb.pack.alpha.server.tcc; import io.grpc.stub.StreamObserver; import java.util.Queue; import java.util.function.Consumer; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; public class TccCoordinateCommandStreamObserver implements StreamObserver { diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverterTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverterTest.java similarity index 95% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverterTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverterTest.java index 4d8477041..a9f2e98b3 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/jpa/EventConverterTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/jpa/EventConverterTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.jpa; +package org.apache.servicecomb.pack.alpha.server.tcc.jpa; import org.junit.Test; import static org.hamcrest.core.Is.is; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryEventRegistryTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryEventRegistryTest.java similarity index 94% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryEventRegistryTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryEventRegistryTest.java index c1d929f12..156e8e655 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/MemoryEventRegistryTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/MemoryEventRegistryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.core.Is.is; @@ -26,9 +26,9 @@ import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.junit.Before; import org.junit.Test; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTest.java similarity index 90% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTest.java index 6993d7991..c424ca76a 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; @@ -29,18 +29,19 @@ import java.util.Date; import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.TccApplication; -import org.apache.servicecomb.saga.alpha.server.tcc.TccConfiguration; -import org.apache.servicecomb.saga.alpha.server.tcc.callback.OmegaCallbacksRegistry; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.TccApplication; +import org.apache.servicecomb.pack.alpha.server.tcc.TccConfiguration; +import org.apache.servicecomb.pack.alpha.server.tcc.callback.OmegaCallbacksRegistry; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java similarity index 86% rename from alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java rename to alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java index e1694f810..97886810f 100644 --- a/alpha/alpha-server/src/test/java/org/apache/servicecomb/saga/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java +++ b/alpha/alpha-server/src/test/java/org/apache/servicecomb/pack/alpha/server/tcc/service/TccTxEventServiceTransactionTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.alpha.server.tcc.service; +package org.apache.servicecomb.pack.alpha.server.tcc.service; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.Matchers.is; @@ -25,16 +25,17 @@ import java.util.List; import java.util.Optional; -import org.apache.servicecomb.saga.alpha.server.tcc.TccApplication; -import org.apache.servicecomb.saga.alpha.server.tcc.TccConfiguration; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.GlobalTxEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.ParticipatedEventRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEvent; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxEventDBRepository; -import org.apache.servicecomb.saga.alpha.server.tcc.jpa.TccTxType; -import org.apache.servicecomb.saga.common.TransactionStatus; + +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.ParticipatedEventRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEventDBRepository; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxType; +import org.apache.servicecomb.pack.alpha.server.tcc.TccApplication; +import org.apache.servicecomb.pack.alpha.server.tcc.TccConfiguration; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.GlobalTxEvent; +import org.apache.servicecomb.pack.alpha.server.tcc.jpa.TccTxEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; import org.junit.After; import org.junit.Before; import org.junit.Test; diff --git a/alpha/pom.xml b/alpha/pom.xml index 4e58d97f9..57d20066f 100644 --- a/alpha/pom.xml +++ b/alpha/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 alpha - Saga::Alpha + Pack::Alpha pom diff --git a/saga-demo/pom.xml b/demo/pom.xml similarity index 95% rename from saga-demo/pom.xml rename to demo/pom.xml index 614dfa6dc..556201b5a 100644 --- a/saga-demo/pom.xml +++ b/demo/pom.xml @@ -19,22 +19,20 @@ saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo saga-demo - Saga::Demo + Pack::Demo pom saga-dubbo-demo saga-spring-demo saga-servicecomb-demo - dependency-free-transaction-demo - conditional-transaction-demo tcc-spring-demo diff --git a/saga-demo/saga-dubbo-demo/README.md b/demo/saga-dubbo-demo/README.md similarity index 100% rename from saga-demo/saga-dubbo-demo/README.md rename to demo/saga-dubbo-demo/README.md diff --git a/saga-demo/saga-dubbo-demo/docker-compose-alpha.yaml b/demo/saga-dubbo-demo/docker-compose-alpha.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/docker-compose-alpha.yaml rename to demo/saga-dubbo-demo/docker-compose-alpha.yaml diff --git a/saga-demo/saga-dubbo-demo/docker-compose-demo.yaml b/demo/saga-dubbo-demo/docker-compose-demo.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/docker-compose-demo.yaml rename to demo/saga-dubbo-demo/docker-compose-demo.yaml diff --git a/saga-demo/saga-dubbo-demo/docker-compose.mysql.yaml b/demo/saga-dubbo-demo/docker-compose.mysql.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/docker-compose.mysql.yaml rename to demo/saga-dubbo-demo/docker-compose.mysql.yaml diff --git a/saga-demo/saga-dubbo-demo/docker-compose.yaml b/demo/saga-dubbo-demo/docker-compose.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/docker-compose.yaml rename to demo/saga-dubbo-demo/docker-compose.yaml diff --git a/saga-demo/saga-dubbo-demo/pom.xml b/demo/saga-dubbo-demo/pom.xml similarity index 93% rename from saga-demo/saga-dubbo-demo/pom.xml rename to demo/saga-dubbo-demo/pom.xml index 3ba7d0c72..ef4c7836b 100644 --- a/saga-demo/saga-dubbo-demo/pom.xml +++ b/demo/saga-dubbo-demo/pom.xml @@ -20,13 +20,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 saga-dubbo-demo - Saga::Demo::Dubbo-Demo + Pack::Demo::Dubbo-Demo pom @@ -60,7 +60,7 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-dubbo ${saga.version} @@ -69,7 +69,7 @@ spring-jdbc - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter @@ -81,7 +81,7 @@ spring-boot-starter-web - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate diff --git a/saga-demo/saga-dubbo-demo/saga-dubbo-demo.sh b/demo/saga-dubbo-demo/saga-dubbo-demo.sh similarity index 100% rename from saga-demo/saga-dubbo-demo/saga-dubbo-demo.sh rename to demo/saga-dubbo-demo/saga-dubbo-demo.sh diff --git a/saga-demo/saga-dubbo-demo/service-api/pom.xml b/demo/saga-dubbo-demo/service-api/pom.xml similarity index 88% rename from saga-demo/saga-dubbo-demo/service-api/pom.xml rename to demo/saga-dubbo-demo/service-api/pom.xml index 4c4ceac53..105d55fb4 100644 --- a/saga-demo/saga-dubbo-demo/service-api/pom.xml +++ b/demo/saga-dubbo-demo/service-api/pom.xml @@ -22,7 +22,7 @@ 4.0.0 - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo service-pub 0.3.0-SNAPSHOT @@ -30,11 +30,11 @@ saga-dubbo-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT service-api - Saga::Demo::Dubbo-Demo::ServiceAPI + Pack::Demo::Dubbo-Demo::ServiceAPI - \ No newline at end of file + diff --git a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IService.java b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IService.java similarity index 89% rename from saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IService.java rename to demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IService.java index 523d4abd9..3f2ef3632 100644 --- a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IService.java +++ b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IService.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.api; +package org.apache.servicecomb.pack.demo.dubbo.api; -import org.apache.servicecomb.saga.demo.dubbo.pub.InvokeContext; +import org.apache.servicecomb.pack.demo.dubbo.pub.InvokeContext; public interface IService { Object run(InvokeContext invokeContext) throws Exception; diff --git a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceA.java b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceA.java similarity index 94% rename from saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceA.java rename to demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceA.java index 21b9ff7d3..361e7d125 100644 --- a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceA.java +++ b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceA.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.api; +package org.apache.servicecomb.pack.demo.dubbo.api; public interface IServiceA extends IService { } diff --git a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceB.java b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceB.java similarity index 94% rename from saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceB.java rename to demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceB.java index 83d538242..64935b655 100644 --- a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceB.java +++ b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceB.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.api; +package org.apache.servicecomb.pack.demo.dubbo.api; public interface IServiceB extends IService { } diff --git a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceC.java b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceC.java similarity index 94% rename from saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceC.java rename to demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceC.java index 91bd18f38..ae61300b0 100644 --- a/saga-demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/saga/demo/dubbo/api/IServiceC.java +++ b/demo/saga-dubbo-demo/service-api/src/main/java/org/apache/servicecomb/pack/demo/dubbo/api/IServiceC.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.api; +package org.apache.servicecomb.pack.demo.dubbo.api; public interface IServiceC extends IService { } diff --git a/saga-demo/saga-dubbo-demo/service-api/src/main/resources/dubbo.properties b/demo/saga-dubbo-demo/service-api/src/main/resources/dubbo.properties similarity index 100% rename from saga-demo/saga-dubbo-demo/service-api/src/main/resources/dubbo.properties rename to demo/saga-dubbo-demo/service-api/src/main/resources/dubbo.properties diff --git a/saga-demo/saga-dubbo-demo/service-pub/pom.xml b/demo/saga-dubbo-demo/service-pub/pom.xml similarity index 91% rename from saga-demo/saga-dubbo-demo/service-pub/pom.xml rename to demo/saga-dubbo-demo/service-pub/pom.xml index 2c4dea9fb..8dc184e27 100644 --- a/saga-demo/saga-dubbo-demo/service-pub/pom.xml +++ b/demo/saga-dubbo-demo/service-pub/pom.xml @@ -20,12 +20,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-dubbo-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 service-pub - Saga::Demo::Dubbo-Demo::ServicePub + Pack::Demo::Dubbo-Demo::ServicePub - \ No newline at end of file + diff --git a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/AbsService.java b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/AbsService.java similarity index 96% rename from saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/AbsService.java rename to demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/AbsService.java index c2082deca..758cebd80 100644 --- a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/AbsService.java +++ b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/AbsService.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.pub; +package org.apache.servicecomb.pack.demo.dubbo.pub; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/IInvokeCode.java b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/IInvokeCode.java similarity index 96% rename from saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/IInvokeCode.java rename to demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/IInvokeCode.java index 1b94ffd66..64a2166d2 100644 --- a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/IInvokeCode.java +++ b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/IInvokeCode.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.pub; +package org.apache.servicecomb.pack.demo.dubbo.pub; /** * a invoke code describe a test scenario diff --git a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/InvokeContext.java b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/InvokeContext.java similarity index 97% rename from saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/InvokeContext.java rename to demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/InvokeContext.java index 513aca350..6c484cbee 100644 --- a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/InvokeContext.java +++ b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/InvokeContext.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.pub; +package org.apache.servicecomb.pack.demo.dubbo.pub; public class InvokeContext implements java.io.Serializable { diff --git a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/ServiceVO.java b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/ServiceVO.java similarity index 96% rename from saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/ServiceVO.java rename to demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/ServiceVO.java index bae337184..2b0da062d 100644 --- a/saga-demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/saga/demo/dubbo/pub/ServiceVO.java +++ b/demo/saga-dubbo-demo/service-pub/src/main/java/org/apache/servicecomb/pack/demo/dubbo/pub/ServiceVO.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.pub; +package org.apache.servicecomb.pack.demo.dubbo.pub; public class ServiceVO { diff --git a/saga-demo/saga-dubbo-demo/servicea/pom.xml b/demo/saga-dubbo-demo/servicea/pom.xml similarity index 92% rename from saga-demo/saga-dubbo-demo/servicea/pom.xml rename to demo/saga-dubbo-demo/servicea/pom.xml index 9dad60d02..47da69a3e 100644 --- a/saga-demo/saga-dubbo-demo/servicea/pom.xml +++ b/demo/saga-dubbo-demo/servicea/pom.xml @@ -22,25 +22,25 @@ 4.0.0 - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo service-api ${saga.version} - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo service-pub ${saga.version} - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo saga-dubbo-demo 0.3.0-SNAPSHOT servicea - Saga::Demo::Dubbo-Demo::ServiceA + Pack::Demo::Dubbo-Demo::ServiceA @@ -91,4 +91,4 @@ - \ No newline at end of file + diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ApplicationA.java b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ApplicationA.java similarity index 91% rename from saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ApplicationA.java rename to demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ApplicationA.java index ae715a672..4c9c66773 100644 --- a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ApplicationA.java +++ b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ApplicationA.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicea; +package org.apache.servicecomb.pack.demo.dubbo.servicea; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ImportResource; diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ServiceA.java b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ServiceA.java similarity index 81% rename from saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ServiceA.java rename to demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ServiceA.java index 0bd5f7bcf..848825ce7 100644 --- a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/ServiceA.java +++ b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/ServiceA.java @@ -14,17 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicea; +package org.apache.servicecomb.pack.demo.dubbo.servicea; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceA; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceB; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceC; -import org.apache.servicecomb.saga.demo.dubbo.pub.AbsService; -import org.apache.servicecomb.saga.demo.dubbo.pub.InvokeContext; -import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceA; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceB; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceC; +import org.apache.servicecomb.pack.demo.dubbo.pub.AbsService; +import org.apache.servicecomb.pack.demo.dubbo.pub.InvokeContext; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/DubboDemoController.java b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/DubboDemoController.java similarity index 95% rename from saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/DubboDemoController.java rename to demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/DubboDemoController.java index ef9981ac7..dc9f494cc 100644 --- a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/DubboDemoController.java +++ b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/DubboDemoController.java @@ -15,16 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicea.web; +package org.apache.servicecomb.pack.demo.dubbo.servicea.web; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceA; -import org.apache.servicecomb.saga.demo.dubbo.pub.IInvokeCode; -import org.apache.servicecomb.saga.demo.dubbo.pub.InvokeContext; -import org.apache.servicecomb.saga.demo.dubbo.pub.ServiceVO; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceA; +import org.apache.servicecomb.pack.demo.dubbo.pub.IInvokeCode; +import org.apache.servicecomb.pack.demo.dubbo.pub.InvokeContext; +import org.apache.servicecomb.pack.demo.dubbo.pub.ServiceVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.BeanPropertyRowMapper; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/MvcConfigurer.java b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/MvcConfigurer.java similarity index 96% rename from saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/MvcConfigurer.java rename to demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/MvcConfigurer.java index d815f6073..9a4d77e79 100644 --- a/saga-demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicea/web/MvcConfigurer.java +++ b/demo/saga-dubbo-demo/servicea/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicea/web/MvcConfigurer.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicea.web; +package org.apache.servicecomb.pack.demo.dubbo.servicea.web; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; @@ -36,4 +36,4 @@ public void configurePathMatch(PathMatchConfigurer configurer) { super.configurePathMatch(configurer); configurer.setUseSuffixPatternMatch(false); } -} \ No newline at end of file +} diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/application.yaml b/demo/saga-dubbo-demo/servicea/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/application.yaml rename to demo/saga-dubbo-demo/servicea/src/main/resources/application.yaml diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml b/demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml similarity index 88% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml rename to demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml index 16a5b63ff..66356cd34 100644 --- a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml +++ b/demo/saga-dubbo-demo/servicea/src/main/resources/dubbo-context.xml @@ -24,8 +24,8 @@ - - - - - \ No newline at end of file + + + + + diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/jdbc.xml b/demo/saga-dubbo-demo/servicea/src/main/resources/jdbc.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/jdbc.xml rename to demo/saga-dubbo-demo/servicea/src/main/resources/jdbc.xml diff --git a/saga-core-akka/src/test/resources/log4j2.xml b/demo/saga-dubbo-demo/servicea/src/main/resources/log4j2.xml similarity index 100% rename from saga-core-akka/src/test/resources/log4j2.xml rename to demo/saga-dubbo-demo/servicea/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/schema-mysql.sql b/demo/saga-dubbo-demo/servicea/src/main/resources/schema-mysql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/schema-mysql.sql rename to demo/saga-dubbo-demo/servicea/src/main/resources/schema-mysql.sql diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/schema-postgresql.sql b/demo/saga-dubbo-demo/servicea/src/main/resources/schema-postgresql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/schema-postgresql.sql rename to demo/saga-dubbo-demo/servicea/src/main/resources/schema-postgresql.sql diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/static/index.html b/demo/saga-dubbo-demo/servicea/src/main/resources/static/index.html similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/static/index.html rename to demo/saga-dubbo-demo/servicea/src/main/resources/static/index.html diff --git a/saga-demo/saga-dubbo-demo/serviceb/pom.xml b/demo/saga-dubbo-demo/serviceb/pom.xml similarity index 94% rename from saga-demo/saga-dubbo-demo/serviceb/pom.xml rename to demo/saga-dubbo-demo/serviceb/pom.xml index 7aa8bbc40..66ffc04db 100644 --- a/saga-demo/saga-dubbo-demo/serviceb/pom.xml +++ b/demo/saga-dubbo-demo/serviceb/pom.xml @@ -22,7 +22,7 @@ 4.0.0 - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo service-api 0.3.0-SNAPSHOT compile @@ -30,13 +30,13 @@ - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo saga-dubbo-demo 0.3.0-SNAPSHOT serviceb - Saga::Demo::Dubbo-Demo::ServiceB + Pack::Demo::Dubbo-Demo::ServiceB @@ -87,4 +87,4 @@ - \ No newline at end of file + diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ApplicationB.java b/demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ApplicationB.java similarity index 91% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ApplicationB.java rename to demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ApplicationB.java index e31c37536..737f9cfe8 100644 --- a/saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ApplicationB.java +++ b/demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ApplicationB.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.serviceb; +package org.apache.servicecomb.pack.demo.dubbo.serviceb; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ImportResource; diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ServiceB.java b/demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ServiceB.java similarity index 84% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ServiceB.java rename to demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ServiceB.java index 01cfb8948..ce68e7581 100644 --- a/saga-demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/saga/demo/dubbo/serviceb/ServiceB.java +++ b/demo/saga-dubbo-demo/serviceb/src/main/java/org/apache/servicecomb/pack/demo/dubbo/serviceb/ServiceB.java @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.serviceb; +package org.apache.servicecomb.pack.demo.dubbo.serviceb; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceB; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceC; -import org.apache.servicecomb.saga.demo.dubbo.pub.AbsService; -import org.apache.servicecomb.saga.demo.dubbo.pub.InvokeContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceB; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceC; +import org.apache.servicecomb.pack.demo.dubbo.pub.AbsService; +import org.apache.servicecomb.pack.demo.dubbo.pub.InvokeContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/application.yaml b/demo/saga-dubbo-demo/serviceb/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/application.yaml rename to demo/saga-dubbo-demo/serviceb/src/main/resources/application.yaml diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml b/demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml similarity index 90% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml rename to demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml index 43a629ce0..120588bf8 100644 --- a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml +++ b/demo/saga-dubbo-demo/serviceb/src/main/resources/dubbo-context.xml @@ -24,7 +24,7 @@ - - - - \ No newline at end of file + + + + diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/jdbc.xml b/demo/saga-dubbo-demo/serviceb/src/main/resources/jdbc.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/jdbc.xml rename to demo/saga-dubbo-demo/serviceb/src/main/resources/jdbc.xml diff --git a/saga-core/src/test/resources/log4j2.xml b/demo/saga-dubbo-demo/serviceb/src/main/resources/log4j2.xml similarity index 100% rename from saga-core/src/test/resources/log4j2.xml rename to demo/saga-dubbo-demo/serviceb/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/schema-mysql.sql b/demo/saga-dubbo-demo/serviceb/src/main/resources/schema-mysql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/schema-mysql.sql rename to demo/saga-dubbo-demo/serviceb/src/main/resources/schema-mysql.sql diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/schema-postgresql.sql b/demo/saga-dubbo-demo/serviceb/src/main/resources/schema-postgresql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/schema-postgresql.sql rename to demo/saga-dubbo-demo/serviceb/src/main/resources/schema-postgresql.sql diff --git a/saga-demo/saga-dubbo-demo/servicec/pom.xml b/demo/saga-dubbo-demo/servicec/pom.xml similarity index 94% rename from saga-demo/saga-dubbo-demo/servicec/pom.xml rename to demo/saga-dubbo-demo/servicec/pom.xml index 6046ed818..d32c79bb3 100644 --- a/saga-demo/saga-dubbo-demo/servicec/pom.xml +++ b/demo/saga-dubbo-demo/servicec/pom.xml @@ -22,7 +22,7 @@ 4.0.0 - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo service-api 0.3.0-SNAPSHOT compile @@ -30,13 +30,13 @@ - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo saga-dubbo-demo 0.3.0-SNAPSHOT servicec - Saga::Demo::Dubbo-Demo::ServiceC + Pack::Demo::Dubbo-Demo::ServiceC @@ -87,4 +87,4 @@ - \ No newline at end of file + diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ApplicationC.java b/demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ApplicationC.java similarity index 91% rename from saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ApplicationC.java rename to demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ApplicationC.java index 5b3d7c706..701a1cb71 100644 --- a/saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ApplicationC.java +++ b/demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ApplicationC.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicec; +package org.apache.servicecomb.pack.demo.dubbo.servicec; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.ImportResource; diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ServiceC.java b/demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ServiceC.java similarity index 85% rename from saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ServiceC.java rename to demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ServiceC.java index a2abd2ea7..7218d9d7c 100644 --- a/saga-demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/saga/demo/dubbo/servicec/ServiceC.java +++ b/demo/saga-dubbo-demo/servicec/src/main/java/org/apache/servicecomb/pack/demo/dubbo/servicec/ServiceC.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.dubbo.servicec; +package org.apache.servicecomb.pack.demo.dubbo.servicec; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.demo.dubbo.api.IServiceC; -import org.apache.servicecomb.saga.demo.dubbo.pub.AbsService; -import org.apache.servicecomb.saga.demo.dubbo.pub.InvokeContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.demo.dubbo.api.IServiceC; +import org.apache.servicecomb.pack.demo.dubbo.pub.AbsService; +import org.apache.servicecomb.pack.demo.dubbo.pub.InvokeContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.transaction.annotation.Transactional; diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/application.yaml b/demo/saga-dubbo-demo/servicec/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/application.yaml rename to demo/saga-dubbo-demo/servicec/src/main/resources/application.yaml diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml b/demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml similarity index 91% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml rename to demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml index 1eb1ffca6..f0846c90c 100644 --- a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml +++ b/demo/saga-dubbo-demo/servicec/src/main/resources/dubbo-context.xml @@ -23,6 +23,6 @@ - - - \ No newline at end of file + + + diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/jdbc.xml b/demo/saga-dubbo-demo/servicec/src/main/resources/jdbc.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/jdbc.xml rename to demo/saga-dubbo-demo/servicec/src/main/resources/jdbc.xml diff --git a/saga-demo/saga-dubbo-demo/servicea/src/main/resources/log4j2.xml b/demo/saga-dubbo-demo/servicec/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicea/src/main/resources/log4j2.xml rename to demo/saga-dubbo-demo/servicec/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/schema-mysql.sql b/demo/saga-dubbo-demo/servicec/src/main/resources/schema-mysql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/schema-mysql.sql rename to demo/saga-dubbo-demo/servicec/src/main/resources/schema-mysql.sql diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/schema-postgresql.sql b/demo/saga-dubbo-demo/servicec/src/main/resources/schema-postgresql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/schema-postgresql.sql rename to demo/saga-dubbo-demo/servicec/src/main/resources/schema-postgresql.sql diff --git a/saga-demo/saga-dubbo-demo/sql/schema-mysql.sql b/demo/saga-dubbo-demo/sql/schema-mysql.sql similarity index 100% rename from saga-demo/saga-dubbo-demo/sql/schema-mysql.sql rename to demo/saga-dubbo-demo/sql/schema-mysql.sql diff --git a/saga-demo/saga-k8s-resources/README.md b/demo/saga-k8s-resources/README.md similarity index 100% rename from saga-demo/saga-k8s-resources/README.md rename to demo/saga-k8s-resources/README.md diff --git a/saga-demo/saga-k8s-resources/base/alpha.yaml b/demo/saga-k8s-resources/base/alpha.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/base/alpha.yaml rename to demo/saga-k8s-resources/base/alpha.yaml diff --git a/saga-demo/saga-k8s-resources/base/jmeter-collector.yaml b/demo/saga-k8s-resources/base/jmeter-collector.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/base/jmeter-collector.yaml rename to demo/saga-k8s-resources/base/jmeter-collector.yaml diff --git a/saga-demo/saga-k8s-resources/base/postgresql.yaml b/demo/saga-k8s-resources/base/postgresql.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/base/postgresql.yaml rename to demo/saga-k8s-resources/base/postgresql.yaml diff --git a/saga-demo/saga-k8s-resources/spring-demo/booking.yaml b/demo/saga-k8s-resources/spring-demo/booking.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/spring-demo/booking.yaml rename to demo/saga-k8s-resources/spring-demo/booking.yaml diff --git a/saga-demo/saga-k8s-resources/spring-demo/car.yaml b/demo/saga-k8s-resources/spring-demo/car.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/spring-demo/car.yaml rename to demo/saga-k8s-resources/spring-demo/car.yaml diff --git a/saga-demo/saga-k8s-resources/spring-demo/hotel.yaml b/demo/saga-k8s-resources/spring-demo/hotel.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/spring-demo/hotel.yaml rename to demo/saga-k8s-resources/spring-demo/hotel.yaml diff --git a/saga-demo/saga-k8s-resources/spring-demo/test/jmeter.configmap.yaml b/demo/saga-k8s-resources/spring-demo/test/jmeter.configmap.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/spring-demo/test/jmeter.configmap.yaml rename to demo/saga-k8s-resources/spring-demo/test/jmeter.configmap.yaml diff --git a/saga-demo/saga-k8s-resources/spring-demo/test/jmeter.yaml b/demo/saga-k8s-resources/spring-demo/test/jmeter.yaml similarity index 100% rename from saga-demo/saga-k8s-resources/spring-demo/test/jmeter.yaml rename to demo/saga-k8s-resources/spring-demo/test/jmeter.yaml diff --git a/saga-demo/saga-servicecomb-demo/README.md b/demo/saga-servicecomb-demo/README.md similarity index 100% rename from saga-demo/saga-servicecomb-demo/README.md rename to demo/saga-servicecomb-demo/README.md diff --git a/saga-demo/saga-servicecomb-demo/docker-compose.yaml b/demo/saga-servicecomb-demo/docker-compose.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/docker-compose.yaml rename to demo/saga-servicecomb-demo/docker-compose.yaml diff --git a/saga-demo/saga-servicecomb-demo/pom.xml b/demo/saga-servicecomb-demo/pom.xml similarity index 95% rename from saga-demo/saga-servicecomb-demo/pom.xml rename to demo/saga-servicecomb-demo/pom.xml index ef8f46bcf..4b47f3de3 100644 --- a/saga-demo/saga-servicecomb-demo/pom.xml +++ b/demo/saga-servicecomb-demo/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 saga-servicecomb-demo - Saga::Demo::ServiceComb-Demo + Pack::Demo::ServiceComb-Demo pom @@ -71,11 +71,11 @@ hibernate-validator - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-servicecomb diff --git a/saga-demo/saga-servicecomb-demo/saga-servicecomb-demo.sh b/demo/saga-servicecomb-demo/saga-servicecomb-demo.sh similarity index 100% rename from saga-demo/saga-servicecomb-demo/saga-servicecomb-demo.sh rename to demo/saga-servicecomb-demo/saga-servicecomb-demo.sh diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/pom.xml b/demo/saga-servicecomb-demo/scb-booking/pom.xml similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-booking/pom.xml rename to demo/saga-servicecomb-demo/scb-booking/pom.xml index 4a21c108b..8468418f6 100644 --- a/saga-demo/saga-servicecomb-demo/scb-booking/pom.xml +++ b/demo/saga-servicecomb-demo/scb-booking/pom.xml @@ -21,12 +21,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-servicecomb-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 scb-booking - Saga::Demo::ServiceComb-Demo::Booking + Pack::Demo::ServiceComb-Demo::Booking - \ No newline at end of file + diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingApplication.java b/demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingApplication.java similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingApplication.java rename to demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingApplication.java index bc2433767..a74933ea3 100644 --- a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingApplication.java +++ b/demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingApplication.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.booking; +package org.apache.servicecomb.pack.demo.scb.booking; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingController.java b/demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingController.java similarity index 86% rename from saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingController.java rename to demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingController.java index cc6947b98..737d88962 100644 --- a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/saga/demo/scb/booking/BookingController.java +++ b/demo/saga-servicecomb-demo/scb-booking/src/main/java/org/apache/servicecomb/pack/demo/scb/booking/BookingController.java @@ -15,17 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.booking; +package org.apache.servicecomb.pack.demo.scb.booking; import org.apache.servicecomb.provider.rest.common.RestSchema; import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; -import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestSchema(schemaId = "booking") diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/application.yaml b/demo/saga-servicecomb-demo/scb-booking/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/application.yaml rename to demo/saga-servicecomb-demo/scb-booking/src/main/resources/application.yaml diff --git a/saga-demo/saga-dubbo-demo/serviceb/src/main/resources/log4j2.xml b/demo/saga-servicecomb-demo/scb-booking/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/serviceb/src/main/resources/log4j2.xml rename to demo/saga-servicecomb-demo/scb-booking/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/microservice.yaml b/demo/saga-servicecomb-demo/scb-booking/src/main/resources/microservice.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/microservice.yaml rename to demo/saga-servicecomb-demo/scb-booking/src/main/resources/microservice.yaml diff --git a/saga-demo/saga-servicecomb-demo/scb-car/pom.xml b/demo/saga-servicecomb-demo/scb-car/pom.xml similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-car/pom.xml rename to demo/saga-servicecomb-demo/scb-car/pom.xml index 8f13b373f..4746871e6 100644 --- a/saga-demo/saga-servicecomb-demo/scb-car/pom.xml +++ b/demo/saga-servicecomb-demo/scb-car/pom.xml @@ -21,12 +21,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-servicecomb-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 scb-car - Saga::Demo::ServiceComb-Demo::Car + Pack::Demo::ServiceComb-Demo::Car - \ No newline at end of file + diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarApplication.java b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarApplication.java similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarApplication.java rename to demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarApplication.java index 435168dbf..8ffe0d378 100644 --- a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarApplication.java +++ b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarApplication.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.car; +package org.apache.servicecomb.pack.demo.scb.car; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBooking.java b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBooking.java similarity index 97% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBooking.java rename to demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBooking.java index 497f278df..9ca4ec33e 100644 --- a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBooking.java +++ b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBooking.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.car; +package org.apache.servicecomb.pack.demo.scb.car; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingController.java b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingController.java similarity index 97% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingController.java rename to demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingController.java index 35ff1467a..9426fd3d9 100644 --- a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingController.java +++ b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.car; +package org.apache.servicecomb.pack.demo.scb.car; import java.util.ArrayList; import java.util.List; diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingService.java b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingService.java similarity index 92% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingService.java rename to demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingService.java index a94cf098b..b0804538e 100644 --- a/saga-demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/saga/demo/scb/car/CarBookingService.java +++ b/demo/saga-servicecomb-demo/scb-car/src/main/java/org/apache/servicecomb/pack/demo/scb/car/CarBookingService.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.car; +package org.apache.servicecomb.pack.demo.scb.car; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.stereotype.Service; @Service diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/application.yaml b/demo/saga-servicecomb-demo/scb-car/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/application.yaml rename to demo/saga-servicecomb-demo/scb-car/src/main/resources/application.yaml diff --git a/saga-demo/saga-dubbo-demo/servicec/src/main/resources/log4j2.xml b/demo/saga-servicecomb-demo/scb-car/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-dubbo-demo/servicec/src/main/resources/log4j2.xml rename to demo/saga-servicecomb-demo/scb-car/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/microservice.yaml b/demo/saga-servicecomb-demo/scb-car/src/main/resources/microservice.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/microservice.yaml rename to demo/saga-servicecomb-demo/scb-car/src/main/resources/microservice.yaml diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/pom.xml b/demo/saga-servicecomb-demo/scb-hotel/pom.xml similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-hotel/pom.xml rename to demo/saga-servicecomb-demo/scb-hotel/pom.xml index b617d4d44..fce548e89 100644 --- a/saga-demo/saga-servicecomb-demo/scb-hotel/pom.xml +++ b/demo/saga-servicecomb-demo/scb-hotel/pom.xml @@ -21,12 +21,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga-servicecomb-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 scb-hotel - Saga::Demo::ServiceComb-Demo::Hotel + Pack::Demo::ServiceComb-Demo::Hotel - \ No newline at end of file + diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelApplication.java b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelApplication.java similarity index 91% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelApplication.java rename to demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelApplication.java index ce8c0cbc1..b14510853 100644 --- a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelApplication.java +++ b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelApplication.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.hotel; +package org.apache.servicecomb.pack.demo.scb.hotel; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBooking.java b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBooking.java similarity index 97% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBooking.java rename to demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBooking.java index b183a793a..d0c489ff2 100644 --- a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBooking.java +++ b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBooking.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.hotel; +package org.apache.servicecomb.pack.demo.scb.hotel; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingController.java b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingController.java similarity index 97% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingController.java rename to demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingController.java index d7d3cd377..eed7a381d 100644 --- a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingController.java +++ b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.hotel; +package org.apache.servicecomb.pack.demo.scb.hotel; import java.util.ArrayList; import java.util.List; diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingService.java b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingService.java similarity index 93% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingService.java rename to demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingService.java index 4d4d55001..bf0518367 100644 --- a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/saga/demo/scb/hotel/HotelBookingService.java +++ b/demo/saga-servicecomb-demo/scb-hotel/src/main/java/org/apache/servicecomb/pack/demo/scb/hotel/HotelBookingService.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.scb.hotel; +package org.apache.servicecomb.pack.demo.scb.hotel; import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.stereotype.Service; @Service diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/application.yaml b/demo/saga-servicecomb-demo/scb-hotel/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/application.yaml rename to demo/saga-servicecomb-demo/scb-hotel/src/main/resources/application.yaml diff --git a/saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/log4j2.xml b/demo/saga-servicecomb-demo/scb-hotel/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-booking/src/main/resources/log4j2.xml rename to demo/saga-servicecomb-demo/scb-hotel/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/microservice.yaml b/demo/saga-servicecomb-demo/scb-hotel/src/main/resources/microservice.yaml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/microservice.yaml rename to demo/saga-servicecomb-demo/scb-hotel/src/main/resources/microservice.yaml diff --git a/saga-demo/saga-spring-demo/README.md b/demo/saga-spring-demo/README.md similarity index 100% rename from saga-demo/saga-spring-demo/README.md rename to demo/saga-spring-demo/README.md diff --git a/saga-demo/saga-spring-demo/booking/pom.xml b/demo/saga-spring-demo/booking/pom.xml similarity index 93% rename from saga-demo/saga-spring-demo/booking/pom.xml rename to demo/saga-spring-demo/booking/pom.xml index b1d77c8d7..6f854e738 100644 --- a/saga-demo/saga-spring-demo/booking/pom.xml +++ b/demo/saga-spring-demo/booking/pom.xml @@ -19,13 +19,13 @@ saga-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 booking - Saga::Demo::Spring-Demo::Booking + Pack::Demo::Spring-Demo::Booking @@ -37,11 +37,11 @@ spring-boot-starter-web - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate diff --git a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/Application.java b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/Application.java similarity index 90% rename from saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/Application.java rename to demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/Application.java index a4fe3d986..03ce0b74c 100644 --- a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/Application.java +++ b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/Application.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.car; +package org.apache.servicecomb.pack.demo.booking; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/BookingController.java b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/BookingController.java similarity index 94% rename from saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/BookingController.java rename to demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/BookingController.java index 509132163..4481c2aaa 100644 --- a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/BookingController.java +++ b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/BookingController.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.booking; +package org.apache.servicecomb.pack.demo.booking; -import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.PathVariable; diff --git a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/MyConfiguration.java similarity index 96% rename from saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java rename to demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/MyConfiguration.java index 0fc5e09c4..504d8ced5 100644 --- a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/MyConfiguration.java +++ b/demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/pack/demo/booking/MyConfiguration.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.booking; +package org.apache.servicecomb.pack.demo.booking; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/saga-demo/saga-spring-demo/booking/src/main/resources/application.yaml b/demo/saga-spring-demo/booking/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-spring-demo/booking/src/main/resources/application.yaml rename to demo/saga-spring-demo/booking/src/main/resources/application.yaml diff --git a/saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/log4j2.xml b/demo/saga-spring-demo/booking/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-car/src/main/resources/log4j2.xml rename to demo/saga-spring-demo/booking/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-spring-demo/booking/src/main/resources/static/index.html b/demo/saga-spring-demo/booking/src/main/resources/static/index.html similarity index 100% rename from saga-demo/saga-spring-demo/booking/src/main/resources/static/index.html rename to demo/saga-spring-demo/booking/src/main/resources/static/index.html diff --git a/saga-demo/saga-spring-demo/car/pom.xml b/demo/saga-spring-demo/car/pom.xml similarity index 93% rename from saga-demo/saga-spring-demo/car/pom.xml rename to demo/saga-spring-demo/car/pom.xml index 169c13e33..7314c54e4 100644 --- a/saga-demo/saga-spring-demo/car/pom.xml +++ b/demo/saga-spring-demo/car/pom.xml @@ -19,13 +19,13 @@ saga-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 car - Saga::Demo::Spring-Demo::Car + Pack::Demo::Spring-Demo::Car @@ -37,11 +37,11 @@ spring-boot-starter-web - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate diff --git a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/Application.java b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/Application.java similarity index 90% rename from saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/Application.java rename to demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/Application.java index 26a55e36a..fc0e47baa 100644 --- a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/Application.java +++ b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/Application.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.hotel; +package org.apache.servicecomb.pack.demo.car; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBooking.java b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBooking.java similarity index 97% rename from saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBooking.java rename to demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBooking.java index 94f40d4a4..8911d3244 100644 --- a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBooking.java +++ b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBooking.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.car; +package org.apache.servicecomb.pack.demo.car; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; diff --git a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingController.java similarity index 97% rename from saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java rename to demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingController.java index 9db37b3ef..35c59aa90 100644 --- a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingController.java +++ b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.car; +package org.apache.servicecomb.pack.demo.car; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; diff --git a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingService.java b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingService.java similarity index 92% rename from saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingService.java rename to demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingService.java index e22528033..a0a6c31b7 100644 --- a/saga-demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/saga/demo/pack/car/CarBookingService.java +++ b/demo/saga-spring-demo/car/src/main/java/org/apache/servicecomb/pack/demo/car/CarBookingService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.car; +package org.apache.servicecomb.pack.demo.car; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.stereotype.Service; import java.util.Collection; diff --git a/saga-demo/saga-spring-demo/car/src/main/resources/application.yaml b/demo/saga-spring-demo/car/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-spring-demo/car/src/main/resources/application.yaml rename to demo/saga-spring-demo/car/src/main/resources/application.yaml diff --git a/saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/log4j2.xml b/demo/saga-spring-demo/car/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-servicecomb-demo/scb-hotel/src/main/resources/log4j2.xml rename to demo/saga-spring-demo/car/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-spring-demo/docker-compose-alpha-perf.yaml b/demo/saga-spring-demo/docker-compose-alpha-perf.yaml similarity index 100% rename from saga-demo/saga-spring-demo/docker-compose-alpha-perf.yaml rename to demo/saga-spring-demo/docker-compose-alpha-perf.yaml diff --git a/saga-demo/saga-spring-demo/docker-compose-alpha.yaml b/demo/saga-spring-demo/docker-compose-alpha.yaml similarity index 100% rename from saga-demo/saga-spring-demo/docker-compose-alpha.yaml rename to demo/saga-spring-demo/docker-compose-alpha.yaml diff --git a/saga-demo/saga-spring-demo/docker-compose-demo.yaml b/demo/saga-spring-demo/docker-compose-demo.yaml similarity index 100% rename from saga-demo/saga-spring-demo/docker-compose-demo.yaml rename to demo/saga-spring-demo/docker-compose-demo.yaml diff --git a/saga-demo/saga-spring-demo/docker-compose.mysql.yaml b/demo/saga-spring-demo/docker-compose.mysql.yaml similarity index 100% rename from saga-demo/saga-spring-demo/docker-compose.mysql.yaml rename to demo/saga-spring-demo/docker-compose.mysql.yaml diff --git a/saga-demo/saga-spring-demo/docker-compose.yaml b/demo/saga-spring-demo/docker-compose.yaml similarity index 100% rename from saga-demo/saga-spring-demo/docker-compose.yaml rename to demo/saga-spring-demo/docker-compose.yaml diff --git a/saga-demo/saga-spring-demo/hotel/pom.xml b/demo/saga-spring-demo/hotel/pom.xml similarity index 93% rename from saga-demo/saga-spring-demo/hotel/pom.xml rename to demo/saga-spring-demo/hotel/pom.xml index 57c855793..56fc35c53 100644 --- a/saga-demo/saga-spring-demo/hotel/pom.xml +++ b/demo/saga-spring-demo/hotel/pom.xml @@ -19,13 +19,13 @@ saga-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 hotel - Saga::Demo::Spring-Demo::Hotel + Pack::Demo::Spring-Demo::Hotel @@ -37,11 +37,11 @@ spring-boot-starter-web - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate diff --git a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/Application.java b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/Application.java similarity index 90% rename from saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/Application.java rename to demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/Application.java index 2dda806ea..1bb9d1033 100644 --- a/saga-demo/saga-spring-demo/booking/src/main/java/org/apache/servicecomb/saga/demo/pack/booking/Application.java +++ b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/Application.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.booking; +package org.apache.servicecomb.pack.demo.hotel; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBooking.java b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBooking.java similarity index 97% rename from saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBooking.java rename to demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBooking.java index e621b23bd..f6d3c15ce 100644 --- a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBooking.java +++ b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBooking.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.hotel; +package org.apache.servicecomb.pack.demo.hotel; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; diff --git a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingController.java similarity index 97% rename from saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java rename to demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingController.java index 6582819d4..4c095a3f4 100644 --- a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingController.java +++ b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingController.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.hotel; +package org.apache.servicecomb.pack.demo.hotel; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; diff --git a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingService.java b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingService.java similarity index 93% rename from saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingService.java rename to demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingService.java index 9abf0407b..395ecbd62 100644 --- a/saga-demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/saga/demo/pack/hotel/HotelBookingService.java +++ b/demo/saga-spring-demo/hotel/src/main/java/org/apache/servicecomb/pack/demo/hotel/HotelBookingService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.demo.pack.hotel; +package org.apache.servicecomb.pack.demo.hotel; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.stereotype.Service; import java.util.Collection; diff --git a/saga-demo/saga-spring-demo/hotel/src/main/resources/application.yaml b/demo/saga-spring-demo/hotel/src/main/resources/application.yaml similarity index 100% rename from saga-demo/saga-spring-demo/hotel/src/main/resources/application.yaml rename to demo/saga-spring-demo/hotel/src/main/resources/application.yaml diff --git a/saga-demo/saga-spring-demo/booking/src/main/resources/log4j2.xml b/demo/saga-spring-demo/hotel/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-spring-demo/booking/src/main/resources/log4j2.xml rename to demo/saga-spring-demo/hotel/src/main/resources/log4j2.xml diff --git a/saga-demo/saga-spring-demo/pom.xml b/demo/saga-spring-demo/pom.xml similarity index 94% rename from saga-demo/saga-spring-demo/pom.xml rename to demo/saga-spring-demo/pom.xml index 63aff40d8..ba31f5c66 100644 --- a/saga-demo/saga-spring-demo/pom.xml +++ b/demo/saga-spring-demo/pom.xml @@ -19,13 +19,13 @@ saga-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 saga-spring-demo - Saga::Demo::Spring-Demo + Pack::Demo::Spring-Demo pom diff --git a/saga-demo/saga-spring-demo/saga-demo.sh b/demo/saga-spring-demo/saga-demo.sh similarity index 100% rename from saga-demo/saga-spring-demo/saga-demo.sh rename to demo/saga-spring-demo/saga-demo.sh diff --git a/saga-demo/tcc-spring-demo/README.md b/demo/tcc-spring-demo/README.md similarity index 100% rename from saga-demo/tcc-spring-demo/README.md rename to demo/tcc-spring-demo/README.md diff --git a/saga-demo/tcc-spring-demo/docker-compose-alpha.yaml b/demo/tcc-spring-demo/docker-compose-alpha.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/docker-compose-alpha.yaml rename to demo/tcc-spring-demo/docker-compose-alpha.yaml diff --git a/saga-demo/tcc-spring-demo/docker-compose-demo.yaml b/demo/tcc-spring-demo/docker-compose-demo.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/docker-compose-demo.yaml rename to demo/tcc-spring-demo/docker-compose-demo.yaml diff --git a/saga-demo/tcc-spring-demo/docker-compose.mysql.yaml b/demo/tcc-spring-demo/docker-compose.mysql.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/docker-compose.mysql.yaml rename to demo/tcc-spring-demo/docker-compose.mysql.yaml diff --git a/saga-demo/tcc-spring-demo/docker-compose.yaml b/demo/tcc-spring-demo/docker-compose.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/docker-compose.yaml rename to demo/tcc-spring-demo/docker-compose.yaml diff --git a/saga-demo/tcc-spring-demo/inventory/pom.xml b/demo/tcc-spring-demo/inventory/pom.xml similarity index 94% rename from saga-demo/tcc-spring-demo/inventory/pom.xml rename to demo/tcc-spring-demo/inventory/pom.xml index bd2f287e3..f4b8a8542 100644 --- a/saga-demo/tcc-spring-demo/inventory/pom.xml +++ b/demo/tcc-spring-demo/inventory/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> tcc-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 tcc-inventory - Saga::Demo::Tcc-Spring-Demo::Tcc-Inventory + Pack::Demo::Tcc-Spring-Demo::Tcc-Inventory @@ -47,8 +47,8 @@ - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java similarity index 97% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java index 5ff8db141..d4d057bf4 100644 --- a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java +++ b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryService.java @@ -23,7 +23,7 @@ import javax.transaction.Transactional; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/Product.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/Product.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/Product.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/Product.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductController.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductController.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductController.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductController.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductDao.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductDao.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductDao.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductDao.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductOrder.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductOrder.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductOrder.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductOrder.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java similarity index 96% rename from saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java rename to demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java index 878c15611..64afe302d 100644 --- a/saga-demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java +++ b/demo/tcc-spring-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/pack/inventory/TccInventoryApplication.java @@ -17,7 +17,7 @@ package org.apache.servicecomb.saga.demo.pack.inventory; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/resources/application.yaml b/demo/tcc-spring-demo/inventory/src/main/resources/application.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/resources/application.yaml rename to demo/tcc-spring-demo/inventory/src/main/resources/application.yaml diff --git a/saga-demo/saga-spring-demo/car/src/main/resources/log4j2.xml b/demo/tcc-spring-demo/inventory/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-spring-demo/car/src/main/resources/log4j2.xml rename to demo/tcc-spring-demo/inventory/src/main/resources/log4j2.xml diff --git a/saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryServiceTest.java b/demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryServiceTest.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryServiceTest.java rename to demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/InventoryServiceTest.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductControllerTest.java b/demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductControllerTest.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductControllerTest.java rename to demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/ProductControllerTest.java diff --git a/saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/TestApplication.java b/demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/TestApplication.java similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/TestApplication.java rename to demo/tcc-spring-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/pack/inventory/TestApplication.java diff --git a/saga-demo/tcc-spring-demo/ordering/pom.xml b/demo/tcc-spring-demo/ordering/pom.xml similarity index 95% rename from saga-demo/tcc-spring-demo/ordering/pom.xml rename to demo/tcc-spring-demo/ordering/pom.xml index 8158a3522..ceb8b00a6 100644 --- a/saga-demo/tcc-spring-demo/ordering/pom.xml +++ b/demo/tcc-spring-demo/ordering/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> tcc-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 tcc-ordering - Saga::Demo::Tcc-Spring-Demo::Tcc-Ordering + Pack::Demo::Tcc-Spring-Demo::Tcc-Ordering diff --git a/saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java b/demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java similarity index 97% rename from saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java rename to demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java index 5affe768d..c5e9ea6af 100644 --- a/saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java +++ b/demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/OrderingController.java @@ -16,7 +16,7 @@ */ package org.apache.servicecomb.saga.demo.pack.ordering; -import org.apache.servicecomb.saga.omega.context.annotations.TccStart; +import org.apache.servicecomb.pack.omega.context.annotations.TccStart; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; diff --git a/saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java b/demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java similarity index 95% rename from saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java rename to demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java index a4000feef..f482e42b4 100644 --- a/saga-demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java +++ b/demo/tcc-spring-demo/ordering/src/main/java/org/apache/servicecomb/saga/demo/pack/ordering/TccOrderingApplication.java @@ -17,7 +17,7 @@ package org.apache.servicecomb.saga.demo.pack.ordering; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/tcc-spring-demo/ordering/src/main/resources/application.yaml b/demo/tcc-spring-demo/ordering/src/main/resources/application.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/ordering/src/main/resources/application.yaml rename to demo/tcc-spring-demo/ordering/src/main/resources/application.yaml diff --git a/saga-demo/saga-spring-demo/hotel/src/main/resources/log4j2.xml b/demo/tcc-spring-demo/ordering/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/saga-spring-demo/hotel/src/main/resources/log4j2.xml rename to demo/tcc-spring-demo/ordering/src/main/resources/log4j2.xml diff --git a/saga-demo/tcc-spring-demo/payment/pom.xml b/demo/tcc-spring-demo/payment/pom.xml similarity index 94% rename from saga-demo/tcc-spring-demo/payment/pom.xml rename to demo/tcc-spring-demo/payment/pom.xml index 9c07521da..4fdf0891e 100644 --- a/saga-demo/tcc-spring-demo/payment/pom.xml +++ b/demo/tcc-spring-demo/payment/pom.xml @@ -19,13 +19,13 @@ tcc-spring-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 tcc-payment - Saga::Demo::Tcc-Spring-Demo::Tcc-Payment + Pack::Demo::Tcc-Spring-Demo::Tcc-Payment @@ -45,8 +45,8 @@ - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Account.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Account.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Account.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Account.java diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/AccountDao.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/AccountDao.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/AccountDao.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/AccountDao.java diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Payment.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Payment.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Payment.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/Payment.java diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentController.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentController.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentController.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentController.java diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java similarity index 97% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java index b10d72fe2..2fb1ec269 100644 --- a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java +++ b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentService.java @@ -21,7 +21,7 @@ import java.util.Objects; import java.util.concurrent.ConcurrentHashMap; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java similarity index 96% rename from saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java rename to demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java index 40f67c4de..fa5720b1e 100644 --- a/saga-demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java +++ b/demo/tcc-spring-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/pack/payment/TccPaymentApplication.java @@ -17,7 +17,7 @@ package org.apache.servicecomb.saga.demo.pack.payment; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/saga-demo/tcc-spring-demo/payment/src/main/resources/application.yaml b/demo/tcc-spring-demo/payment/src/main/resources/application.yaml similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/main/resources/application.yaml rename to demo/tcc-spring-demo/payment/src/main/resources/application.yaml diff --git a/saga-demo/tcc-spring-demo/inventory/src/main/resources/log4j2.xml b/demo/tcc-spring-demo/payment/src/main/resources/log4j2.xml similarity index 100% rename from saga-demo/tcc-spring-demo/inventory/src/main/resources/log4j2.xml rename to demo/tcc-spring-demo/payment/src/main/resources/log4j2.xml diff --git a/saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentControllerTest.java b/demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentControllerTest.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentControllerTest.java rename to demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentControllerTest.java diff --git a/saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentServiceTest.java b/demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentServiceTest.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentServiceTest.java rename to demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/PaymentServiceTest.java diff --git a/saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/TestApplication.java b/demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/TestApplication.java similarity index 100% rename from saga-demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/TestApplication.java rename to demo/tcc-spring-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/pack/payment/TestApplication.java diff --git a/saga-demo/tcc-spring-demo/pom.xml b/demo/tcc-spring-demo/pom.xml similarity index 91% rename from saga-demo/tcc-spring-demo/pom.xml rename to demo/tcc-spring-demo/pom.xml index 76bc069b7..99fdfa058 100644 --- a/saga-demo/tcc-spring-demo/pom.xml +++ b/demo/tcc-spring-demo/pom.xml @@ -19,13 +19,13 @@ saga-demo - org.apache.servicecomb.saga.demo + org.apache.servicecomb.pack.demo 0.3.0-SNAPSHOT 4.0.0 tcc-spring-demo - Saga::Demo::Tcc-Spring-Demo + Pack::Demo::Tcc-Spring-Demo pom @@ -49,11 +49,11 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate diff --git a/saga-demo/tcc-spring-demo/saga-demo.sh b/demo/tcc-spring-demo/saga-demo.sh similarity index 100% rename from saga-demo/tcc-spring-demo/saga-demo.sh rename to demo/tcc-spring-demo/saga-demo.sh diff --git a/saga-distribution/pom.xml b/distribution/pom.xml similarity index 83% rename from saga-distribution/pom.xml rename to distribution/pom.xml index aeab76a87..dc680287e 100644 --- a/saga-distribution/pom.xml +++ b/distribution/pom.xml @@ -19,60 +19,60 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.apache.servicecomb.saga + org.apache.servicecomb.pack saga 0.3.0-SNAPSHOT apache-servicecomb-incubating-saga-distribution - Saga::Distribution + Pack::Distribution pom - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-tx - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-dubbo - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-feign - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-connector-grpc - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-format - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-core - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-contract-grpc - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common diff --git a/saga-distribution/src/assembly/bin.xml b/distribution/src/assembly/bin.xml similarity index 100% rename from saga-distribution/src/assembly/bin.xml rename to distribution/src/assembly/bin.xml diff --git a/saga-distribution/src/assembly/src.xml b/distribution/src/assembly/src.xml similarity index 100% rename from saga-distribution/src/assembly/src.xml rename to distribution/src/assembly/src.xml diff --git a/saga-distribution/src/release/LICENSE b/distribution/src/release/LICENSE similarity index 100% rename from saga-distribution/src/release/LICENSE rename to distribution/src/release/LICENSE diff --git a/saga-distribution/src/release/NOTICE b/distribution/src/release/NOTICE similarity index 100% rename from saga-distribution/src/release/NOTICE rename to distribution/src/release/NOTICE diff --git a/saga-distribution/src/release/licenses/LICENSE-asm b/distribution/src/release/licenses/LICENSE-asm similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-asm rename to distribution/src/release/licenses/LICENSE-asm diff --git a/saga-distribution/src/release/licenses/LICENSE-boringssl b/distribution/src/release/licenses/LICENSE-boringssl similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-boringssl rename to distribution/src/release/licenses/LICENSE-boringssl diff --git a/saga-distribution/src/release/licenses/LICENSE-epl-v10 b/distribution/src/release/licenses/LICENSE-epl-v10 similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-epl-v10 rename to distribution/src/release/licenses/LICENSE-epl-v10 diff --git a/saga-distribution/src/release/licenses/LICENSE-esotericsoftware b/distribution/src/release/licenses/LICENSE-esotericsoftware similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-esotericsoftware rename to distribution/src/release/licenses/LICENSE-esotericsoftware diff --git a/saga-distribution/src/release/licenses/LICENSE-javax b/distribution/src/release/licenses/LICENSE-javax similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-javax rename to distribution/src/release/licenses/LICENSE-javax diff --git a/saga-distribution/src/release/licenses/LICENSE-logback b/distribution/src/release/licenses/LICENSE-logback similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-logback rename to distribution/src/release/licenses/LICENSE-logback diff --git a/saga-distribution/src/release/licenses/LICENSE-ngxadmin b/distribution/src/release/licenses/LICENSE-ngxadmin similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-ngxadmin rename to distribution/src/release/licenses/LICENSE-ngxadmin diff --git a/saga-distribution/src/release/licenses/LICENSE-openfeign b/distribution/src/release/licenses/LICENSE-openfeign similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-openfeign rename to distribution/src/release/licenses/LICENSE-openfeign diff --git a/saga-distribution/src/release/licenses/LICENSE-postgresql b/distribution/src/release/licenses/LICENSE-postgresql similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-postgresql rename to distribution/src/release/licenses/LICENSE-postgresql diff --git a/saga-distribution/src/release/licenses/LICENSE-protobuf b/distribution/src/release/licenses/LICENSE-protobuf similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-protobuf rename to distribution/src/release/licenses/LICENSE-protobuf diff --git a/saga-distribution/src/release/licenses/LICENSE-slf4j b/distribution/src/release/licenses/LICENSE-slf4j similarity index 100% rename from saga-distribution/src/release/licenses/LICENSE-slf4j rename to distribution/src/release/licenses/LICENSE-slf4j diff --git a/saga-distribution/src/release/licenses/NOTICE-grpc b/distribution/src/release/licenses/NOTICE-grpc similarity index 100% rename from saga-distribution/src/release/licenses/NOTICE-grpc rename to distribution/src/release/licenses/NOTICE-grpc diff --git a/saga-distribution/src/release/licenses/NOTICE-netty b/distribution/src/release/licenses/NOTICE-netty similarity index 100% rename from saga-distribution/src/release/licenses/NOTICE-netty rename to distribution/src/release/licenses/NOTICE-netty diff --git a/saga-distribution/src/release/licenses/NOTICE-netty-tcnative b/distribution/src/release/licenses/NOTICE-netty-tcnative similarity index 100% rename from saga-distribution/src/release/licenses/NOTICE-netty-tcnative rename to distribution/src/release/licenses/NOTICE-netty-tcnative diff --git a/saga-distribution/src/release/licenses/NOTICE-tomcat b/distribution/src/release/licenses/NOTICE-tomcat similarity index 100% rename from saga-distribution/src/release/licenses/NOTICE-tomcat rename to distribution/src/release/licenses/NOTICE-tomcat diff --git a/docker-build-config/pom.xml b/docker-build-config/pom.xml index 6395fd842..c14e005ab 100644 --- a/docker-build-config/pom.xml +++ b/docker-build-config/pom.xml @@ -19,13 +19,13 @@ saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 docker-build-config - Saga::Docker Build Config + Pack::Docker Build Config pom diff --git a/docs/api/api.md b/docs/api/api.md deleted file mode 100755 index 756a75c0b..000000000 --- a/docs/api/api.md +++ /dev/null @@ -1,288 +0,0 @@ -# Saga API -### Post transaction and compensation requests to Saga -``` -POST /requests -``` - -#### Description - -1. Define requests in order and recovery policy by JSON format as below,put them to body. -``` -{ - "policy": "", - "requests": [ - { - "id": "", - "type": "", - "serviceName": "", - "parents": [ - - ], - "transaction": { - "method": "", - "path": "", - "retries": "", - "params": { - - } - }, - "compensation": { - "method": "", - "path": "", - "retries": "", - "params": { - - } - } - } - ] -} -``` -JSON parameters: -- policy - support `BackwardRecovery` or `ForwardRecovery`. -- requests - transactions array. - - id - request id. It should be unique among this collection of requests. - - type - support `rest` for now. - - serviceName - user-defined service name. - - parents - request ids. It means this request is only executed after all requests in the parents field are completed. - - transaction - user-defined transaction that executed by the Saga. - - method - user-defined, HTTP method. - - path - user-defined, HTTP path. - - retries - int, optional, default -1. The max retry times for transaction. If this parameter is less than or equal to 0, transaction will retry infinitely. - - params - support `form`,`json`,`body`,`query`. - - compensation - user-defined compensation that executed by the Saga. - - method - user-defined, HTTP method. - - path - user-defined, HTTP path. - - retries - int, optional, default 3. The max retry times for compensation. - - params - support `form`,`json`,`body`,`query`. - -2. Set content type to `text/plain`. - -3. Send them to Saga service. - -#### Example request -``` -curl -XPOST -H "Content-Type: text/plain" -d @./request.json http:///requests -``` - -#### Example response -``` -success -``` - -#### Status codes -- **200** – no error -- **400** – bad parameter -- **500** – server error - - -### Get all the Saga events -``` -GET /events -``` - -#### Description -Get all the Saga events. - -#### Example request -``` -curl -XGET http:///events -``` - -#### Example response -``` -{ - "88658e73-eff5-4d31-887e-019201d6b560": [ - { - "id": 1, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "SagaStartedEvent", - "contentJson": "{\"policy\": \"BackwardRecovery\", \"requests\": [{\"id\": \"request-car\", \"type\": \"rest\", \"serviceName\": \"car-rental-service\", \"transaction\": {\"path\": \"/rentals\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/rentals\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}}, {\"id\": \"request-hotel\", \"type\": \"rest\", \"serviceName\": \"hotel-reservation-service\", \"transaction\": {\"path\": \"/reservations\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/reservations\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}}, {\"id\": \"request-flight\", \"type\": \"rest\", \"serviceName\": \"flight-booking-service\", \"transaction\": {\"path\": \"/bookings\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/bookings\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}}, {\"id\": \"request-payment\", \"type\": \"rest\", \"parents\": [\"request-car\", \"request-flight\", \"request-hotel\"], \"serviceName\": \"payment-service\", \"transaction\": {\"path\": \"/payments\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/payments\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}}]}" - }, - { - "id": 2, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "TransactionStartedEvent", - "contentJson": "{\"id\": \"request-flight\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"flight-booking-service\", \"transaction\": {\"path\": \"/bookings\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/bookings\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}" - }, - { - "id": 3, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "TransactionStartedEvent", - "contentJson": "{\"id\": \"request-car\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"car-rental-service\", \"transaction\": {\"path\": \"/rentals\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/rentals\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}" - }, - { - "id": 4, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "TransactionStartedEvent", - "contentJson": "{\"id\": \"request-hotel\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"hotel-reservation-service\", \"transaction\": {\"path\": \"/reservations\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/reservations\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}" - }, - { - "id": 5, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "TransactionEndedEvent", - "contentJson": "{\"request\": {\"id\": \"request-flight\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"flight-booking-service\", \"transaction\": {\"path\": \"/bookings\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/bookings\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}, \"response\": {\"body\": \"{\\n \\\"statusCode\\\": 200,\\n \\\"content\\\": \\\"Flight booked with id 5b3c462a-b5d4-45b8-b5e4-8c9aa7d1c069 for customer mike\\\"\\n}\"}}" - }, - { - "id": 6, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:40Z", - "type": "TransactionEndedEvent", - "contentJson": "{\"request\": {\"id\": \"request-hotel\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"hotel-reservation-service\", \"transaction\": {\"path\": \"/reservations\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/reservations\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}, \"response\": {\"body\": \"{\\n \\\"statusCode\\\": 200,\\n \\\"content\\\": \\\"Hotel reserved with id eb2366e1-411d-4352-84fb-6b5ab446ec81 for customer mike\\\"\\n}\"}}" - }, - { - "id": 7, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:41Z", - "type": "TransactionEndedEvent", - "contentJson": "{\"request\": {\"id\": \"request-car\", \"type\": \"rest\", \"parents\": [], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"car-rental-service\", \"transaction\": {\"path\": \"/rentals\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/rentals\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}, \"response\": {\"body\": \"{\\n \\\"statusCode\\\": 200,\\n \\\"content\\\": \\\"Car rented with id 3c22da64-d4ac-4870-b9bb-54b603721925 for customer mike\\\"\\n}\"}}" - }, - { - "id": 8, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:41Z", - "type": "TransactionStartedEvent", - "contentJson": "{\"id\": \"request-payment\", \"type\": \"rest\", \"parents\": [\"request-car\", \"request-flight\", \"request-hotel\"], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"payment-service\", \"transaction\": {\"path\": \"/payments\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/payments\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}" - }, - { - "id": 9, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:41Z", - "type": "TransactionEndedEvent", - "contentJson": "{\"request\": {\"id\": \"request-payment\", \"type\": \"rest\", \"parents\": [\"request-car\", \"request-flight\", \"request-hotel\"], \"fallback\": {\"type\": \"NOP\"}, \"serviceName\": \"payment-service\", \"transaction\": {\"path\": \"/payments\", \"method\": \"post\", \"params\": {\"form\": {\"customerId\": \"mike\"}}}, \"compensation\": {\"path\": \"/payments\", \"method\": \"put\", \"params\": {\"form\": {\"customerId\": \"mike\"}}, \"retries\": 3}}, \"response\": {\"body\": \"{\\n \\\"statusCode\\\": 200,\\n \\\"content\\\": \\\"Payment made for customer mike and remaining balance is 200\\\"\\n}\"}}" - }, - { - "id": 10, - "sagaId": "88658e73-eff5-4d31-887e-019201d6b560", - "creationTime": "2017-09-15T01:15:41Z", - "type": "SagaEndedEvent", - "contentJson": "{}" - } - ] -} -``` - -#### Status codes -- **200** – no error - -### Invoke embedded Saga to execute SQL transaction - -In order to Invoke embedded saga, it is necessary to add dependencies to your applications. - -There are a `maven` example - -``` - - - ... - - - org.apache.servicecomb.saga - saga-core - - - org.apache.servicecomb.saga - saga-format - - - ... - - -``` - -#### Description - -1. Implement SQLTransport interface in your own applications. - -2. Instance `SagaExecutionComponent` and inject it into your own applications. - -3. Define requests in order and recovery policy by JSON format as below in your applications. - -``` -{ - "policy": "", - "requests": [ - { - "id": "", - "type": "", - "datasource": "", - "parents": [ - - ], - "transaction": { - "sql": "", - "retries": "", - "params": [ - [] - ] - }, - "compensation": { - "sql": "", - "retries": "", - "params": [ - [] - ] - } - } - ] -} -``` -JSON parameters: -- policy - support `BackwardRecovery` or `ForwardRecovery`. -- requests - transactions array. - - id - request id. It should be unique among this collection of requests. - - type - support `sql` for now. - - datasource - user-defined datasource name. - - parents - request ids. It means this request is only executed after all requests in the parents field are completed. - - transaction - user-defined transaction that executed by the Saga. - - sql - user-defined, forward sql. - - retries - int, optional, default -1. The max retry times for transaction. If this parameter is less than or equal to 0, transaction will retry infinitely. - - params - parameters for forward sql. - - compensation - user-defined compensation that executed by the Saga. - - sql - user-defined, backward sql. - - retries - int, optional, default 3. The max retry times for compensation. - - params - parameters for backward sql. - -4. Invoke `SagaExecutionComponent.run(String json)` function to execute saga. - -#### Example Implement SQLTransport interface - -``` -public class ExampleSQLTransport implements SQLTransport { - @Override - public SagaResponse with(final String datasource, final String sql, final List params) { - try { - // invoke your own code to execute sql. - } catch (Exception e) { - throw new TransportFailedException("execute SQL " + sql + " occur exception: ", e); - } - return new JsonSuccessfulSagaResponse("{}"); - } -} -``` - -#### Example Instance `SagaExecutionComponent` - -``` - private final SQLTransport sqlTransport = new ExampleSQLTransport; - - private final TransportFactory transportFactory = new TransportFactory() { - @Override - public SQLTransport getTransport() { - return sqlTransport; - } - }; - - private final SagaExecutionComponent coordinator = new SagaExecutionComponent( - new EmbeddedPersistentStore(), - new JacksonFromJsonFormat(transportFactory), - null, - new GraphBasedSagaFactory(500, eventStore, new ChildrenExtractor(), Executors.newFixedThreadPool(5)) - ); -``` - diff --git a/docs/old_saga.md b/docs/old_saga.md deleted file mode 100755 index 171b0693a..000000000 --- a/docs/old_saga.md +++ /dev/null @@ -1,53 +0,0 @@ -# Previous Saga's Documentation -## Major Architecture of Saga -* saga-core(transaction and compensation handling logic) -* saga-format(data serialization and deserialization) -* saga-transports(communication protocol implementation such as rest or rpc in the future) -* saga-discovery(service discovery) -* saga-spring(restful service framework) - -![Saga](static_files/saga.png) - -## Prerequisites -You will need: -1. [Oracle JDK 1.8+][jdk] -2. [Maven 3.x][maven] -3. [Docker][docker] -4. [PostgreSQL][postgres] -5. [Service Center(optional)][service_center] -6. [Docker compose(optional)][docker_compose] -7. [Docker machine(optional)][docker_machine] - -[jdk]: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html -[maven]: https://maven.apache.org/install.html -[docker]: https://www.docker.com/get-docker -[postgres]: https://www.postgresql.org/download/ -[service_center]: https://github.com/apache/servicecomb-service-center -[docker_compose]: https://docs.docker.com/compose/install/ -[docker_machine]: https://docs.docker.com/machine/install-machine/ - -## Building -Download the source code. -``` -git clone https://github.com/apache/servicecomb-saga.git -``` - -Enter the Saga root directory,build Saga project by maven command and generate a docker image named saga-spring in local. -``` -mvn package -DskipTests -Pdocker -``` - -## Run Services -A `docker-compose.yaml` file is provided to start Saga services and its dependencies(Service center and Mysql) as docker containers. -User also can configure specified Service center or Mysql in `docker-compose.yaml`. - -Enter the Saga root directory, run all service images using command, -``` -docker-compose up -``` - -## Reference API -See [Saga API](docs/api/api.md) for details. - -## Example -See [Saga demo](https://github.com/apache/servicecomb-saga/tree/master/saga-demo) for details. diff --git a/integration-tests/coverage-aggregate/pom.xml b/integration-tests/coverage-aggregate/pom.xml index ef4df2eb5..8d92958f7 100644 --- a/integration-tests/coverage-aggregate/pom.xml +++ b/integration-tests/coverage-aggregate/pom.xml @@ -18,71 +18,63 @@ - org.apache.servicecomb.saga.tests + org.apache.servicecomb.pack.tests integration-tests 0.3.0-SNAPSHOT 4.0.0 coverage-aggregate - Saga::Integration Tests::Coverage Aggregate + Pack::Integration Tests::Coverage Aggregate - org.apache.servicecomb.saga - saga-core - - - org.apache.servicecomb.saga - saga-format - - - org.apache.servicecomb.saga - saga-spring + org.apache.servicecomb.pack + omega-context - org.apache.servicecomb.saga.transports - transport-httpclient + org.apache.servicecomb.pack + omega-transaction - org.apache.servicecomb.saga.discovery - saga-discovery-servicecenter + org.apache.servicecomb.pack + omega-spring-tx - org.apache.servicecomb.saga - omega-context + org.apache.servicecomb.pack + omega-transport-resttemplate - org.apache.servicecomb.saga - omega-transaction + org.apache.servicecomb.pack + omega-transport-dubbo - org.apache.servicecomb.saga - omega-spring-tx + org.apache.servicecomb.pack + omega-transport-feign - org.apache.servicecomb.saga - omega-transport-resttemplate + org.apache.servicecomb.pack + omega-transport-servicecomb - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-format - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-connector-grpc - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-core - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-server - org.apache.servicecomb.saga.tests + org.apache.servicecomb.pack.tests pack-tests 0.3.0-SNAPSHOT diff --git a/integration-tests/pack-tests/pom.xml b/integration-tests/pack-tests/pom.xml index dcb36785f..dc7d1d95e 100644 --- a/integration-tests/pack-tests/pom.xml +++ b/integration-tests/pack-tests/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> integration-tests - org.apache.servicecomb.saga.tests + org.apache.servicecomb.pack.tests 0.3.0-SNAPSHOT 4.0.0 pack-tests - Saga::Integration Tests::Pack Tests + Pack::Integration Tests @@ -56,19 +56,19 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-core - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate @@ -107,8 +107,8 @@ runtime - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa test diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/CommandEnvelopeRepository.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/CommandEnvelopeRepository.java similarity index 89% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/CommandEnvelopeRepository.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/CommandEnvelopeRepository.java index ad8ae3ae0..b8733d941 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/CommandEnvelopeRepository.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/CommandEnvelopeRepository.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; -import org.apache.servicecomb.saga.alpha.core.Command; +import org.apache.servicecomb.pack.alpha.core.Command; import org.springframework.data.repository.CrudRepository; interface CommandEnvelopeRepository extends CrudRepository { diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingApplication.java similarity index 88% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingApplication.java index c49829c5a..7bae0b45a 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingApplication.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingApplication.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.servicecomb.saga.omega.spring.EnableOmega; +import org.apache.servicecomb.pack.omega.spring.EnableOmega; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; @@ -28,7 +28,7 @@ @EnableOmega @SpringBootApplication -@EntityScan(basePackages = "org.apache.servicecomb.saga.alpha") +@EntityScan(basePackages = "org.apache.servicecomb.pack.alpha") public class GreetingApplication { public static void main(String[] args) { SpringApplication.run(GreetingApplication.class, args); diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingController.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingController.java similarity index 94% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingController.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingController.java index e497cec79..e4f2612c7 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingController.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingController.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; -import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingService.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingService.java similarity index 95% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingService.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingService.java index 554dc15a4..07e0d61f8 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/GreetingService.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/GreetingService.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; import java.util.Queue; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/PackIT.java similarity index 96% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/PackIT.java index ca6376de0..5422ce2ee 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/PackIT.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/PackIT.java @@ -15,10 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; import static java.util.concurrent.TimeUnit.SECONDS; -import static org.apache.servicecomb.saga.integration.pack.tests.GreetingController.TRESPASSER; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.notNullValue; import static org.hamcrest.CoreMatchers.nullValue; @@ -31,8 +30,9 @@ import java.util.List; import java.util.Queue; -import org.apache.servicecomb.saga.alpha.core.TxEvent; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.alpha.core.TxEvent; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.hamcrest.Matchers; import org.junit.After; import org.junit.Test; import org.junit.runner.RunWith; @@ -141,7 +141,7 @@ public void updatesTxStateToAlpha() throws Exception { public void compensatesFailedGlobalTransaction() throws Exception { ResponseEntity entity = restTemplate.getForEntity("/greet?name={name}", String.class, - TRESPASSER); + GreetingController.TRESPASSER); assertThat(entity.getStatusCode(), is(INTERNAL_SERVER_ERROR)); @@ -178,7 +178,7 @@ public void compensatesFailedGlobalTransaction() throws Exception { event = events.get(6); checkedLastTwoEvents(globalTxId, txStartedEvent1, event); - assertThat(compensatedMessages, contains("Goodbye, " + TRESPASSER)); + assertThat(compensatedMessages, Matchers.contains("Goodbye, " + GreetingController.TRESPASSER)); } private void checkedLastTwoEvents(String globalTxId, TxEvent txStartedEvent1, TxEvent event) { @@ -285,7 +285,7 @@ public void compensateWhenRetryReachesMaximum() throws InterruptedException { // retries 3 times and then compensate ResponseEntity entity = restTemplate.getForEntity("/open?name={name}&retries={retries}", String.class, - TRESPASSER, + GreetingController.TRESPASSER, 5); assertThat(entity.getStatusCode(), is(INTERNAL_SERVER_ERROR)); @@ -312,6 +312,6 @@ public void compensateWhenRetryReachesMaximum() throws InterruptedException { assertThat(events.get(9).type(), is("TxAbortedEvent")); assertThat(events.get(10).type(), is("TxCompensatedEvent")); - assertThat(compensatedMessages, contains("Goodbye, " + TRESPASSER)); + assertThat(compensatedMessages, Matchers.contains("Goodbye, " + GreetingController.TRESPASSER)); } } diff --git a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/TxEventEnvelopeRepository.java similarity index 91% rename from integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java rename to integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/TxEventEnvelopeRepository.java index 77bcb8f37..6484e2f87 100644 --- a/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/saga/integration/pack/tests/TxEventEnvelopeRepository.java +++ b/integration-tests/pack-tests/src/test/java/org/apache/servicecomb/pack/integration/tests/TxEventEnvelopeRepository.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.integration.pack.tests; +package org.apache.servicecomb.pack.integration.tests; import java.util.List; -import org.apache.servicecomb.saga.alpha.core.TxEvent; +import org.apache.servicecomb.pack.alpha.core.TxEvent; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.CrudRepository; diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 4253779de..e790890b1 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -19,14 +19,14 @@ saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - org.apache.servicecomb.saga.tests + org.apache.servicecomb.pack.tests integration-tests - Saga::Integration Tests + Pack::Integration Tests pom diff --git a/omega/omega-connector/omega-connector-grpc/pom.xml b/omega/omega-connector/omega-connector-grpc/pom.xml index f4d7bf1a5..b211d9bf0 100644 --- a/omega/omega-connector/omega-connector-grpc/pom.xml +++ b/omega/omega-connector/omega-connector-grpc/pom.xml @@ -23,13 +23,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega-connector - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-connector-grpc - Saga::Omega::Connector::GRPC + Pack::Omega::Connector::GRPC @@ -45,11 +45,11 @@ netty-tcnative-boringssl-static - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-contract-grpc diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/AlphaClusterConfig.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/AlphaClusterConfig.java similarity index 94% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/AlphaClusterConfig.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/AlphaClusterConfig.java index 43fb8fcb5..d590ac377 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/AlphaClusterConfig.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/AlphaClusterConfig.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc; +package org.apache.servicecomb.pack.omega.connector.grpc; import java.util.Collections; import java.util.List; -import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.MessageSerializer; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageDeserializer; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageSerializer; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; public class AlphaClusterConfig { @@ -203,4 +203,4 @@ public MessageHandler getMessageHandler() { public TccMessageHandler getTccMessageHandler() { return tccMessageHandler; } -} \ No newline at end of file +} diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/FastestSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/FastestSender.java similarity index 92% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/FastestSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/FastestSender.java index 486c1b7db..7831f4ed5 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/FastestSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/FastestSender.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import com.google.common.base.Supplier; import java.util.Map; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; /** * The strategy of picking the fastest {@link MessageSender} diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/GrpcOnErrorHandler.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/GrpcOnErrorHandler.java similarity index 94% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/GrpcOnErrorHandler.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/GrpcOnErrorHandler.java index 2a54f967b..d2ad6ee6e 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/GrpcOnErrorHandler.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/GrpcOnErrorHandler.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import com.google.common.base.Supplier; import java.util.Map; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; public class GrpcOnErrorHandler { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContext.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContext.java similarity index 94% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContext.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContext.java index e2425fc0b..46af51492 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContext.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContext.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import io.grpc.ManagedChannel; import java.util.Collection; import java.util.Map; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; public class LoadBalanceContext { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContextBuilder.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContextBuilder.java similarity index 93% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContextBuilder.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContextBuilder.java index 2768135c9..c25e0c8fc 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceContextBuilder.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceContextBuilder.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import com.google.common.base.Optional; import io.grpc.ManagedChannel; @@ -35,11 +35,12 @@ import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import javax.net.ssl.SSLException; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.saga.GrpcSagaClientMessageSender; -import org.apache.servicecomb.saga.omega.connector.grpc.tcc.GrpcTccClientMessageSender; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; + +import org.apache.servicecomb.pack.omega.connector.grpc.saga.GrpcSagaClientMessageSender; +import org.apache.servicecomb.pack.omega.connector.grpc.AlphaClusterConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.tcc.GrpcTccClientMessageSender; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; public class LoadBalanceContextBuilder { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceSenderAdapter.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceSenderAdapter.java similarity index 92% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceSenderAdapter.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceSenderAdapter.java index 424dbbe96..af3a4a446 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/LoadBalanceSenderAdapter.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/LoadBalanceSenderAdapter.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import com.google.common.base.Optional; import io.grpc.ManagedChannel; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/MessageSenderPicker.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/MessageSenderPicker.java similarity index 92% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/MessageSenderPicker.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/MessageSenderPicker.java index c4b669de6..c54974724 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/MessageSenderPicker.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/MessageSenderPicker.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import com.google.common.base.Supplier; import java.util.Collection; import java.util.Map; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; /** * The strategy of picking a specific {@link MessageSender} from a {@link Collection} of {@link diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PendingTaskRunner.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PendingTaskRunner.java similarity index 96% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PendingTaskRunner.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PendingTaskRunner.java index 9bb7c9597..ae0ae2581 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PendingTaskRunner.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PendingTaskRunner.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import static java.util.concurrent.TimeUnit.MILLISECONDS; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PushBackReconnectRunnable.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PushBackReconnectRunnable.java similarity index 95% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PushBackReconnectRunnable.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PushBackReconnectRunnable.java index bc3c1b39e..7e7a729ac 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/PushBackReconnectRunnable.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/PushBackReconnectRunnable.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import java.lang.invoke.MethodHandles; import java.util.Map; import java.util.Objects; import java.util.concurrent.BlockingQueue; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/ReconnectStreamObserver.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/ReconnectStreamObserver.java similarity index 88% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/ReconnectStreamObserver.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/ReconnectStreamObserver.java index bc6971d9b..9fb1270ef 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/ReconnectStreamObserver.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/ReconnectStreamObserver.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; import io.grpc.stub.StreamObserver; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; + +import org.apache.servicecomb.pack.omega.transaction.MessageSender; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/SenderExecutor.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/SenderExecutor.java similarity index 87% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/SenderExecutor.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/SenderExecutor.java index ed0a03f1f..ccf007edb 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/SenderExecutor.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/SenderExecutor.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; public interface SenderExecutor { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/TransactionType.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/TransactionType.java similarity index 93% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/TransactionType.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/TransactionType.java index 236bb5336..fdf0556f4 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/core/TransactionType.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/core/TransactionType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.core; +package org.apache.servicecomb.pack.omega.connector.grpc.core; public enum TransactionType { TCC, SAGA diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java similarity index 82% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java index cdaec1084..0cf9f42cf 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcCompensateStreamObserver.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.ReconnectStreamObserver; -import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.ReconnectStreamObserver; +import org.apache.servicecomb.pack.omega.transaction.MessageDeserializer; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java similarity index 76% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java index 577092001..f55634ff0 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/GrpcSagaClientMessageSender.java @@ -15,25 +15,25 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.MessageSerializer; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; -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.GrpcTxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTxEvent.Builder; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceBlockingStub; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceStub; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.MessageDeserializer; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageSerializer; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent.Builder; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceBlockingStub; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceStub; public class GrpcSagaClientMessageSender implements SagaMessageSender { private final String target; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSender.java similarity index 80% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSender.java index 6869dae65..275c45a85 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSender.java @@ -15,16 +15,16 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; -import static org.apache.servicecomb.saga.common.EventType.SagaStartedEvent; +import static org.apache.servicecomb.pack.common.EventType.SagaStartedEvent; import java.util.concurrent.BlockingQueue; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; public class RetryableMessageSender implements SagaMessageSender { private final BlockingQueue availableMessageSenders; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSender.java similarity index 75% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSender.java index df2a3671a..25eccda52 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSender.java @@ -15,17 +15,18 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import com.google.common.base.Optional; -import org.apache.servicecomb.saga.omega.connector.grpc.core.MessageSenderPicker; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceSenderAdapter; -import org.apache.servicecomb.saga.omega.connector.grpc.core.SenderExecutor; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; + +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceSenderAdapter; +import org.apache.servicecomb.pack.omega.connector.grpc.core.MessageSenderPicker; +import org.apache.servicecomb.pack.omega.connector.grpc.core.SenderExecutor; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; public class SagaLoadBalanceSender extends LoadBalanceSenderAdapter implements SagaMessageSender { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java similarity index 82% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java index e2aec97c6..52a589957 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcCoordinateStreamObserver.java @@ -15,14 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.ReconnectStreamObserver; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinateCommand; + +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.ReconnectStreamObserver; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java similarity index 79% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java index c0020f0b9..e47554258 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSender.java @@ -15,27 +15,28 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import io.grpc.ManagedChannel; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; -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.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceBlockingStub; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceStub; + +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceBlockingStub; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceStub; public class GrpcTccClientMessageSender implements TccMessageSender { diff --git a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSender.java b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSender.java similarity index 83% rename from omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSender.java rename to omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSender.java index a1e762c26..6356b1e8f 100644 --- a/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSender.java +++ b/omega/omega-connector/omega-connector-grpc/src/main/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSender.java @@ -15,20 +15,21 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import com.google.common.base.Optional; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceSenderAdapter; -import org.apache.servicecomb.saga.omega.connector.grpc.core.MessageSenderPicker; -import org.apache.servicecomb.saga.omega.connector.grpc.core.SenderExecutor; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; + +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceSenderAdapter; +import org.apache.servicecomb.pack.omega.connector.grpc.core.MessageSenderPicker; +import org.apache.servicecomb.pack.omega.connector.grpc.core.SenderExecutor; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; public class TccLoadBalanceSender extends LoadBalanceSenderAdapter implements TccMessageSender { diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceContextBuilderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceContextBuilderTest.java similarity index 91% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceContextBuilderTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceContextBuilderTest.java index 9d8ef1dcd..caad66b05 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceContextBuilderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceContextBuilderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc; +package org.apache.servicecomb.pack.omega.connector.grpc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.MatcherAssert.assertThat; @@ -30,15 +30,15 @@ import io.grpc.testing.GrpcCleanupRule; import java.io.IOException; import java.util.ArrayList; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContextBuilder; -import org.apache.servicecomb.saga.omega.connector.grpc.core.TransactionType; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.CoordinateMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; + +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContextBuilder; +import org.apache.servicecomb.pack.omega.connector.grpc.core.TransactionType; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.CoordinateMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceSenderTestBase.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceSenderTestBase.java similarity index 96% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceSenderTestBase.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceSenderTestBase.java index f7c81111a..444e238c1 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/LoadBalanceSenderTestBase.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/LoadBalanceSenderTestBase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc; +package org.apache.servicecomb.pack.omega.connector.grpc; import io.grpc.Server; import java.util.HashMap; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/PushBackReconnectRunnableTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/PushBackReconnectRunnableTest.java similarity index 94% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/PushBackReconnectRunnableTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/PushBackReconnectRunnableTest.java index aad214f9a..54ad5ef5d 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/PushBackReconnectRunnableTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/PushBackReconnectRunnableTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc; +package org.apache.servicecomb.pack.omega.connector.grpc; import static org.hamcrest.Matchers.contains; import static org.hamcrest.core.Is.is; @@ -30,8 +30,8 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.servicecomb.saga.omega.connector.grpc.core.PushBackReconnectRunnable; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.connector.grpc.core.PushBackReconnectRunnable; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSenderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSenderTest.java similarity index 84% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSenderTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSenderTest.java index 6f2970884..c16c143fc 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/RetryableMessageSenderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/RetryableMessageSenderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; @@ -27,13 +27,13 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; -import org.apache.servicecomb.saga.omega.connector.grpc.saga.RetryableMessageSender; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.SagaStartedEvent; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; -import org.apache.servicecomb.saga.omega.transaction.TxStartedEvent; + +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.SagaStartedEvent; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.omega.transaction.TxStartedEvent; import org.junit.Test; public class RetryableMessageSenderTest { diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java similarity index 92% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java index 4b53e83e1..8007f19e8 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalanceSenderWithTLSTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import static java.util.concurrent.TimeUnit.SECONDS; import static org.awaitility.Awaitility.await; @@ -38,12 +38,12 @@ import java.util.Arrays; import java.util.concurrent.Callable; import javax.net.ssl.SSLException; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.core.FastestSender; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContextBuilder; -import org.apache.servicecomb.saga.omega.connector.grpc.core.TransactionType; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.AlphaClusterConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.core.FastestSender; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContextBuilder; +import org.apache.servicecomb.pack.omega.connector.grpc.core.TransactionType; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; import org.junit.BeforeClass; import org.junit.Test; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java similarity index 92% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java index ce6b96e37..9d623ffb0 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static java.lang.Thread.State.TERMINATED; @@ -36,18 +36,18 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.core.FastestSender; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContextBuilder; -import org.apache.servicecomb.saga.omega.connector.grpc.core.TransactionType; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxAbortedEvent; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; -import org.apache.servicecomb.saga.omega.transaction.TxStartedEvent; +import org.apache.servicecomb.pack.omega.connector.grpc.AlphaClusterConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.core.FastestSender; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContextBuilder; +import org.apache.servicecomb.pack.omega.connector.grpc.core.TransactionType; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.TxAbortedEvent; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.omega.transaction.TxStartedEvent; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.Mockito; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java similarity index 86% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java index efefc1563..f29a203dc 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/saga/SagaLoadBalancedSenderTestBase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.saga; +package org.apache.servicecomb.pack.omega.connector.grpc.saga; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.junit.Assert.fail; @@ -27,19 +27,16 @@ import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; -import org.apache.servicecomb.saga.common.EventType; -import org.apache.servicecomb.saga.omega.connector.grpc.saga.SagaLoadBalanceSender; -import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.MessageSerializer; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcAck; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcCompensateCommand; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcServiceConfig; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTxEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceImplBase; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.transaction.MessageDeserializer; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageSerializer; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcCompensateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTxEvent; +import org.apache.servicecomb.pack.contract.grpc.TxEventServiceGrpc.TxEventServiceImplBase; import org.junit.After; import org.junit.AfterClass; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java similarity index 88% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java index 0c425b0e8..0dcdb1445 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/GrpcTccClientMessageSenderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.MatcherAssert.assertThat; @@ -23,23 +23,22 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.connector.grpc.tcc.GrpcTccClientMessageSender; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; -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; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceImplBase; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc.TccEventServiceImplBase; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/MyTccEventServiceImpl.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/MyTccEventServiceImpl.java similarity index 85% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/MyTccEventServiceImpl.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/MyTccEventServiceImpl.java index f2e10cb4d..1b5bb3b7e 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/MyTccEventServiceImpl.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/MyTccEventServiceImpl.java @@ -15,21 +15,21 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import static org.junit.Assert.fail; import io.grpc.stub.StreamObserver; import java.lang.invoke.MethodHandles; import java.util.Queue; -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; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccCoordinatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionEndedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccTransactionStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.TccEventServiceGrpc; +import org.apache.servicecomb.pack.contract.grpc.GrpcAck; +import org.apache.servicecomb.pack.contract.grpc.GrpcServiceConfig; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinateCommand; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccCoordinatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionEndedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccTransactionStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.TccEventServiceGrpc; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java similarity index 90% rename from omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java rename to omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java index 569203d15..810948de4 100644 --- a/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/saga/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java +++ b/omega/omega-connector/omega-connector-grpc/src/test/java/org/apache/servicecomb/pack/omega/connector/grpc/tcc/TccLoadBalanceSenderTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.connector.grpc.tcc; +package org.apache.servicecomb.pack.omega.connector.grpc.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.concurrent.TimeUnit.SECONDS; @@ -42,25 +42,25 @@ import java.util.Queue; import java.util.concurrent.Callable; import java.util.concurrent.TimeUnit; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.LoadBalanceSenderTestBase; -import org.apache.servicecomb.saga.omega.connector.grpc.core.FastestSender; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContextBuilder; -import org.apache.servicecomb.saga.omega.connector.grpc.core.TransactionType; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.tcc.CoordinateMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; -import org.apache.servicecomb.saga.pack.contract.grpc.GrpcTccParticipatedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.connector.grpc.LoadBalanceSenderTestBase; +import org.apache.servicecomb.pack.omega.connector.grpc.AlphaClusterConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.core.FastestSender; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContextBuilder; +import org.apache.servicecomb.pack.omega.connector.grpc.core.TransactionType; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.tcc.CoordinateMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.contract.grpc.GrpcTccParticipatedEvent; import org.hamcrest.core.Is; import org.junit.After; import org.junit.AfterClass; diff --git a/omega/omega-connector/pom.xml b/omega/omega-connector/pom.xml index cc2ed7366..4edf0fbef 100644 --- a/omega/omega-connector/pom.xml +++ b/omega/omega-connector/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-connector - Saga::Omega::Connector + Pack::Omega::Connector pom omega-connector-grpc diff --git a/omega/omega-context/pom.xml b/omega/omega-context/pom.xml index 654295ca0..c595c993a 100644 --- a/omega/omega-context/pom.xml +++ b/omega/omega-context/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-context - Saga::Omega::Context + Pack::Omega::Context diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/CallbackContext.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/CallbackContext.java similarity index 98% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/CallbackContext.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/CallbackContext.java index cf5ab5081..90e06d64b 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/CallbackContext.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/CallbackContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import java.lang.invoke.MethodHandles; import java.lang.reflect.InvocationTargetException; diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/IdGenerator.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/IdGenerator.java similarity index 94% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/IdGenerator.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/IdGenerator.java index 0917192f6..0e02265f4 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/IdGenerator.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/IdGenerator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import java.io.Serializable; diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/OmegaContext.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/OmegaContext.java similarity index 95% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/OmegaContext.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/OmegaContext.java index c84337a80..015aa679d 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/OmegaContext.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/OmegaContext.java @@ -15,10 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; - -import java.util.HashMap; -import java.util.Map; +package org.apache.servicecomb.pack.omega.context; /** * OmegaContext holds the globalTxId and localTxId which are used to build the invocation map diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/ServiceConfig.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/ServiceConfig.java similarity index 96% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/ServiceConfig.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/ServiceConfig.java index 1e16b6293..044b87d7e 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/ServiceConfig.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/ServiceConfig.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import java.net.InetAddress; import java.net.UnknownHostException; diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/UniqueIdGenerator.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/UniqueIdGenerator.java similarity index 95% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/UniqueIdGenerator.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/UniqueIdGenerator.java index 36c991abd..3a050e5d9 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/UniqueIdGenerator.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/UniqueIdGenerator.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import java.util.UUID; diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/SagaStart.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/SagaStart.java similarity index 95% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/SagaStart.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/SagaStart.java index 8b686187c..2a66a8419 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/SagaStart.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/SagaStart.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context.annotations; +package org.apache.servicecomb.pack.omega.context.annotations; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; diff --git a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/TccStart.java b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/TccStart.java similarity index 95% rename from omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/TccStart.java rename to omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/TccStart.java index c7f836905..d558522f7 100644 --- a/omega/omega-context/src/main/java/org/apache/servicecomb/saga/omega/context/annotations/TccStart.java +++ b/omega/omega-context/src/main/java/org/apache/servicecomb/pack/omega/context/annotations/TccStart.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context.annotations; +package org.apache.servicecomb.pack.omega.context.annotations; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.RetentionPolicy.RUNTIME; diff --git a/omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/OmegaContextTest.java b/omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/OmegaContextTest.java similarity index 98% rename from omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/OmegaContextTest.java rename to omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/OmegaContextTest.java index a104f7e5a..5394c014c 100644 --- a/omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/OmegaContextTest.java +++ b/omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/OmegaContextTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/UniqueIdGeneratorTest.java b/omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/UniqueIdGeneratorTest.java similarity index 97% rename from omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/UniqueIdGeneratorTest.java rename to omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/UniqueIdGeneratorTest.java index 7325a1e00..f69c05889 100644 --- a/omega/omega-context/src/test/java/org/apache/servicecomb/saga/omega/context/UniqueIdGeneratorTest.java +++ b/omega/omega-context/src/test/java/org/apache/servicecomb/pack/omega/context/UniqueIdGeneratorTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.context; +package org.apache.servicecomb.pack.omega.context; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/omega/omega-format/pom.xml b/omega/omega-format/pom.xml index c4be4b2a3..efd215aab 100644 --- a/omega/omega-format/pom.xml +++ b/omega/omega-format/pom.xml @@ -21,17 +21,17 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-format - Saga::Omega::Format + Pack::Omega::Format - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormat.java similarity index 94% rename from omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java rename to omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormat.java index 50dfba802..495ba3e01 100644 --- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormat.java +++ b/omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormat.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.format; +package org.apache.servicecomb.pack.omega.format; import java.io.ByteArrayInputStream; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; import com.esotericsoftware.kryo.Kryo; import com.esotericsoftware.kryo.KryoException; diff --git a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java b/omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/MessageFormat.java similarity index 83% rename from omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java rename to omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/MessageFormat.java index d80467d7b..5da326a97 100644 --- a/omega/omega-format/src/main/java/org/apache/servicecomb/saga/omega/format/MessageFormat.java +++ b/omega/omega-format/src/main/java/org/apache/servicecomb/pack/omega/format/MessageFormat.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.format; +package org.apache.servicecomb.pack.omega.format; -import org.apache.servicecomb.saga.omega.transaction.MessageDeserializer; -import org.apache.servicecomb.saga.omega.transaction.MessageSerializer; +import org.apache.servicecomb.pack.omega.transaction.MessageDeserializer; +import org.apache.servicecomb.pack.omega.transaction.MessageSerializer; public interface MessageFormat extends MessageSerializer, MessageDeserializer { } diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java b/omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormatTest.java similarity index 96% rename from omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java rename to omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormatTest.java index 327b6ecac..aa518f09e 100644 --- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/KryoMessageFormatTest.java +++ b/omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/KryoMessageFormatTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.format; +package org.apache.servicecomb.pack.omega.format; import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThat; diff --git a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java b/omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/MessageFormatTestBase.java similarity index 96% rename from omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java rename to omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/MessageFormatTestBase.java index a37ff20d8..1d2148525 100644 --- a/omega/omega-format/src/test/java/org/apache/servicecomb/saga/omega/format/MessageFormatTestBase.java +++ b/omega/omega-format/src/test/java/org/apache/servicecomb/pack/omega/format/MessageFormatTestBase.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.format; +package org.apache.servicecomb.pack.omega.format; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static java.util.Arrays.asList; @@ -25,11 +25,9 @@ import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertThat; -import java.util.List; import java.util.Objects; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.hamcrest.Matcher; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; import org.junit.Ignore; import org.junit.Test; diff --git a/omega/omega-spring-starter/pom.xml b/omega/omega-spring-starter/pom.xml index 7baae84a6..49279fa0b 100644 --- a/omega/omega-spring-starter/pom.xml +++ b/omega/omega-spring-starter/pom.xml @@ -21,21 +21,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-spring-starter - Saga::Omega::Spring Starter + Pack::Omega::Spring Starter - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-tx - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-format @@ -47,7 +47,7 @@ grpc-stub - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-connector-grpc diff --git a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/EnableOmega.java b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/EnableOmega.java similarity index 87% rename from omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/EnableOmega.java rename to omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/EnableOmega.java index e94c39e61..6117d48d7 100644 --- a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/EnableOmega.java +++ b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/EnableOmega.java @@ -15,16 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.spring; +package org.apache.servicecomb.pack.omega.spring; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.springframework.context.annotation.Import; -import org.apache.servicecomb.saga.omega.transaction.spring.TransactionAspectConfig; +import org.apache.servicecomb.pack.omega.transaction.spring.TransactionAspectConfig; @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @@ -32,7 +33,7 @@ /** * Indicates create the OmegaContext and inject it into the interceptors * to pass the transactions id across the application. - * @see org.apache.servicecomb.saga.omega.context.OmegaContext + * @see OmegaContext */ public @interface EnableOmega { } diff --git a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/OmegaSpringConfig.java similarity index 80% rename from omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java rename to omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/OmegaSpringConfig.java index 02593e152..29406bc47 100644 --- a/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/saga/omega/spring/OmegaSpringConfig.java +++ b/omega/omega-spring-starter/src/main/java/org/apache/servicecomb/pack/omega/spring/OmegaSpringConfig.java @@ -15,29 +15,29 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.spring; +package org.apache.servicecomb.pack.omega.spring; import com.google.common.collect.ImmutableList; -import org.apache.servicecomb.saga.omega.connector.grpc.AlphaClusterConfig; -import org.apache.servicecomb.saga.omega.connector.grpc.core.FastestSender; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContext; -import org.apache.servicecomb.saga.omega.connector.grpc.core.LoadBalanceContextBuilder; -import org.apache.servicecomb.saga.omega.connector.grpc.core.TransactionType; -import org.apache.servicecomb.saga.omega.connector.grpc.saga.SagaLoadBalanceSender; -import org.apache.servicecomb.saga.omega.connector.grpc.tcc.TccLoadBalanceSender; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.context.ServiceConfig; -import org.apache.servicecomb.saga.omega.context.UniqueIdGenerator; -import org.apache.servicecomb.saga.omega.format.KryoMessageFormat; -import org.apache.servicecomb.saga.omega.format.MessageFormat; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.DefaultParametersContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.ParametersContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.connector.grpc.AlphaClusterConfig; +import org.apache.servicecomb.pack.omega.connector.grpc.core.FastestSender; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContext; +import org.apache.servicecomb.pack.omega.connector.grpc.core.LoadBalanceContextBuilder; +import org.apache.servicecomb.pack.omega.connector.grpc.core.TransactionType; +import org.apache.servicecomb.pack.omega.connector.grpc.saga.SagaLoadBalanceSender; +import org.apache.servicecomb.pack.omega.connector.grpc.tcc.TccLoadBalanceSender; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.ServiceConfig; +import org.apache.servicecomb.pack.omega.context.UniqueIdGenerator; +import org.apache.servicecomb.pack.omega.format.KryoMessageFormat; +import org.apache.servicecomb.pack.omega.format.MessageFormat; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.DefaultParametersContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.ParametersContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; diff --git a/omega/omega-spring-tx/pom.xml b/omega/omega-spring-tx/pom.xml index ec6c020fc..f76ac3884 100644 --- a/omega/omega-spring-tx/pom.xml +++ b/omega/omega-spring-tx/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-spring-tx - Saga::Omega::Spring TX + Pack::Omega::Spring TX org.springframework.boot @@ -40,11 +40,11 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction @@ -75,8 +75,8 @@ test - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa test diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CallbackType.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CallbackType.java similarity index 94% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CallbackType.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CallbackType.java index 70d9c8298..109f26b14 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CallbackType.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CallbackType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; public enum CallbackType { /** diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationProcessor.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationProcessor.java similarity index 91% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationProcessor.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationProcessor.java index 254c3e738..b714a6ba3 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationProcessor.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationProcessor.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.util.ReflectionUtils; diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableMethodCheckingCallback.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableMethodCheckingCallback.java similarity index 89% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableMethodCheckingCallback.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableMethodCheckingCallback.java index bf2b5ce6f..16bfc7066 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableMethodCheckingCallback.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableMethodCheckingCallback.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; class CompensableMethodCheckingCallback extends MethodCheckingCallback { diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ExecutorFieldCallback.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ExecutorFieldCallback.java similarity index 96% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ExecutorFieldCallback.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ExecutorFieldCallback.java index 07a9466b5..4f72ad20e 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ExecutorFieldCallback.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ExecutorFieldCallback.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; @@ -27,8 +27,8 @@ import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.Executor; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.spring.annotations.OmegaContextAware; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.spring.annotations.OmegaContextAware; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.ReflectionUtils; diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/MethodCheckingCallback.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/MethodCheckingCallback.java similarity index 95% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/MethodCheckingCallback.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/MethodCheckingCallback.java index 6c5231348..071ac73b5 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/MethodCheckingCallback.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/MethodCheckingCallback.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.lang.invoke.MethodHandles; import java.lang.reflect.Field; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.aop.framework.AdvisedSupport; diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateAnnotationProcessor.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateAnnotationProcessor.java similarity index 91% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateAnnotationProcessor.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateAnnotationProcessor.java index 80583bd2c..9ecc2722d 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateAnnotationProcessor.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateAnnotationProcessor.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.springframework.beans.BeansException; import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.util.ReflectionUtils; diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateMethodCheckingCallback.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateMethodCheckingCallback.java similarity index 88% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateMethodCheckingCallback.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateMethodCheckingCallback.java index 959727af7..54a09dbea 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/ParticipateMethodCheckingCallback.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/ParticipateMethodCheckingCallback.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; public class ParticipateMethodCheckingCallback extends MethodCheckingCallback { diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionAspectConfig.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionAspectConfig.java similarity index 77% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionAspectConfig.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionAspectConfig.java index e5ab96847..a268381ee 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionAspectConfig.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionAspectConfig.java @@ -15,21 +15,21 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.CompensationMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.SagaStartAspect; -import org.apache.servicecomb.saga.omega.transaction.TransactionAspect; -import org.apache.servicecomb.saga.omega.transaction.tcc.CoordinateMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.ParametersContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccParticipatorAspect; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccStartAspect; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.CompensationMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.SagaStartAspect; +import org.apache.servicecomb.pack.omega.transaction.TransactionAspect; +import org.apache.servicecomb.pack.omega.transaction.tcc.CoordinateMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.ParametersContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccParticipatorAspect; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccStartAspect; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/annotations/OmegaContextAware.java b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/annotations/OmegaContextAware.java similarity index 94% rename from omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/annotations/OmegaContextAware.java rename to omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/annotations/OmegaContextAware.java index 5a4e7e45d..3160dba1a 100644 --- a/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/saga/omega/transaction/spring/annotations/OmegaContextAware.java +++ b/omega/omega-spring-tx/src/main/java/org/apache/servicecomb/pack/omega/transaction/spring/annotations/OmegaContextAware.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring.annotations; +package org.apache.servicecomb.pack.omega.transaction.spring.annotations; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationCheckingTest.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationCheckingTest.java similarity index 97% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationCheckingTest.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationCheckingTest.java index 6cbf8f994..48402018b 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/CompensableAnnotationCheckingTest.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/CompensableAnnotationCheckingTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.CoreMatchers.endsWith; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MessageConfig.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MessageConfig.java similarity index 80% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MessageConfig.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MessageConfig.java index 7b650efac..415e42e93 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MessageConfig.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MessageConfig.java @@ -15,23 +15,23 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.util.ArrayList; import java.util.List; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.SagaMessageSender; -import org.apache.servicecomb.saga.omega.transaction.TxEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.DefaultParametersContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.ParametersContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.SagaMessageSender; +import org.apache.servicecomb.pack.omega.transaction.TxEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.DefaultParametersContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.ParametersContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.mockito.Mockito; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredAnnotation.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredAnnotation.java similarity index 89% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredAnnotation.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredAnnotation.java index 99459a5eb..28811b079 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredAnnotation.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredAnnotation.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.transaction.spring.annotations.OmegaContextAware; +import org.apache.servicecomb.pack.omega.transaction.spring.annotations.OmegaContextAware; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredRetriesService.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredRetriesService.java similarity index 89% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredRetriesService.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredRetriesService.java index e68c99ca6..0c9056719 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredRetriesService.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredRetriesService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredService.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredService.java similarity index 89% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredService.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredService.java index a569d236d..936f219e5 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/MisconfiguredService.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/MisconfiguredService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.context.annotation.Profile; import org.springframework.stereotype.Component; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccInterceptorTest.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccInterceptorTest.java similarity index 88% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccInterceptorTest.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccInterceptorTest.java index 7f43476e3..5bda4ce59 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccInterceptorTest.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccInterceptorTest.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.omega.transaction.spring.TransactionalUserService.ILLEGAL_USER; import static org.assertj.core.util.IterableUtil.toArray; import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; @@ -29,14 +28,13 @@ import java.util.List; import java.util.UUID; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.TccMessageHandler; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.transaction.tcc.TccMessageHandler; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -57,7 +55,7 @@ public class TccInterceptorTest { private final String email = uniquify("email"); private final User user = new User(username, email); - private final User illegalUser = new User(ILLEGAL_USER, email); + private final User illegalUser = new User(TransactionalUserService.ILLEGAL_USER, email); private final String usernameJack = uniquify("Jack"); private final User jack = new User(usernameJack, uniquify("jack@gmail.com")); diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserService.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserService.java similarity index 94% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserService.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserService.java index 31da4c9cb..0d7abc0f4 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserService.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserService.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import javax.annotation.Resource; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserServiceMain.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserServiceMain.java similarity index 89% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserServiceMain.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserServiceMain.java index 4d09dec72..59d8c31e0 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TccUserServiceMain.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TccUserServiceMain.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.context.annotations.TccStart; +import org.apache.servicecomb.pack.omega.context.annotations.TccStart; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionInterceptionTest.java similarity index 95% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionInterceptionTest.java index 4505f72c6..92dd5db96 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionInterceptionTest.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionInterceptionTest.java @@ -15,14 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import static akka.actor.ActorRef.noSender; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Collections.singletonList; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import static org.apache.servicecomb.saga.omega.transaction.spring.TransactionalUserService.ILLEGAL_USER; import static org.awaitility.Awaitility.await; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.nullValue; @@ -48,14 +47,14 @@ import java.util.concurrent.Callable; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.MessageHandler; -import org.apache.servicecomb.saga.omega.transaction.TxAbortedEvent; -import org.apache.servicecomb.saga.omega.transaction.TxCompensatedEvent; -import org.apache.servicecomb.saga.omega.transaction.TxEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.TxStartedEvent; -import org.apache.servicecomb.saga.omega.transaction.spring.annotations.OmegaContextAware; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.spring.annotations.OmegaContextAware; +import org.apache.servicecomb.pack.omega.transaction.MessageHandler; +import org.apache.servicecomb.pack.omega.transaction.TxAbortedEvent; +import org.apache.servicecomb.pack.omega.transaction.TxCompensatedEvent; +import org.apache.servicecomb.pack.omega.transaction.TxEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.TxStartedEvent; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -78,7 +77,7 @@ public class TransactionInterceptionTest { private final String email = uniquify("email"); private final User user = new User(username, email); - private final User illegalUser = new User(ILLEGAL_USER, email); + private final User illegalUser = new User(TransactionalUserService.ILLEGAL_USER, email); private final String usernameJack = uniquify("Jack"); private final User jack = new User(usernameJack, uniquify("jack@gmail.com")); diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionTestMain.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionTestMain.java similarity index 94% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionTestMain.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionTestMain.java index ab9bb7e9e..ba4733cf9 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionTestMain.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionTestMain.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionalUserService.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionalUserService.java similarity index 95% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionalUserService.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionalUserService.java index ff0b5721c..bc7bcc939 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/TransactionalUserService.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/TransactionalUserService.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/User.java similarity index 96% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/User.java index da9d4b2ae..b9e668a8a 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/User.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/User.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import java.util.Objects; diff --git a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/UserRepository.java b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/UserRepository.java similarity index 93% rename from omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/UserRepository.java rename to omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/UserRepository.java index 729b7ab05..9ff8c39b2 100644 --- a/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/saga/omega/transaction/spring/UserRepository.java +++ b/omega/omega-spring-tx/src/test/java/org/apache/servicecomb/pack/omega/transaction/spring/UserRepository.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.spring; +package org.apache.servicecomb.pack.omega.transaction.spring; import org.springframework.data.repository.CrudRepository; diff --git a/omega/omega-transaction/pom.xml b/omega/omega-transaction/pom.xml index 8b487cd9e..e9f357f67 100644 --- a/omega/omega-transaction/pom.xml +++ b/omega/omega-transaction/pom.xml @@ -21,21 +21,21 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-transaction - Saga::Omega::Transaction + Pack::Omega::Transaction - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/AlphaResponse.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/AlphaResponse.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/AlphaResponse.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/AlphaResponse.java index 07df79375..bfcf64944 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/AlphaResponse.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/AlphaResponse.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public class AlphaResponse { private final boolean aborted; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensableInterceptor.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptor.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensableInterceptor.java index 5c5bb183b..718614775 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensableInterceptor.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; class CompensableInterceptor implements EventAwareInterceptor { private final OmegaContext context; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandler.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensationMessageHandler.java similarity index 92% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandler.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensationMessageHandler.java index 2e1e0a3f6..97b80eef3 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandler.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/CompensationMessageHandler.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.CallbackContext; public class CompensationMessageHandler implements MessageHandler { private final SagaMessageSender sender; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecovery.java similarity index 95% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecovery.java index 084498132..49b9d9062 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecovery.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecovery.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import javax.transaction.InvalidTransactionException; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/EventAwareInterceptor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/EventAwareInterceptor.java similarity index 95% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/EventAwareInterceptor.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/EventAwareInterceptor.java index b542222cf..5a88ee3bd 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/EventAwareInterceptor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/EventAwareInterceptor.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface EventAwareInterceptor { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecovery.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecovery.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecovery.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecovery.java index d1a28c2e0..35fe419a6 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecovery.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecovery.java @@ -15,15 +15,15 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import javax.transaction.InvalidTransactionException; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.slf4j.Logger; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageDeserializer.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageDeserializer.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageDeserializer.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageDeserializer.java index 23f1126fe..3efd45d82 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageDeserializer.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageDeserializer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface MessageDeserializer { Object[] deserialize(byte[] message); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageHandler.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageHandler.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageHandler.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageHandler.java index ada064eb9..38a9dabae 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageHandler.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageHandler.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface MessageHandler { void onReceive(String globalTxId, String localTxId, String parentTxId, String compensationMethod, Object... payloads); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSender.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSender.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSender.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSender.java index 406208233..9833fdf49 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSender.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSender.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface MessageSender { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSerializer.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSerializer.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSerializer.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSerializer.java index 0bc1e4614..95da95ee8 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/MessageSerializer.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/MessageSerializer.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface MessageSerializer { byte[] serialize(Object[] objects); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/NoOpEventAwareInterceptor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/NoOpEventAwareInterceptor.java similarity index 96% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/NoOpEventAwareInterceptor.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/NoOpEventAwareInterceptor.java index 990973578..bc462429a 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/NoOpEventAwareInterceptor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/NoOpEventAwareInterceptor.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public class NoOpEventAwareInterceptor implements EventAwareInterceptor { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/OmegaException.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/OmegaException.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/OmegaException.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/OmegaException.java index 4488e447f..4d3f9830c 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/OmegaException.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/OmegaException.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public class OmegaException extends RuntimeException { public OmegaException(String message) { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicy.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicy.java similarity index 85% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicy.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicy.java index bc1d4d8de..7aec7c73c 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicy.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicy.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; public interface RecoveryPolicy { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicyFactory.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicyFactory.java similarity index 96% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicyFactory.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicyFactory.java index f59ac2b39..33098d92b 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/RecoveryPolicyFactory.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/RecoveryPolicyFactory.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public class RecoveryPolicyFactory { private static final RecoveryPolicy DEFAULT_RECOVERY = new DefaultRecovery(); 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/pack/omega/transaction/SagaEndedEvent.java similarity index 90% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaEndedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaEndedEvent.java index 2e28b5e16..aa2bb3b6b 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/pack/omega/transaction/SagaEndedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class SagaEndedEvent extends TxEvent { SagaEndedEvent(String globalTxId, String localTxId) { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaMessageSender.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaMessageSender.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaMessageSender.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaMessageSender.java index 3a6c67cf1..ca147fb37 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaMessageSender.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaMessageSender.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; public interface SagaMessageSender extends MessageSender { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAnnotationProcessor.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAnnotationProcessor.java index 4c3b1228b..87b780807 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAnnotationProcessor.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import javax.transaction.TransactionalException; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; class SagaStartAnnotationProcessor { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspect.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAspect.java similarity index 91% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspect.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAspect.java index 0e09f4962..ec4441ecd 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspect.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAspect.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.context.annotations.SagaStart; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -41,7 +41,7 @@ public SagaStartAspect(SagaMessageSender sender, OmegaContext context) { this.sagaStartAnnotationProcessor = new SagaStartAnnotationProcessor(context, sender); } - @Around("execution(@org.apache.servicecomb.saga.omega.context.annotations.SagaStart * *(..)) && @annotation(sagaStart)") + @Around("execution(@org.apache.servicecomb.pack.omega.context.annotations.SagaStart * *(..)) && @annotation(sagaStart)") Object advise(ProceedingJoinPoint joinPoint, SagaStart sagaStart) throws Throwable { initializeOmegaContext(); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); 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/pack/omega/transaction/SagaStartedEvent.java similarity index 91% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/SagaStartedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/SagaStartedEvent.java index 0e87a97d4..66fba1a6a 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/pack/omega/transaction/SagaStartedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class SagaStartedEvent extends TxEvent { public SagaStartedEvent(String globalTxId, String localTxId, int timeout) { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspect.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspect.java similarity index 90% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspect.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspect.java index ee247ceb4..262067f86 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspect.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspect.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -42,7 +42,7 @@ public TransactionAspect(SagaMessageSender sender, OmegaContext context) { this.interceptor = new CompensableInterceptor(context, sender); } - @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") + @Around("execution(@org.apache.servicecomb.pack.omega.transaction.annotations.Compensable * *(..)) && @annotation(compensable)") Object advise(ProceedingJoinPoint joinPoint, Compensable compensable) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.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/pack/omega/transaction/TxAbortedEvent.java similarity index 93% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxAbortedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TxAbortedEvent.java index 0a4146af3..c6dea5a18 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/pack/omega/transaction/TxAbortedEvent.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.io.PrintWriter; import java.io.StringWriter; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class TxAbortedEvent extends TxEvent { 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/pack/omega/transaction/TxCompensatedEvent.java similarity index 90% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxCompensatedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TxCompensatedEvent.java index cd709e407..e4b1a1759 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/pack/omega/transaction/TxCompensatedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class TxCompensatedEvent extends TxEvent { public TxCompensatedEvent(String globalTxId, String localTxId, String parentTxId, String 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/pack/omega/transaction/TxEndedEvent.java similarity index 90% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEndedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TxEndedEvent.java index f702c438d..8618e7f07 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/pack/omega/transaction/TxEndedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class TxEndedEvent extends TxEvent { public TxEndedEvent(String globalTxId, String localTxId, String parentTxId, String 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/pack/omega/transaction/TxEvent.java similarity index 96% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TxEvent.java index a158af19b..71e10b509 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/pack/omega/transaction/TxEvent.java @@ -15,11 +15,11 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import java.util.Arrays; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class TxEvent { 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/pack/omega/transaction/TxStartedEvent.java similarity index 91% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/TxStartedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/TxStartedEvent.java index 5d2ae1277..fe7bb5b60 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/pack/omega/transaction/TxStartedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; -import org.apache.servicecomb.saga.common.EventType; +import org.apache.servicecomb.pack.common.EventType; public class TxStartedEvent extends TxEvent { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Compensable.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Compensable.java similarity index 97% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Compensable.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Compensable.java index 94753743e..a3e9d33e6 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Compensable.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Compensable.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.annotations; +package org.apache.servicecomb.pack.omega.transaction.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Participate.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Participate.java similarity index 97% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Participate.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Participate.java index 835107629..8f5c3a257 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/annotations/Participate.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/annotations/Participate.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.annotations; +package org.apache.servicecomb.pack.omega.transaction.annotations; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandler.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandler.java similarity index 86% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandler.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandler.java index 657c9fbbc..73673aab3 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandler.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandler.java @@ -15,12 +15,12 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; public class CoordinateMessageHandler implements TccMessageHandler { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/DefaultParametersContext.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/DefaultParametersContext.java similarity index 95% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/DefaultParametersContext.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/DefaultParametersContext.java index 2fb9f2f70..5cd3baa22 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/DefaultParametersContext.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/DefaultParametersContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import java.util.HashMap; import java.util.Map; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/ParametersContext.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/ParametersContext.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/ParametersContext.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/ParametersContext.java index 26fc4d232..7e992d8b4 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/ParametersContext.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/ParametersContext.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; public interface ParametersContext { Object[] getParameters(String localTransactionId); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccEventService.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccEventService.java similarity index 77% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccEventService.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccEventService.java index 6c5b7e262..370fe3147 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccEventService.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccEventService.java @@ -15,13 +15,13 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; public interface TccEventService { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageHandler.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageHandler.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageHandler.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageHandler.java index 461c310a7..e2c8a70b0 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageHandler.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageHandler.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; public interface TccMessageHandler { void onReceive(String globalTxId, String localTxId, String parentTxId, String method); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageSender.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageSender.java similarity index 73% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageSender.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageSender.java index 2a9055eba..a1d16a809 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccMessageSender.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccMessageSender.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; - -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.MessageSender; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +package org.apache.servicecomb.pack.omega.transaction.tcc; + +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.MessageSender; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; public interface TccMessageSender extends MessageSender { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspect.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspect.java similarity index 90% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspect.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspect.java index 88496605e..f70f61a15 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspect.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspect.java @@ -15,14 +15,14 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -47,7 +47,7 @@ public TccParticipatorAspect(TccMessageSender tccMessageSender, OmegaContext con this.parametersContext = parametersContext; } - @Around("execution(@org.apache.servicecomb.saga.omega.transaction.annotations.Participate * *(..)) && @annotation(participate)") + @Around("execution(@org.apache.servicecomb.pack.omega.transaction.annotations.Participate * *(..)) && @annotation(participate)") Object advise(ProceedingJoinPoint joinPoint, Participate participate) throws Throwable { Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); String localTxId = context.localTxId(); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessor.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessor.java similarity index 82% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessor.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessor.java index 1d4cf24d8..948f79f9b 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessor.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessor.java @@ -14,15 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import javax.transaction.TransactionalException; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; public class TccStartAnnotationProcessor { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspect.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspect.java similarity index 89% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspect.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspect.java index 8d0bf839f..057c3e12a 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspect.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspect.java @@ -14,14 +14,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.context.annotations.TccStart; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.annotations.TccStart; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -42,7 +42,7 @@ public TccStartAspect(TccMessageSender tccMessageSender, OmegaContext context) { this.tccStartAnnotationProcessor = new TccStartAnnotationProcessor(context, tccMessageSender); } - @Around("execution(@org.apache.servicecomb.saga.omega.context.annotations.TccStart * *(..)) && @annotation(tccStart)") + @Around("execution(@org.apache.servicecomb.pack.omega.context.annotations.TccStart * *(..)) && @annotation(tccStart)") Object advise(ProceedingJoinPoint joinPoint, TccStart tccStart) throws Throwable { initializeOmegaContext(); Method method = ((MethodSignature) joinPoint.getSignature()).getMethod(); diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/CoordinatedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/CoordinatedEvent.java similarity index 93% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/CoordinatedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/CoordinatedEvent.java index 2a8015382..1ef6bb6e0 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/CoordinatedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/CoordinatedEvent.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc.events; +package org.apache.servicecomb.pack.omega.transaction.tcc.events; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.common.TransactionStatus; public class CoordinatedEvent { private final String globalTxId; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/ParticipatedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/ParticipatedEvent.java similarity index 94% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/ParticipatedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/ParticipatedEvent.java index f55fd43e3..701509d3f 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/ParticipatedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/ParticipatedEvent.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc.events; +package org.apache.servicecomb.pack.omega.transaction.tcc.events; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.common.TransactionStatus; public class ParticipatedEvent { diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccEndedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccEndedEvent.java similarity index 92% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccEndedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccEndedEvent.java index 3944fb146..41a2c2552 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccEndedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccEndedEvent.java @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc.events; +package org.apache.servicecomb.pack.omega.transaction.tcc.events; -import org.apache.servicecomb.saga.common.TransactionStatus; +import org.apache.servicecomb.pack.common.TransactionStatus; public class TccEndedEvent { private final String globalTxId; diff --git a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccStartedEvent.java b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccStartedEvent.java similarity index 95% rename from omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccStartedEvent.java rename to omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccStartedEvent.java index 7a1e7b3b3..4b9205d7d 100644 --- a/omega/omega-transaction/src/main/java/org/apache/servicecomb/saga/omega/transaction/tcc/events/TccStartedEvent.java +++ b/omega/omega-transaction/src/main/java/org/apache/servicecomb/pack/omega/transaction/tcc/events/TccStartedEvent.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc.events; +package org.apache.servicecomb.pack.omega.transaction.tcc.events; public class TccStartedEvent { private final String globalTxId; 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/pack/omega/transaction/CompensableInterceptorTest.java similarity index 94% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensableInterceptorTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/CompensableInterceptorTest.java index aec9d5a7c..617b4c499 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/pack/omega/transaction/CompensableInterceptorTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static java.util.Arrays.asList; @@ -28,9 +28,9 @@ import java.util.Random; 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.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; 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/pack/omega/transaction/CompensationMessageHandlerTest.java similarity index 94% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/CompensationMessageHandlerTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/CompensationMessageHandlerTest.java index ce40d7115..3bc1362cd 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/pack/omega/transaction/CompensationMessageHandlerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.core.Is.is; @@ -26,8 +26,8 @@ import java.util.ArrayList; import java.util.List; -import org.apache.servicecomb.saga.common.EventType; -import org.apache.servicecomb.saga.omega.context.CallbackContext; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.CallbackContext; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecoveryTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecoveryTest.java similarity index 95% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecoveryTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecoveryTest.java index 3f8b17fd0..5d7680490 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/DefaultRecoveryTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/DefaultRecoveryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.core.Is.is; @@ -34,10 +34,10 @@ import javax.transaction.InvalidTransactionException; -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; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecoveryTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecoveryTest.java similarity index 95% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecoveryTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecoveryTest.java index 98b3980ed..23482af7e 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/ForwardRecoveryTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/ForwardRecoveryTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.core.Is.is; @@ -33,10 +33,10 @@ import javax.transaction.InvalidTransactionException; -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; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; 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/pack/omega/transaction/SagaStartAnnotationProcessorTest.java similarity index 94% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAnnotationProcessorTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAnnotationProcessorTest.java index 9052e2f1e..015d2ded4 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/pack/omega/transaction/SagaStartAnnotationProcessorTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.Matchers.instanceOf; @@ -30,9 +30,9 @@ import java.util.List; import java.util.UUID; import javax.transaction.TransactionalException; -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.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.junit.Before; import org.junit.Test; 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/pack/omega/transaction/SagaStartAspectTest.java similarity index 93% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/SagaStartAspectTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/SagaStartAspectTest.java index a9ff33884..c11a7909b 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/pack/omega/transaction/SagaStartAspectTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.CoreMatchers.nullValue; @@ -27,10 +27,10 @@ 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.apache.servicecomb.saga.omega.context.annotations.SagaStart; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.annotations.SagaStart; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; 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/pack/omega/transaction/TransactionAspectTest.java similarity index 96% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/TransactionAspectTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/TransactionAspectTest.java index 3c0514096..0f4cf8b7d 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/pack/omega/transaction/TransactionAspectTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction; +package org.apache.servicecomb.pack.omega.transaction; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.core.Is.is; @@ -27,10 +27,10 @@ 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.apache.servicecomb.saga.omega.transaction.annotations.Compensable; +import org.apache.servicecomb.pack.common.EventType; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.annotations.Compensable; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandlerTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandlerTest.java similarity index 85% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandlerTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandlerTest.java index 6dbb7211d..ca2879e20 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/CoordinateMessageHandlerTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/CoordinateMessageHandlerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; @@ -24,14 +24,14 @@ import java.util.ArrayList; import java.util.List; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.CallbackContext; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.CallbackContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspectTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspectTest.java similarity index 90% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspectTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspectTest.java index f52da0383..da194915e 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccParticipatorAspectTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccParticipatorAspectTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.core.Is.is; @@ -26,15 +26,15 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.annotations.Participate; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.annotations.Participate; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessorTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessorTest.java similarity index 88% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessorTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessorTest.java index 185387410..96d0de6cb 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAnnotationProcessorTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAnnotationProcessorTest.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.MatcherAssert.assertThat; @@ -28,15 +28,15 @@ import javax.transaction.TransactionalException; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.OmegaException; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.OmegaException; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.hamcrest.core.Is; import org.junit.Assert; import org.junit.Before; diff --git a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspectTest.java b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspectTest.java similarity index 89% rename from omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspectTest.java rename to omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspectTest.java index 0fe096d32..2572c72b4 100644 --- a/omega/omega-transaction/src/test/java/org/apache/servicecomb/saga/omega/transaction/tcc/TccStartAspectTest.java +++ b/omega/omega-transaction/src/test/java/org/apache/servicecomb/pack/omega/transaction/tcc/TccStartAspectTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transaction.tcc; +package org.apache.servicecomb.pack.omega.transaction.tcc; import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; import static org.hamcrest.CoreMatchers.nullValue; @@ -27,15 +27,15 @@ import java.util.List; import java.util.UUID; -import org.apache.servicecomb.saga.common.TransactionStatus; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.context.annotations.TccStart; -import org.apache.servicecomb.saga.omega.transaction.AlphaResponse; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.CoordinatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.ParticipatedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccEndedEvent; -import org.apache.servicecomb.saga.omega.transaction.tcc.events.TccStartedEvent; +import org.apache.servicecomb.pack.common.TransactionStatus; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.annotations.TccStart; +import org.apache.servicecomb.pack.omega.transaction.AlphaResponse; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.CoordinatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.ParticipatedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccEndedEvent; +import org.apache.servicecomb.pack.omega.transaction.tcc.events.TccStartedEvent; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.reflect.MethodSignature; import org.junit.Before; diff --git a/omega/omega-transport/omega-transport-dubbo/pom.xml b/omega/omega-transport/omega-transport-dubbo/pom.xml index ec9522eb5..09018ca9b 100644 --- a/omega/omega-transport/omega-transport-dubbo/pom.xml +++ b/omega/omega-transport/omega-transport-dubbo/pom.xml @@ -22,7 +22,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega-transport - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 diff --git a/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboConsumerFilter.java b/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilter.java similarity index 88% rename from omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboConsumerFilter.java rename to omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilter.java index afb83d1e1..2a44a46d1 100644 --- a/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboConsumerFilter.java +++ b/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilter.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.dubbo; +package org.apache.servicecomb.pack.omega.transport.dubbo; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory; import com.alibaba.dubbo.rpc.Filter; import com.alibaba.dubbo.rpc.Invocation; import com.alibaba.dubbo.rpc.Invoker; @@ -28,13 +27,13 @@ import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; /** * add saga transaction id to dubbo invocation diff --git a/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboProviderFilter.java b/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilter.java similarity index 88% rename from omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboProviderFilter.java rename to omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilter.java index 618b9b9ee..ee6c905ca 100644 --- a/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/saga/omega/transport/dubbo/SagaDubboProviderFilter.java +++ b/omega/omega-transport/omega-transport-dubbo/src/main/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilter.java @@ -14,22 +14,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.dubbo; +package org.apache.servicecomb.pack.omega.transport.dubbo; import com.alibaba.dubbo.common.Constants; import com.alibaba.dubbo.common.extension.Activate; -import com.alibaba.dubbo.config.spring.extension.SpringExtensionFactory; import com.alibaba.dubbo.rpc.*; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import java.lang.invoke.MethodHandles; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; /** * get saga transaction id from dubbo invocation and set into omega context diff --git a/omega/omega-transport/omega-transport-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter b/omega/omega-transport/omega-transport-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter index f60a7433d..3505b4f31 100644 --- a/omega/omega-transport/omega-transport-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter +++ b/omega/omega-transport/omega-transport-dubbo/src/main/resources/META-INF/dubbo/com.alibaba.dubbo.rpc.Filter @@ -14,5 +14,5 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- -sagaDubboConsumerFilter=org.apache.servicecomb.saga.omega.transport.dubbo.SagaDubboConsumerFilter -sageDubboProviderFilter=org.apache.servicecomb.saga.omega.transport.dubbo.SagaDubboProviderFilter \ No newline at end of file +sagaDubboConsumerFilter=org.apache.servicecomb.pack.omega.transport.dubbo.SagaDubboConsumerFilter +sageDubboProviderFilter=org.apache.servicecomb.pack.omega.transport.dubbo.SagaDubboProviderFilter diff --git a/omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboConsumerFilterTest.java b/omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilterTest.java similarity index 91% rename from omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboConsumerFilterTest.java rename to omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilterTest.java index dc1875b80..53049b220 100644 --- a/omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboConsumerFilterTest.java +++ b/omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboConsumerFilterTest.java @@ -1,4 +1,4 @@ -/* +package org.apache.servicecomb.pack.omega.transport.dubbo;/* * 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. @@ -19,9 +19,9 @@ import java.util.Map; import java.util.UUID; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transport.dubbo.SagaDubboConsumerFilter; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.transport.dubbo.SagaDubboConsumerFilter; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboProviderFilterTest.java b/omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilterTest.java similarity index 92% rename from omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboProviderFilterTest.java rename to omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilterTest.java index 1d0e8ade8..08ae0ce0c 100644 --- a/omega/omega-transport/omega-transport-dubbo/src/test/java/SagaDubboProviderFilterTest.java +++ b/omega/omega-transport/omega-transport-dubbo/src/test/java/org/apache/servicecomb/pack/omega/transport/dubbo/SagaDubboProviderFilterTest.java @@ -1,4 +1,4 @@ -/* +package org.apache.servicecomb.pack.omega.transport.dubbo;/* * 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. @@ -17,9 +17,8 @@ import java.util.UUID; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; -import org.apache.servicecomb.saga.omega.transport.dubbo.SagaDubboProviderFilter; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transport/omega-transport-feign/pom.xml b/omega/omega-transport/omega-transport-feign/pom.xml index fd9b05038..d8d3f7b6b 100644 --- a/omega/omega-transport/omega-transport-feign/pom.xml +++ b/omega/omega-transport/omega-transport-feign/pom.xml @@ -22,7 +22,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega-transport - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 diff --git a/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfiguration.java b/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfiguration.java similarity index 92% rename from omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfiguration.java rename to omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfiguration.java index 0edc663fc..c76d66500 100644 --- a/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfiguration.java +++ b/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfiguration.java @@ -15,10 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.feign; +package org.apache.servicecomb.pack.omega.transport.feign; import feign.RequestInterceptor; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.context.annotation.Bean; diff --git a/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignClientRequestInterceptor.java b/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignClientRequestInterceptor.java similarity index 88% rename from omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignClientRequestInterceptor.java rename to omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignClientRequestInterceptor.java index c679ed0a2..774b05dd1 100644 --- a/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/saga/omega/transport/feign/FeignClientRequestInterceptor.java +++ b/omega/omega-transport/omega-transport-feign/src/main/java/org/apache/servicecomb/pack/omega/transport/feign/FeignClientRequestInterceptor.java @@ -15,18 +15,18 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.feign; +package org.apache.servicecomb.pack.omega.transport.feign; import feign.RequestInterceptor; import feign.RequestTemplate; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.invoke.MethodHandles; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; /** * 增加Feign拦截器,实现spring cloud下feign调用传递全局事务和本地事务。 diff --git a/omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfigurationTest.java b/omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfigurationTest.java similarity index 93% rename from omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfigurationTest.java rename to omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfigurationTest.java index 4fa35ac7d..cd2c9a01f 100644 --- a/omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/saga/omega/transport/feign/FeignAutoConfigurationTest.java +++ b/omega/omega-transport/omega-transport-feign/src/test/java/org/apache/servicecomb/pack/omega/transport/feign/FeignAutoConfigurationTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.servicecomb.saga.omega.transport.feign; +package org.apache.servicecomb.pack.omega.transport.feign; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; @@ -28,8 +28,8 @@ import feign.RequestInterceptor; import feign.RequestTemplate; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transport/omega-transport-resttemplate/pom.xml b/omega/omega-transport/omega-transport-resttemplate/pom.xml index d9e348a2d..7edfad7ea 100644 --- a/omega/omega-transport/omega-transport-resttemplate/pom.xml +++ b/omega/omega-transport/omega-transport-resttemplate/pom.xml @@ -22,13 +22,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega-transport - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-transport-resttemplate - Saga::Omega::Transport::Rest Template + Pack::Omega::Transport::Rest Template diff --git a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/RestTemplateConfig.java b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/RestTemplateConfig.java similarity index 92% rename from omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/RestTemplateConfig.java rename to omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/RestTemplateConfig.java index 98bf70bd6..f97f0f352 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/RestTemplateConfig.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/RestTemplateConfig.java @@ -16,7 +16,7 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; import java.util.List; @@ -26,7 +26,7 @@ import org.springframework.http.client.ClientHttpRequestInterceptor; import org.springframework.web.client.RestTemplate; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; @Configuration public class RestTemplateConfig { diff --git a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java similarity index 87% rename from omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java rename to omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java index 958be54e0..0562ad725 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptor.java @@ -16,18 +16,17 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; import java.io.IOException; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpRequest; import org.springframework.http.client.ClientHttpRequestExecution; import org.springframework.http.client.ClientHttpRequestInterceptor; diff --git a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptor.java b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptor.java similarity index 89% rename from omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptor.java rename to omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptor.java index 50b8a0ea1..d4aa4ad55 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptor.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptor.java @@ -18,17 +18,17 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; import java.lang.invoke.MethodHandles; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.servlet.HandlerInterceptor; diff --git a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/WebConfig.java b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/WebConfig.java similarity index 93% rename from omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/WebConfig.java rename to omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/WebConfig.java index 3218d4707..d7833d35a 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/saga/omega/transport/resttemplate/WebConfig.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/main/java/org/apache/servicecomb/pack/omega/transport/resttemplate/WebConfig.java @@ -18,11 +18,11 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; import java.lang.invoke.MethodHandles; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/omega/omega-transport/omega-transport-resttemplate/src/main/resources/META-INF/spring.factories b/omega/omega-transport/omega-transport-resttemplate/src/main/resources/META-INF/spring.factories index 00a5c7ceb..e3fbe6f54 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/main/resources/META-INF/spring.factories +++ b/omega/omega-transport/omega-transport-resttemplate/src/main/resources/META-INF/spring.factories @@ -15,5 +15,5 @@ ## limitations under the License. ## --------------------------------------------------------------------------- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.servicecomb.saga.omega.transport.resttemplate.WebConfig,\ - org.apache.servicecomb.saga.omega.transport.resttemplate.RestTemplateConfig + org.apache.servicecomb.pack.omega.transport.resttemplate.WebConfig,\ + org.apache.servicecomb.pack.omega.transport.resttemplate.RestTemplateConfig diff --git a/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java b/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java similarity index 94% rename from omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java rename to omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java index 14e288e6d..a305b12c3 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionClientHttpRequestInterceptorTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; import static org.hamcrest.Matchers.contains; @@ -27,8 +27,8 @@ import java.io.IOException; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java b/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java similarity index 93% rename from omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java rename to omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java index 16cbe6d03..2ebf4c176 100644 --- a/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/saga/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java +++ b/omega/omega-transport/omega-transport-resttemplate/src/test/java/org/apache/servicecomb/pack/omega/transport/resttemplate/TransactionHandlerInterceptorTest.java @@ -16,7 +16,7 @@ * */ -package org.apache.servicecomb.saga.omega.transport.resttemplate; +package org.apache.servicecomb.pack.omega.transport.resttemplate; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; @@ -30,8 +30,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.junit.Before; import org.junit.Test; import org.springframework.web.servlet.HandlerInterceptor; diff --git a/omega/omega-transport/omega-transport-servicecomb/pom.xml b/omega/omega-transport/omega-transport-servicecomb/pom.xml index 951de055b..835e96f43 100644 --- a/omega/omega-transport/omega-transport-servicecomb/pom.xml +++ b/omega/omega-transport/omega-transport-servicecomb/pom.xml @@ -21,7 +21,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega-transport - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 diff --git a/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandler.java b/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandler.java similarity index 90% rename from omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandler.java rename to omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandler.java index 226985357..5a51a2761 100644 --- a/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandler.java +++ b/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandler.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.servicecomb; +package org.apache.servicecomb.pack.omega.transport.servicecomb; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; import java.lang.invoke.MethodHandles; import org.apache.servicecomb.core.Handler; import org.apache.servicecomb.core.Invocation; import org.apache.servicecomb.foundation.common.utils.BeanUtils; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.apache.servicecomb.swagger.invocation.AsyncResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandler.java b/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandler.java similarity index 90% rename from omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandler.java rename to omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandler.java index 8dbeb54ab..e79d9e496 100644 --- a/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandler.java +++ b/omega/omega-transport/omega-transport-servicecomb/src/main/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandler.java @@ -15,17 +15,17 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.servicecomb; +package org.apache.servicecomb.pack.omega.transport.servicecomb; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; import java.lang.invoke.MethodHandles; import org.apache.servicecomb.core.Handler; import org.apache.servicecomb.core.Invocation; import org.apache.servicecomb.foundation.common.utils.BeanUtils; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.apache.servicecomb.swagger.invocation.AsyncResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/omega/omega-transport/omega-transport-servicecomb/src/main/resources/config/cse.handler.xml b/omega/omega-transport/omega-transport-servicecomb/src/main/resources/config/cse.handler.xml index 951581528..29bb57277 100644 --- a/omega/omega-transport/omega-transport-servicecomb/src/main/resources/config/cse.handler.xml +++ b/omega/omega-transport/omega-transport-servicecomb/src/main/resources/config/cse.handler.xml @@ -17,7 +17,7 @@ + class="org.apache.servicecomb.pack.omega.transport.servicecomb.SagaConsumerHandler" /> - \ No newline at end of file + class="org.apache.servicecomb.pack.omega.transport.servicecomb.SagaProviderHandler" /> + diff --git a/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandlerTest.java b/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandlerTest.java similarity index 93% rename from omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandlerTest.java rename to omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandlerTest.java index 18b57aca6..db5bf0c83 100644 --- a/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaConsumerHandlerTest.java +++ b/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaConsumerHandlerTest.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.servicecomb; +package org.apache.servicecomb.pack.omega.transport.servicecomb; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; @@ -27,8 +27,8 @@ import java.util.UUID; import org.apache.servicecomb.core.Invocation; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.apache.servicecomb.swagger.invocation.AsyncResponse; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandlerTest.java b/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandlerTest.java similarity index 88% rename from omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandlerTest.java rename to omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandlerTest.java index 41fc04964..638076d04 100644 --- a/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/saga/omega/transport/servicecomb/SagaProviderHandlerTest.java +++ b/omega/omega-transport/omega-transport-servicecomb/src/test/java/org/apache/servicecomb/pack/omega/transport/servicecomb/SagaProviderHandlerTest.java @@ -15,11 +15,10 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.omega.transport.servicecomb; +package org.apache.servicecomb.pack.omega.transport.servicecomb; -import static java.util.Collections.emptyMap; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; -import static org.apache.servicecomb.saga.omega.context.OmegaContext.LOCAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.GLOBAL_TX_ID_KEY; +import static org.apache.servicecomb.pack.omega.context.OmegaContext.LOCAL_TX_ID_KEY; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; @@ -32,8 +31,8 @@ import java.util.UUID; import org.apache.servicecomb.core.Invocation; -import org.apache.servicecomb.saga.omega.context.IdGenerator; -import org.apache.servicecomb.saga.omega.context.OmegaContext; +import org.apache.servicecomb.pack.omega.context.IdGenerator; +import org.apache.servicecomb.pack.omega.context.OmegaContext; import org.apache.servicecomb.swagger.invocation.AsyncResponse; import org.junit.Before; import org.junit.Test; diff --git a/omega/omega-transport/pom.xml b/omega/omega-transport/pom.xml index f3626f3ef..6d1b2884c 100644 --- a/omega/omega-transport/pom.xml +++ b/omega/omega-transport/pom.xml @@ -22,13 +22,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> omega - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega-transport - Saga::Omega::Transport + Pack::Omega::Transport pom @@ -40,11 +40,11 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction diff --git a/omega/pom.xml b/omega/pom.xml index bc431b5a0..abfcd097a 100644 --- a/omega/pom.xml +++ b/omega/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 omega - Saga::Omega + Pack::Omega pom @@ -62,12 +62,12 @@ import - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction 0.3.0-SNAPSHOT diff --git a/pack-common/pom.xml b/pack-common/pom.xml index c32d7a20a..2cf1625a6 100644 --- a/pack-common/pom.xml +++ b/pack-common/pom.xml @@ -21,12 +21,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 pack-common - Saga::Pack Common + Pack::Pack Common diff --git a/pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java b/pack-common/src/main/java/org/apache/servicecomb/pack/common/EventType.java similarity index 95% rename from pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java rename to pack-common/src/main/java/org/apache/servicecomb/pack/common/EventType.java index d7743d905..f3d0585a9 100644 --- a/pack-common/src/main/java/org/apache/servicecomb/saga/common/EventType.java +++ b/pack-common/src/main/java/org/apache/servicecomb/pack/common/EventType.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.common; +package org.apache.servicecomb.pack.common; public enum EventType { SagaStartedEvent, diff --git a/pack-common/src/main/java/org/apache/servicecomb/saga/common/TransactionStatus.java b/pack-common/src/main/java/org/apache/servicecomb/pack/common/TransactionStatus.java similarity index 95% rename from pack-common/src/main/java/org/apache/servicecomb/saga/common/TransactionStatus.java rename to pack-common/src/main/java/org/apache/servicecomb/pack/common/TransactionStatus.java index ea5a6624c..1c88d198a 100644 --- a/pack-common/src/main/java/org/apache/servicecomb/saga/common/TransactionStatus.java +++ b/pack-common/src/main/java/org/apache/servicecomb/pack/common/TransactionStatus.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.common; +package org.apache.servicecomb.pack.common; public enum TransactionStatus { Succeed, diff --git a/pack-contracts/pack-contract-grpc/pom.xml b/pack-contracts/pack-contract-grpc/pom.xml index f7b794bfc..7c805bbf6 100644 --- a/pack-contracts/pack-contract-grpc/pom.xml +++ b/pack-contracts/pack-contract-grpc/pom.xml @@ -24,13 +24,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> pack-contracts - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 pack-contract-grpc - Saga::Pack Contracts::Grpc + Pack::Pack Contracts::Grpc diff --git a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcCommon.proto b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcCommon.proto index 40a8db7ea..07177ef2c 100644 --- a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcCommon.proto +++ b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcCommon.proto @@ -18,7 +18,7 @@ syntax = "proto3"; option java_multiple_files = true; -option java_package = "org.apache.servicecomb.saga.pack.contract.grpc"; +option java_package = "org.apache.servicecomb.pack.contract.grpc"; // Define the common structs which could be use for TccEventService and SagaEventService diff --git a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTccEvent.proto b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTccEvent.proto index 7977b7ac7..20edad451 100644 --- a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTccEvent.proto +++ b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTccEvent.proto @@ -18,7 +18,7 @@ syntax = "proto3"; option java_multiple_files = true; -option java_package = "org.apache.servicecomb.saga.pack.contract.grpc"; +option java_package = "org.apache.servicecomb.pack.contract.grpc"; option java_outer_classname = "TccEventProto"; import "GrpcCommon.proto"; diff --git a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTxEvent.proto b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTxEvent.proto index f037b4fda..7c7764e6a 100644 --- a/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTxEvent.proto +++ b/pack-contracts/pack-contract-grpc/src/main/proto/GrpcTxEvent.proto @@ -18,7 +18,7 @@ syntax = "proto3"; option java_multiple_files = true; -option java_package = "org.apache.servicecomb.saga.pack.contract.grpc"; +option java_package = "org.apache.servicecomb.pack.contract.grpc"; option java_outer_classname = "TxEventProto"; import "GrpcCommon.proto"; diff --git a/pack-contracts/pom.xml b/pack-contracts/pom.xml index ed2a5d5a3..4d6d2da12 100644 --- a/pack-contracts/pom.xml +++ b/pack-contracts/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 pack-contracts - Saga::Pack Contracts + Pack::Pack Contracts pom diff --git a/saga-persistence/saga-persistence-jpa/pom.xml b/persistence/persistence-jpa/pom.xml similarity index 94% rename from saga-persistence/saga-persistence-jpa/pom.xml rename to persistence/persistence-jpa/pom.xml index 6bd5dd8d0..c68e377cb 100644 --- a/saga-persistence/saga-persistence-jpa/pom.xml +++ b/persistence/persistence-jpa/pom.xml @@ -20,13 +20,14 @@ 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"> - saga-persistence - org.apache.servicecomb.saga + persistence + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - saga-persistence-jpa + Pack::Persistence::JPA + persistence-jpa diff --git a/saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java b/persistence/persistence-jpa/src/main/java/org/apache/servicecomb/pack/persistence/jpa/EclipseLinkJpaConfiguration.java similarity index 97% rename from saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java rename to persistence/persistence-jpa/src/main/java/org/apache/servicecomb/pack/persistence/jpa/EclipseLinkJpaConfiguration.java index da3f334c7..2c8da03c8 100644 --- a/saga-persistence/saga-persistence-jpa/src/main/java/org/apache/servicecomb/saga/persistence/jpa/EclipseLinkJpaConfiguration.java +++ b/persistence/persistence-jpa/src/main/java/org/apache/servicecomb/pack/persistence/jpa/EclipseLinkJpaConfiguration.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package org.apache.servicecomb.saga.persistence.jpa; +package org.apache.servicecomb.pack.persistence.jpa; import java.util.Collections; import java.util.HashMap; diff --git a/saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories b/persistence/persistence-jpa/src/main/resources/META-INF/spring.factories similarity index 94% rename from saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories rename to persistence/persistence-jpa/src/main/resources/META-INF/spring.factories index 1d6b85033..f18c6a520 100644 --- a/saga-persistence/saga-persistence-jpa/src/main/resources/META-INF/spring.factories +++ b/persistence/persistence-jpa/src/main/resources/META-INF/spring.factories @@ -15,4 +15,4 @@ ## limitations under the License. ## --------------------------------------------------------------------------- org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.servicecomb.saga.persistence.jpa.EclipseLinkJpaConfiguration + org.apache.servicecomb.pack.persistence.jpa.EclipseLinkJpaConfiguration diff --git a/saga-persistence/pom.xml b/persistence/pom.xml similarity index 88% rename from saga-persistence/pom.xml rename to persistence/pom.xml index 134c83de5..990ab8446 100644 --- a/saga-persistence/pom.xml +++ b/persistence/pom.xml @@ -21,15 +21,16 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - saga-persistence + persistence + Pack::Persistence pom - saga-persistence-jpa + persistence-jpa diff --git a/pom.xml b/pom.xml index f1eef1327..5c8aa56ed 100644 --- a/pom.xml +++ b/pom.xml @@ -25,26 +25,20 @@ 18 - org.apache.servicecomb.saga + org.apache.servicecomb.pack saga pom 0.3.0-SNAPSHOT - saga-core - saga-core-akka - transports - saga-spring docker-build-config - saga-format - saga-discovery - saga-web omega alpha pack-contracts pack-common integration-tests - saga-persistence + persistence + web @@ -242,124 +236,84 @@ 3.3.2.Final - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-feign 0.3.0-SNAPSHOT - org.apache.servicecomb.saga - saga-core - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga - saga-core-akka - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga - saga-core - test-jar - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga - saga-format - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga - saga-spring - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga.transports + org.apache.servicecomb.pack.transports transport-httpclient 0.3.0-SNAPSHOT - org.apache.servicecomb.saga.transports - transport-httpclient-spring - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga.transports - transport-resttemplate - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga.discovery - saga-discovery-servicecenter - 0.3.0-SNAPSHOT - - - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-context 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transaction 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-tx 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-resttemplate 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-dubbo 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-transport-servicecomb 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-connector-grpc 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-spring-starter 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack omega-format 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-core 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack alpha-server 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-contract-grpc 0.3.0-SNAPSHOT - org.apache.servicecomb.saga + org.apache.servicecomb.pack pack-common 0.3.0-SNAPSHOT + - org.apache.servicecomb.saga - saga-persistence-jpa + org.apache.servicecomb.pack + persistence-jpa 0.3.0-SNAPSHOT @@ -653,7 +607,7 @@ - org.apache.servicecomb.saga + org.apache.servicecomb.pack docker-build-config ${project.version} @@ -823,8 +777,8 @@ release - saga-demo - saga-distribution + demo + distribution @@ -885,7 +839,7 @@ demo - saga-demo + demo acceptance-tests diff --git a/saga-core-akka/pom.xml b/saga-core-akka/pom.xml deleted file mode 100644 index a019a25ae..000000000 --- a/saga-core-akka/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - saga-core-akka - Saga::Core::Akka - - - - com.lmax - disruptor - - - org.slf4j - slf4j-api - - - org.apache.logging.log4j - log4j-slf4j-impl - - - org.apache.logging.log4j - log4j-api - - - org.apache.logging.log4j - log4j-core - - - org.apache.servicecomb.saga - saga-core - - - com.typesafe.akka - akka-actor_2.12 - - - com.typesafe.akka - akka-slf4j_2.12 - - - io.kamon - kamon-core_2.12 - - - io.kamon - kamon-annotation_2.12 - - - - - com.typesafe.akka - akka-testkit_2.12 - - - org.scalatest - scalatest_2.12 - - - junit - junit - - - org.hamcrest - hamcrest-all - - - org.mockito - mockito-core - - 1.10.19 - - - org.apache.commons - commons-lang3 - - - org.awaitility - awaitility - - - com.github.seanyinx - unit-scaffolding - - - org.apache.servicecomb.saga - saga-core - test-jar - 0.3.0-SNAPSHOT - test - - - org.apache.servicecomb.saga - saga-core - - - - diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSaga.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSaga.java deleted file mode 100644 index 36fae1fe5..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSaga.java +++ /dev/null @@ -1,65 +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.core.actors; - -import java.util.concurrent.CompletableFuture; - -import org.apache.servicecomb.saga.core.EventContext; -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.Saga; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; - -import akka.actor.ActorRef; - -public class ActorBasedSaga implements Saga { - private final ActorRef root; - private final ActorRef completionCallback; - private final CompletableFuture future; - private final EventStore sagaLog; - private final EventContext sagaContext; - - ActorBasedSaga(ActorRef root, ActorRef completionCallback, CompletableFuture future, EventStore sagaLog, - EventContext sagaContext) { - this.root = root; - this.completionCallback = completionCallback; - this.future = future; - this.sagaLog = sagaLog; - this.sagaContext = sagaContext; - } - - @Override - public SagaResponse run() { - root.tell(new TransactMessage(NoOpSagaRequest.SAGA_START_REQUEST, SagaResponse.EMPTY_RESPONSE), completionCallback); - - return future.join(); - } - - @Override - public void play() { - gatherEvents(sagaLog); - } - - private void gatherEvents(Iterable events) { - for (SagaEvent event : events) { - event.gatherTo(sagaContext); - } - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaFactory.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaFactory.java deleted file mode 100644 index 8ce22fa6d..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaFactory.java +++ /dev/null @@ -1,83 +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.core.actors; - -import static akka.actor.ActorRef.noSender; - -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.application.SagaFactory; -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaTaskFactory; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import scala.concurrent.Await; -import scala.concurrent.duration.Duration; - -public class ActorBasedSagaFactory implements SagaFactory { - private final ActorSystem actorSystem = ActorSystem.create("saga"); - private final RequestActorBuilder actorBuilder; - private final SagaTaskFactory sagaTaskFactory; - - public ActorBasedSagaFactory(int retryDelay, - PersistentStore persistentStore, - FromJsonFormat> childrenExtractor) { - - this.sagaTaskFactory = new SagaTaskFactory(retryDelay, persistentStore); - this.actorBuilder = new RequestActorBuilder(actorSystem, childrenExtractor); - } - - @Override - public ActorBasedSaga createSaga(String requestJson, String sagaId, EventStore sagaLog, SagaDefinition definition) { - - CompletableFuture future = new CompletableFuture<>(); - ActorRef completionCallback = actorSystem.actorOf(CompletionCallbackActor.props(future)); - RequestActorContext context = actorBuilder.build( - definition.requests(), - sagaTaskFactory.sagaTasks(sagaId, - requestJson, - definition.policy(), - sagaLog - ), - completionCallback); - - completionCallback.tell(context, noSender()); - return new ActorBasedSaga( - context.actorOf(NoOpSagaRequest.SAGA_START_REQUEST.id()), - completionCallback, - future, - sagaLog, - new EventContextImpl(context)); - } - - @Override - public boolean isTerminated() { - return actorSystem.whenTerminated().isCompleted(); - } - - @Override - public void terminate() throws Exception { - Await.result(actorSystem.terminate(), Duration.Inf()); - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActor.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActor.java deleted file mode 100644 index 7cee4d301..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActor.java +++ /dev/null @@ -1,69 +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.core.actors; - -import java.util.concurrent.CompletableFuture; - -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.actors.messages.AbortMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensateMessage; -import org.apache.servicecomb.saga.core.actors.messages.FailMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; -import akka.actor.AbstractLoggingActor; -import akka.actor.Props; - -class CompletionCallbackActor extends AbstractLoggingActor { - private final CompletableFuture future; - - private CompletionCallbackActor(CompletableFuture future) { - this.future = future; - } - - static Props props(CompletableFuture future) { - return Props.create(CompletionCallbackActor.class, () -> new CompletionCallbackActor(future)); - } - - @Override - public Receive createReceive() { - return receiveBuilder() - .match(RequestActorContext.class, this::ready) - .build(); - } - - private void ready(RequestActorContext context) { - getContext().become(receiveBuilder() - .match(CompensateMessage.class, message -> end(context, message.response())) - .match(TransactMessage.class, message -> end(context, message.response())) - .match(AbortMessage.class, message -> onAbort(context, message)) - .match(FailMessage.class, message -> end(context, message.response())) - .build()); - } - - private void onAbort(RequestActorContext context, AbortMessage message) { - log().info("saga actor: received abort message of {}", message.response()); - context.actorOf(NoOpSagaRequest.SAGA_END_REQUEST.id()).tell(new CompensateMessage(message.response()), self()); - } - - private void end(RequestActorContext context, SagaResponse response) { - log().info("saga actor: received response {}", response); - future.complete(response); - context.forAll(actor -> getContext().stop(actor)); - getContext().stop(self()); - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/EventContextImpl.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/EventContextImpl.java deleted file mode 100644 index 21a2928a7..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/EventContextImpl.java +++ /dev/null @@ -1,60 +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.core.actors; - -import static akka.actor.ActorRef.noSender; - -import org.apache.servicecomb.saga.core.EventContext; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.actors.messages.AbortRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensationRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactionRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.Message; - -public class EventContextImpl implements EventContext { - private final RequestActorContext context; - - EventContextImpl(RequestActorContext context) { - this.context = context; - } - - @Override - public void beginTransaction(SagaRequest request) { - - } - - @Override - public void endTransaction(SagaRequest request, SagaResponse response) { - sendMessage(request, new TransactionRecoveryMessage(response)); - } - - @Override - public void abortTransaction(SagaRequest request, SagaResponse response) { - sendMessage(request, new AbortRecoveryMessage(response)); - } - - @Override - public void compensateTransaction(SagaRequest request, SagaResponse response) { - sendMessage(request, new CompensationRecoveryMessage()); - } - - private void sendMessage(SagaRequest request, Message message) { - context.actorOf(request.id()).tell(message, noSender()); - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActor.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActor.java deleted file mode 100644 index 055174e23..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActor.java +++ /dev/null @@ -1,206 +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.core.actors; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Supplier; - -import org.apache.servicecomb.saga.core.CompositeSagaResponse; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SagaStartFailedException; -import org.apache.servicecomb.saga.core.SagaTask; -import org.apache.servicecomb.saga.core.TransactionFailedException; -import org.apache.servicecomb.saga.core.actors.messages.AbortMessage; -import org.apache.servicecomb.saga.core.actors.messages.AbortRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensationRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.FailMessage; -import org.apache.servicecomb.saga.core.actors.messages.Message; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactionRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensateMessage; - -import akka.actor.AbstractLoggingActor; -import akka.actor.ActorRef; -import akka.actor.Props; -import akka.japi.pf.ReceiveBuilder; - -public class RequestActor extends AbstractLoggingActor { - private final RequestActorContext context; - private final SagaTask task; - private final SagaRequest request; - - private final List parentResponses; - private final List compensatedChildren; - - private final Receive transacted; - private final Receive aborted; - - static Props props( - RequestActorContext context, - SagaTask task, - SagaRequest request) { - return Props.create(RequestActor.class, () -> new RequestActor(context, task, request)); - } - - private RequestActor( - RequestActorContext context, - SagaTask task, - SagaRequest request) { - this.context = context; - this.task = task; - this.request = request; - this.parentResponses = new ArrayList<>(request.parents().length); - this.compensatedChildren = new LinkedList<>(); - - this.aborted = onReceive(ignored -> { - }).build(); - - this.transacted = onReceive(task::compensate) - .match(CompensationRecoveryMessage.class, message -> getContext().become(aborted)) - .build(); - } - - @Override - public Receive createReceive() { - return receiveBuilder() - .match(TransactMessage.class, - message -> onTransaction(message, () -> task.commit(request, responseOf(parentResponses)))) - .match(TransactionRecoveryMessage.class, this::onTransactRecovery) - .match(AbortRecoveryMessage.class, this::onAbortRecovery) - .match(AbortMessage.class, this::onAbort) - .build(); - } - - private void onAbort(AbortMessage message) { - log().debug("{}: received abort message of {}", request.id(), message.response()); - sendToChildrenButSender(message); - sendToParentsButSender(message); - - getContext().become(aborted); - } - - private void sendToParentsButSender(AbortMessage message) { - context.parentsOf(request) - .stream() - .filter(this::isNotSender) - .forEach(actor -> actor.tell(message, self())); - } - - private void sendToChildrenButSender(AbortMessage message) { - context.childrenOf(request) - .stream() - .filter(this::isNotSender) - .forEach(actor -> actor.tell(message, self())); - } - - private boolean isNotSender(ActorRef actor) { - return !actor.equals(sender()); - } - - private void onTransactRecovery(TransactionRecoveryMessage message) { - getContext().become(receiveBuilder() - .match(TransactMessage.class, m -> onTransaction(m, message::response)) - .match(CompensationRecoveryMessage.class, m -> getContext().become(aborted)) - .build() - ); - } - - private void onAbortRecovery(AbortRecoveryMessage message) { - getContext().become( - receiveBuilder() - .match(TransactMessage.class, m -> onAbort(new AbortMessage(message.response()))) - .build()); - } - - private void onTransaction(TransactMessage message, Supplier responseSupplier) { - log().debug("{}: received transaction message of {}", request.id(), message.request()); - if (context.parentsOf(request).contains(sender())) { - parentResponses.add(message.response()); - } - - if (parentResponses.size() == context.parentsOf(request).size()) { - transact(responseSupplier); - } - } - - private void transact(Supplier responseSupplier) { - try { - if (isChosenChild(parentResponses)) { - SagaResponse sagaResponse = responseSupplier.get(); - sendToChildren(new TransactMessage(request, sagaResponse)); - getContext().become(transacted); - } else { - sendToChildren(new TransactMessage(request, SagaResponse.NONE_RESPONSE)); - getContext().become(aborted); - } - } catch (SagaStartFailedException e) { - sendToParents(new FailMessage(e)); - } catch (Exception e) { - log().error("Failed to run operation {} with error {}", request.transaction(), e); - - Message abortMessage = new AbortMessage(new TransactionFailedException(e)); - sendToParents(abortMessage); - sendToChildren(abortMessage); - getContext().become(aborted); - } - } - - private void sendToParents(Message message) { - context.parentsOf(request).forEach(actor -> actor.tell(message, self())); - } - - private void sendToChildren(Message message) { - context.childrenOf(request).forEach(actor -> actor.tell(message, self())); - } - - private boolean isChosenChild(List parentResponses) { - return request.parents().length == 0 || parentResponses.isEmpty() || parentResponses.stream() - .map(context::chosenChildren) - .anyMatch(chosenChildren -> chosenChildren.isEmpty() || chosenChildren.contains(request.id())); - } - - private SagaResponse responseOf(List responseContexts) { - if (responseContexts.isEmpty()) { - return SagaResponse.EMPTY_RESPONSE; - } - - if (responseContexts.size() == 1) { - return responseContexts.get(0); - } - return new CompositeSagaResponse(responseContexts); - } - - private ReceiveBuilder onReceive(Consumer requestConsumer) { - return receiveBuilder() - .match(CompensateMessage.class, message -> onCompensate(message, requestConsumer)); - } - - private void onCompensate(CompensateMessage message, Consumer requestConsumer) { - log().debug("{}: received compensation message from {}", request.id(), sender()); - compensatedChildren.add(sender()); - - if (compensatedChildren.size() == context.childrenOf(request).size()) { - requestConsumer.accept(request); - sendToParents(message); - } - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilder.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilder.java deleted file mode 100644 index 5004b4ecc..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilder.java +++ /dev/null @@ -1,108 +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.core.actors; - -import java.util.Map; -import java.util.Set; - -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaTask; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.actor.Props; - -public class RequestActorBuilder { - private final ActorSystem actorSystem; - private final FromJsonFormat> childrenExtractor; - - RequestActorBuilder( - ActorSystem actorSystem, - FromJsonFormat> childrenExtractor) { - - this.actorSystem = actorSystem; - this.childrenExtractor = childrenExtractor; - } - - public RequestActorContext build(SagaRequest[] requests, Map tasks, ActorRef sagaActor) { - RequestActorContext context = new RequestActorContext(childrenExtractor); - - ActorRef rootActor = rootActor(context, tasks); - ActorRef leafActor = leafActor(context, tasks); - - createRequestActors(requests, tasks, context); - - linkActorsById(rootActor, requests, context); - addLeafToChildless(leafActor, requests, context); - - context.addParent(NoOpSagaRequest.SAGA_START_REQUEST.id(), sagaActor); - context.addChild(NoOpSagaRequest.SAGA_END_REQUEST.id(), sagaActor); - return context; - } - - private void linkActorsById(ActorRef rootActor, SagaRequest[] requests, RequestActorContext context) { - for (SagaRequest request : requests) { - if (isOrphan(request)) { - context.addParent(request.id(), rootActor); - context.addChild(NoOpSagaRequest.SAGA_START_REQUEST.id(), context.actorOf(request.id())); - } else { - for (String parent : request.parents()) { - context.addParent(request.id(), context.actorOf(parent)); - context.addChild(parent, context.actorOf(request.id())); - } - } - } - } - - private boolean isOrphan(SagaRequest request) { - return request.parents().length == 0; - } - - private void createRequestActors(SagaRequest[] requests, Map tasks, RequestActorContext context) { - for (SagaRequest request : requests) { - Props props = RequestActor.props(context, tasks.get(request.task()), request); - context.addActor(request.id(), actorSystem.actorOf(props)); - } - } - - private void addLeafToChildless(ActorRef leafActor, SagaRequest[] requests, RequestActorContext context) { - for (SagaRequest request : requests) { - if (context.childrenOf(request).isEmpty()) { - context.addParent(NoOpSagaRequest.SAGA_END_REQUEST.id(), context.actorOf(request.id())); - context.addChild(request.id(), leafActor); - } - } - } - - private ActorRef rootActor(RequestActorContext context, Map tasks) { - Props root = RequestActor.props(context, tasks.get( - NoOpSagaRequest.SAGA_START_REQUEST.task()), NoOpSagaRequest.SAGA_START_REQUEST); - ActorRef actor = actorSystem.actorOf(root); - context.addActor(NoOpSagaRequest.SAGA_START_REQUEST.id(), actor); - return actor; - } - - private ActorRef leafActor(RequestActorContext context, Map tasks) { - Props leaf = RequestActor.props(context, tasks.get( - NoOpSagaRequest.SAGA_END_REQUEST.task()), NoOpSagaRequest.SAGA_END_REQUEST); - ActorRef actor = actorSystem.actorOf(leaf); - context.addActor(NoOpSagaRequest.SAGA_END_REQUEST.id(), actor); - return actor; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorContext.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorContext.java deleted file mode 100644 index 2e3149d40..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/RequestActorContext.java +++ /dev/null @@ -1,82 +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.core.actors; - -import static java.util.Collections.emptyList; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.Consumer; - -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import akka.actor.ActorRef; - -class RequestActorContext { - private final Map actors; - private final Map> parents; - private final Map> children; - private final FromJsonFormat> childrenExtractor; - - RequestActorContext( - FromJsonFormat> childrenExtractor) { - this.actors = new HashMap<>(); - this.children = new HashMap<>(); - this.parents = new HashMap<>(); - this.childrenExtractor = childrenExtractor; - } - - void addActor(String id, ActorRef actorRef) { - actors.put(id, actorRef); - } - - void addChild(String requestId, ActorRef ref) { - children.computeIfAbsent(requestId, k -> new ArrayList<>()).add(ref); - } - - void addParent(String requestId, ActorRef ref) { - parents.computeIfAbsent(requestId, k -> new ArrayList<>()).add(ref); - } - - ActorRef actorOf(String id) { - return actors.get(id); - } - - Collection parentsOf(SagaRequest request) { - return parents.getOrDefault(request.id(), emptyList()); - } - - Collection childrenOf(SagaRequest request) { - return children.getOrDefault(request.id(), emptyList()); - } - - void forAll(Consumer consumer) { - actors.values() - .stream() - .forEach(consumer); - } - - Set chosenChildren(SagaResponse response) { - return childrenExtractor.fromJson(response.body()); - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortMessage.java deleted file mode 100644 index f23a0790d..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortMessage.java +++ /dev/null @@ -1,37 +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.core.actors.messages; - -import org.apache.servicecomb.saga.core.FailedSagaResponse; -import org.apache.servicecomb.saga.core.SagaResponse; - -public class AbortMessage implements Message { - private final SagaResponse response; - - public AbortMessage(Throwable e) { - response = new FailedSagaResponse(e); - } - - public AbortMessage(SagaResponse response) { - this.response = response; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortRecoveryMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortRecoveryMessage.java deleted file mode 100644 index 951157d29..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/AbortRecoveryMessage.java +++ /dev/null @@ -1,33 +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.core.actors.messages; - -import org.apache.servicecomb.saga.core.SagaResponse; - -public class AbortRecoveryMessage implements Message { - - private final SagaResponse response; - - public AbortRecoveryMessage(SagaResponse response) { - this.response = response; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensateMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensateMessage.java deleted file mode 100644 index 5fd07019b..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensateMessage.java +++ /dev/null @@ -1,32 +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.core.actors.messages; - -import org.apache.servicecomb.saga.core.SagaResponse; - -public class CompensateMessage implements Message { - private final SagaResponse response; - - public CompensateMessage(SagaResponse response) { - this.response = response; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensationRecoveryMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensationRecoveryMessage.java deleted file mode 100644 index 421a0928a..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/CompensationRecoveryMessage.java +++ /dev/null @@ -1,22 +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.core.actors.messages; - -public class CompensationRecoveryMessage implements Message { - -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/FailMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/FailMessage.java deleted file mode 100644 index 7a80ecb66..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/FailMessage.java +++ /dev/null @@ -1,33 +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.core.actors.messages; - -import org.apache.servicecomb.saga.core.FailedSagaResponse; -import org.apache.servicecomb.saga.core.SagaResponse; - -public class FailMessage implements Message { - private final SagaResponse response; - - public FailMessage(Throwable e) { - response = new FailedSagaResponse(e); - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/Message.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/Message.java deleted file mode 100644 index 3ed818765..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/Message.java +++ /dev/null @@ -1,21 +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.core.actors.messages; - -public interface Message { -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactMessage.java deleted file mode 100644 index e78be8dbf..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactMessage.java +++ /dev/null @@ -1,40 +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.core.actors.messages; - - -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; - -public class TransactMessage implements Message { - private final SagaRequest request; - private final SagaResponse response; - - public TransactMessage(SagaRequest request, SagaResponse response) { - this.request = request; - this.response = response; - } - - public SagaRequest request() { - return request; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactionRecoveryMessage.java b/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactionRecoveryMessage.java deleted file mode 100644 index 26ba05b89..000000000 --- a/saga-core-akka/src/main/java/org/apache/servicecomb/saga/core/actors/messages/TransactionRecoveryMessage.java +++ /dev/null @@ -1,32 +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.core.actors.messages; - -import org.apache.servicecomb.saga.core.SagaResponse; - -public class TransactionRecoveryMessage implements Message { - private final SagaResponse response; - - public TransactionRecoveryMessage(SagaResponse response) { - this.response = response; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaExecutionComponentTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaExecutionComponentTest.java deleted file mode 100644 index a5633dbff..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaExecutionComponentTest.java +++ /dev/null @@ -1,31 +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.core.actors; - -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaExecutionComponentTestBase; -import org.apache.servicecomb.saga.core.application.SagaFactory; - - -public class ActorBasedSagaExecutionComponentTest extends SagaExecutionComponentTestBase { - - @Override - protected SagaFactory sagaFactory(PersistentStore eventStore) { - return new ActorBasedSagaFactory(500, eventStore, null); - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaIntegrationTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaIntegrationTest.java deleted file mode 100644 index de62cf2b0..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/ActorBasedSagaIntegrationTest.java +++ /dev/null @@ -1,692 +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.core.actors; - -import static org.apache.servicecomb.saga.core.Transaction.SAGA_END_TRANSACTION; -import static org.apache.servicecomb.saga.core.Transaction.SAGA_START_TRANSACTION; -import static java.util.Arrays.asList; -import static java.util.Collections.emptySet; -import static java.util.Collections.singletonList; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.hamcrest.CoreMatchers.anyOf; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.CyclicBarrier; - -import org.apache.servicecomb.saga.core.BackwardRecovery; -import org.apache.servicecomb.saga.core.Compensation; -import org.apache.servicecomb.saga.core.EventEnvelope; -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.Fallback; -import org.apache.servicecomb.saga.core.ForwardRecovery; -import org.apache.servicecomb.saga.core.IdGenerator; -import org.apache.servicecomb.saga.core.LongIdGenerator; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.Saga; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaEndedEvent; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.apache.servicecomb.saga.core.SagaEventMatcher; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SagaStartedEvent; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.apache.servicecomb.saga.core.Transaction; -import org.apache.servicecomb.saga.core.TransactionAbortedEvent; -import org.apache.servicecomb.saga.core.TransactionCompensatedEvent; -import org.apache.servicecomb.saga.core.TransactionEndedEvent; -import org.apache.servicecomb.saga.core.TransactionStartedEvent; -import org.apache.servicecomb.saga.core.application.SagaFactory; -import org.hamcrest.CoreMatchers; -import org.hamcrest.collection.IsIterableContainingInOrder; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.mockito.stubbing.Answer; - -import com.seanyinx.github.unit.scaffolding.Randomness; - -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.infrastructure.EmbeddedEventStore; - -@SuppressWarnings("unchecked") -public class ActorBasedSagaIntegrationTest { - private static final String sagaId = Randomness.uniquify("sagaId"); - - private final FromJsonFormat> childrenExtractor = mock(FromJsonFormat.class); - private final IdGenerator idGenerator = new LongIdGenerator(); - private final EventStore eventStore = new EmbeddedEventStore(); - - private final PersistentStore persistentStore = mock(PersistentStore.class); - private final SagaDefinition sagaDefinition = mock(SagaDefinition.class); - - private final Transaction transaction1 = mock(Transaction.class, "transaction1"); - private final Transaction transaction2 = mock(Transaction.class, "transaction2"); - private final Transaction transaction3 = mock(Transaction.class, "transaction3"); - private final Transaction transaction4 = mock(Transaction.class, "transaction4"); - - private final Compensation compensation1 = mock(Compensation.class, "compensation1"); - private final Compensation compensation2 = mock(Compensation.class, "compensation2"); - private final Compensation compensation3 = mock(Compensation.class, "compensation3"); - private final Compensation compensation4 = mock(Compensation.class, "compensation4"); - - private final Fallback fallback1 = mock(Fallback.class, "fallback1"); - - private final String requestJson = "{}"; - private final SagaRequest request1 = request("request1", "service1", transaction1, compensation1, fallback1); - private final SagaRequest request2 = request("request2", "service2", transaction2, compensation2, request1.id()); - private final SagaRequest request3 = request("request3", "service3", transaction3, compensation3, request1.id()); - private final SagaRequest request4 = request("request4", "service4", transaction4, compensation4, request3.id()); - - private final SagaResponse transactionResponse1 = new SuccessfulSagaResponse("transaction1"); - private final SagaResponse transactionResponse2 = new SuccessfulSagaResponse("transaction2"); - private final SagaResponse transactionResponse3 = new SuccessfulSagaResponse("transaction3"); - private final SagaResponse compensationResponse1 = new SuccessfulSagaResponse("compensation1"); - private final SagaResponse compensationResponse2 = new SuccessfulSagaResponse("compensation2"); - private final SagaResponse compensationResponse3 = new SuccessfulSagaResponse("compensation3"); - - @SuppressWarnings("ThrowableInstanceNeverThrown") - private final RuntimeException exception = new RuntimeException("oops"); - - private Saga saga; - private final SagaFactory sagaFactory = new ActorBasedSagaFactory(100, persistentStore, childrenExtractor); - - // root - node1 - node2 - leaf - @Before - public void setUp() throws Exception { - when(sagaDefinition.policy()).thenReturn(new BackwardRecovery()); - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2}); - - when(childrenExtractor.fromJson(anyString())).thenReturn(emptySet()); - when(childrenExtractor.fromJson(SagaResponse.NONE_RESPONSE.body())).thenReturn(setOf("none")); - - when(transaction1.send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE)).thenReturn(transactionResponse1); - when(transaction2.send(request2.serviceName(), transactionResponse1)).thenReturn(transactionResponse2); - when(transaction3.send(request3.serviceName(), transactionResponse1)).thenReturn(transactionResponse3); - - when(compensation1.send(request1.serviceName(), compensationResponse2)).thenReturn(compensationResponse1); - when(compensation2.send(request2.serviceName(), compensationResponse3)).thenReturn(compensationResponse2); - when(compensation3.send(request3.serviceName(), SagaResponse.EMPTY_RESPONSE)).thenReturn(compensationResponse3); - } - - @After - public void tearDown() throws Exception { - sagaFactory.terminate(); - assertTrue(sagaFactory.isTerminated()); - } - - @Test - public void transactionsAreRunSuccessfully() { - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - // root - node1 - node2 - leaf - // \_ node3 _/ - @Test - public void compensateCommittedTransactionsOnFailure() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - // barrier to make sure the two transactions starts at the same time - CyclicBarrier barrier = new CyclicBarrier(2); - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenAnswer( - withAnswer(() -> { - barrier.await(); - Thread.sleep(100); - throw exception; - })); - - when(transaction3.send(request3.serviceName(), transactionResponse1)) - .thenAnswer( - withAnswer(() -> { - barrier.await(); - return transactionResponse3; - })); - - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - CoreMatchers.anyOf(SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), SagaEventMatcher - .eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - CoreMatchers.anyOf(SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), SagaEventMatcher - .eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation3, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class))); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3).send(request3.serviceName()); - } - - @Test - public void skipIgnoredTransaction() throws Exception { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf(request3.id())); - - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void skipAllIgnoredTransactions() throws Exception { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3, request4}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf("none")); - - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction4, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - verify(compensation4, never()).send(request4.serviceName()); - } - - @Test - public void doNotCompensateIgnoredTransactions() throws Exception { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3, request4}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf(request3.id())); - - when(transaction4.send(request4.serviceName(), transactionResponse3)).thenThrow(exception); - - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction4, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction4, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - verify(transaction4).send(request4.serviceName(), transactionResponse3); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation3).send(request3.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation4, never()).send(request4.serviceName()); - } - - // TODO: 2017/10/31 actor will hang and its parent and children will be blocked without its response, timeout must be applied - @Ignore - // root - node1 - node2 - leaf - // \_ node3 _/ - @Test - public void redoHangingTransactionsOnFailure() throws InterruptedException { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - // barrier to make sure the two transactions starts at the same time - CyclicBarrier barrier = new CyclicBarrier(2); - when(transaction3.send(request3.serviceName(), transactionResponse1)) - .thenAnswer(withAnswer(() -> { - barrier.await(); - throw exception; - })); - - CountDownLatch latch = new CountDownLatch(1); - - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenAnswer(withAnswer(() -> { - barrier.await(); - latch.await(1, SECONDS); - return transactionResponse2; - })).thenReturn(transactionResponse2); - - saga.run(); - - // the ordering of events may not be consistence due to concurrent processing of requests - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - CoreMatchers.anyOf( - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - CoreMatchers.anyOf( - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class)), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class))); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2, times(2)).send(request2.serviceName(), transactionResponse1); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - - latch.countDown(); - } - - @Test - public void retriesFailedTransactionTillSuccess() { - when(sagaDefinition.policy()).thenReturn(new ForwardRecovery()); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenThrow(exception).thenThrow(exception).thenReturn(transactionResponse2); - when(transaction2.retries()).thenReturn(-1); - - saga.run(); - - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2, times(3)).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(anyString(), any(SagaResponse.class)); - verify(compensation2, never()).send(anyString(), any(SagaResponse.class)); - } - - @Test - public void fallbackWhenCompensationFailed() { - int retries = 3; - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - when(transaction2.send(request2.serviceName(), transactionResponse1)).thenThrow(exception); - when(compensation1.send(request1.serviceName())).thenThrow(exception); - when(compensation1.retries()).thenReturn(retries); - - saga.run(); - - verify(transaction1).send(request1.serviceName(), SagaResponse.EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, times(retries + 1)).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - - verify(fallback1).send(request1.serviceName()); - } - - @Test - public void restoresSagaToTransactionStateByPlayingAllEvents() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1, transactionResponse1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2, transactionResponse2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresPartialTransactionByPlayingAllEvents() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1, transactionResponse1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2, transactionResponse2)), - envelope(new TransactionStartedEvent(sagaId, request3)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresToCompensationFromAbortedTransactionByPlayingAllEvents() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionAbortedEvent(sagaId, request3, exception)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresSagaToCompensationStateByPlayingAllEvents() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionAbortedEvent(sagaId, request3, exception)), - envelope(new TransactionCompensatedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresPartialCompensationByPlayingAllEvents() { - when(sagaDefinition.requests()).thenReturn(new SagaRequest[]{request1, request2, request3}); - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionAbortedEvent(sagaId, request3, exception)), - envelope(new TransactionCompensatedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - SagaEventMatcher.eventWith(sagaId, Compensation.SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresSagaToEndStateByPlayingAllEvents() { - saga = sagaFactory.createSaga(requestJson, sagaId, eventStore, sagaDefinition); - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, IsIterableContainingInOrder.contains( - SagaEventMatcher.eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction1, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionStartedEvent.class), - SagaEventMatcher.eventWith(sagaId, transaction2, TransactionEndedEvent.class), - SagaEventMatcher.eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - @Test - public void failFastIfSagaLogIsDown() throws Exception { - EventStore sagaLog = mock(EventStore.class); - saga = sagaFactory.createSaga(requestJson, sagaId, sagaLog, sagaDefinition); - - doThrow(RuntimeException.class).when(sagaLog).offer(any(SagaStartedEvent.class)); - - saga.run(); - - verify(sagaLog).offer(any(SagaStartedEvent.class)); - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - private Answer withAnswer(Callable callable) { - return invocationOnMock -> callable.call(); - } - - private EventEnvelope envelope(SagaEvent event) { - return new EventEnvelope(idGenerator.nextId(), event); - } - - private SagaRequest request(String requestId, - String serviceName, - Transaction transaction, - Compensation compensation, - String... parentIds) { - - return new SagaRequestImpl(requestId, serviceName, Operation.TYPE_REST, transaction, compensation, parentIds); - } - - private SagaRequest request(String requestId, - String serviceName, - Transaction transaction, - Compensation compensation, - Fallback fallback) { - - return new SagaRequestImpl(requestId, serviceName, Operation.TYPE_REST, transaction, compensation, fallback); - } - - private HashSet setOf(String requestId) { - return new HashSet<>(singletonList(requestId)); - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActorTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActorTest.java deleted file mode 100644 index 7057de46e..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/CompletionCallbackActorTest.java +++ /dev/null @@ -1,140 +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.core.actors; - -import static akka.actor.ActorRef.noSender; -import static akka.actor.Props.empty; -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static java.time.temporal.ChronoUnit.SECONDS; -import static org.awaitility.Awaitility.await; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThat; - -import java.time.Duration; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.TimeUnit; - -import org.apache.servicecomb.saga.core.FailedSagaResponse; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.actors.messages.AbortMessage; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import org.apache.servicecomb.saga.core.actors.messages.CompensateMessage; -import org.apache.servicecomb.saga.core.actors.messages.FailMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.testkit.javadsl.TestKit; - -public class CompletionCallbackActorTest { - private static final ActorSystem actorSystem = ActorSystem.create(); - - private final SagaResponse response = Mockito.mock(SagaResponse.class); - private final RequestActorContext context = new RequestActorContext(null); - - private final ActorRef actor1 = someActor(); - private final ActorRef actor2 = someActor(); - - @Before - public void setUp() throws Exception { - context.addActor(uniquify("requestId"), actor1); - context.addActor(uniquify("requestId"), actor2); - } - - @AfterClass - public static void tearDown() throws Exception { - TestKit.shutdownActorSystem(actorSystem); - } - - @Test - public void killAllOnTransactionComplete() throws Exception { - new TestKit(actorSystem) {{ - CompletableFuture future = new CompletableFuture<>(); - - ActorRef actor = actorSystem.actorOf(CompletionCallbackActor.props(future)); - - actor.tell(context, noSender()); - actor.tell(new TransactMessage(null, response), noSender()); - - await().atMost(2, TimeUnit.SECONDS) - .until(() -> actor1.isTerminated() && actor2.isTerminated() && actor.isTerminated()); - - assertThat(future.get(), is(response)); - }}; - } - - @Test - public void killAllOnCompensationComplete() throws Exception { - new TestKit(actorSystem) {{ - CompletableFuture future = new CompletableFuture<>(); - - ActorRef actor = actorSystem.actorOf(CompletionCallbackActor.props(future)); - - actor.tell(context, noSender()); - actor.tell(new CompensateMessage(response), noSender()); - - await().atMost(2, TimeUnit.SECONDS) - .until(() -> actor1.isTerminated() && actor2.isTerminated() && actor.isTerminated()); - - assertThat(future.get(), is(response)); - }}; - } - - @Test - public void killAllOnFailure() throws Exception { - new TestKit(actorSystem) {{ - CompletableFuture future = new CompletableFuture<>(); - - ActorRef actor = actorSystem.actorOf(CompletionCallbackActor.props(future)); - - actor.tell(context, noSender()); - actor.tell(new FailMessage(new RuntimeException("oops")), noSender()); - - await().atMost(2, TimeUnit.SECONDS) - .until(() -> actor1.isTerminated() && actor2.isTerminated() && actor.isTerminated()); - - assertThat(future.get(), is(instanceOf(FailedSagaResponse.class))); - }}; - } - - @Test - public void tellLeafToCompensateOnAbort() throws Exception { - new TestKit(actorSystem) {{ - context.addActor(NoOpSagaRequest.SAGA_END_REQUEST.id(), getRef()); - CompletableFuture future = new CompletableFuture<>(); - - ActorRef actor = actorSystem.actorOf(CompletionCallbackActor.props(future)); - - actor.tell(context, noSender()); - AbortMessage message = new AbortMessage(new RuntimeException("oops")); - actor.tell(message, noSender()); - - CompensateMessage compensateMessage = (CompensateMessage) receiveOne(Duration.of(2, SECONDS)); - assertThat(compensateMessage.response(), is(message.response())); - }}; - } - - private ActorRef someActor() { - return actorSystem.actorOf(empty()); - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/EventContextImplTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/EventContextImplTest.java deleted file mode 100644 index ae11d90f5..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/EventContextImplTest.java +++ /dev/null @@ -1,96 +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.core.actors; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static java.time.temporal.ChronoUnit.SECONDS; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.when; - -import java.time.Duration; - -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.actors.messages.AbortRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensationRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactionRecoveryMessage; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.scalatest.junit.JUnitSuite; - -import akka.actor.ActorSystem; -import akka.testkit.javadsl.TestKit; - -public class EventContextImplTest extends JUnitSuite { - private static final ActorSystem actorSystem = ActorSystem.create(); - - private final SagaRequest request = Mockito.mock(SagaRequest.class); - private final SagaResponse response = Mockito.mock(SagaResponse.class); - - private final RequestActorContext context = new RequestActorContext(null); - private final EventContextImpl eventContext = new EventContextImpl(context); - private final String requestId = uniquify("requestId"); - - @Before - public void setUp() throws Exception { - when(request.id()).thenReturn(requestId); - } - - @AfterClass - public static void tearDown() throws Exception { - TestKit.shutdownActorSystem(actorSystem); - } - - @Test - public void sendTransactionRecoveryMessageToActor_OnTransactionEnd() throws Exception { - new TestKit(actorSystem) {{ - context.addActor(requestId, getRef()); - - eventContext.endTransaction(request, response); - - TransactionRecoveryMessage message = (TransactionRecoveryMessage) receiveOne(Duration.of(2, SECONDS)); - assertThat(message.response(), is(response)); - }}; - } - - @Test - public void sendCompensationRecoveryMessageToActor_OnCompensationEnd() throws Exception { - new TestKit(actorSystem) {{ - context.addActor(requestId, getRef()); - - eventContext.compensateTransaction(request, response); - - expectMsgClass(CompensationRecoveryMessage.class); - }}; - } - - @Test - public void sendAbortMessageToActor_OnAbort() throws Exception { - new TestKit(actorSystem) {{ - context.addActor(requestId, getRef()); - - eventContext.abortTransaction(request, response); - - AbortRecoveryMessage message = ((AbortRecoveryMessage) receiveOne(Duration.of(2, SECONDS))); - assertThat(message.response(), is(response)); - }}; - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilderTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilderTest.java deleted file mode 100644 index f799517ae..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorBuilderTest.java +++ /dev/null @@ -1,175 +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.core.actors; - -import static java.time.temporal.ChronoUnit.SECONDS; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.time.Duration; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.servicecomb.saga.core.CompositeSagaResponse; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SagaTask; -import org.hamcrest.Matchers; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.scalatest.junit.JUnitSuite; - -import com.seanyinx.github.unit.scaffolding.Randomness; - -import org.apache.servicecomb.saga.core.actors.messages.CompensateMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.testkit.javadsl.TestKit; - -@SuppressWarnings("unchecked") -public class RequestActorBuilderTest extends JUnitSuite { - private static final ActorSystem actorSystem = ActorSystem.create(); - - private final String requestId1 = Randomness.uniquify("requestId1"); - private final String requestId2 = Randomness.uniquify("requestId2"); - private final String requestId3 = Randomness.uniquify("requestId3"); - private final String taskId = "some task"; - - private final SagaRequest request1 = Mockito.mock(SagaRequest.class); - private final SagaRequest request2 = Mockito.mock(SagaRequest.class); - private final SagaRequest request3 = Mockito.mock(SagaRequest.class); - - private final SagaResponse response1 = Mockito.mock(SagaResponse.class); - private final SagaResponse response2 = Mockito.mock(SagaResponse.class); - private final SagaResponse response3 = Mockito.mock(SagaResponse.class); - - private final SagaRequest[] requests = {request1, request2, request3}; - - private final SagaTask task = Mockito.mock(SagaTask.class); - private final Map tasks = new HashMap<>(); - - private final FromJsonFormat> childrenExtractor = Mockito.mock(FromJsonFormat.class); - private final RequestActorBuilder actorBuilder = new RequestActorBuilder(actorSystem, childrenExtractor); - - @Before - public void setUp() throws Exception { - tasks.put(SagaTask.SAGA_START_TASK, task); - tasks.put(SagaTask.SAGA_END_TASK, task); - tasks.put(taskId, task); - - when(request1.id()).thenReturn(requestId1); - when(request2.id()).thenReturn(requestId2); - when(request3.id()).thenReturn(requestId3); - - when(request1.task()).thenReturn(taskId); - when(request2.task()).thenReturn(taskId); - when(request3.task()).thenReturn(taskId); - - when(request1.parents()).thenReturn(new String[0]); - when(request2.parents()).thenReturn(new String[] {requestId1}); - when(request3.parents()).thenReturn(new String[] {requestId1}); - - when(task.commit(NoOpSagaRequest.SAGA_START_REQUEST, SagaResponse.EMPTY_RESPONSE)).thenReturn( - SagaResponse.EMPTY_RESPONSE); - when(task.commit(request1, SagaResponse.EMPTY_RESPONSE)).thenReturn(response1); - when(task.commit(request2, response1)).thenReturn(response2); - when(task.commit(request3, response1)).thenReturn(response3); - - when(childrenExtractor.fromJson(anyString())).thenReturn(Collections.emptySet()); - } - - @AfterClass - public static void tearDown() throws Exception { - TestKit.shutdownActorSystem(actorSystem); - } - - @Test - public void createOneActorPerRequest() throws Exception { - new TestKit(actorSystem) {{ - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(SagaResponse.class); - when(task.commit(eq(NoOpSagaRequest.SAGA_END_REQUEST), argumentCaptor.capture())).thenReturn( - SagaResponse.EMPTY_RESPONSE); - - ActorRef root = actorBuilder.build(requests, tasks, getRef()).actorOf(NoOpSagaRequest.SAGA_START_REQUEST.id()); - - root.tell(new TransactMessage(NoOpSagaRequest.SAGA_START_REQUEST, SagaResponse.EMPTY_RESPONSE), getRef()); - - List responses = receiveN(1, Duration.of(2, SECONDS)).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, Matchers.containsInAnyOrder(SagaResponse.EMPTY_RESPONSE)); - - verify(task).commit(NoOpSagaRequest.SAGA_START_REQUEST, SagaResponse.EMPTY_RESPONSE); - verify(task).commit(request1, SagaResponse.EMPTY_RESPONSE); - verify(task).commit(request2, response1); - verify(task).commit(request3, response1); - verify(task).commit(eq(NoOpSagaRequest.SAGA_END_REQUEST), any(SagaResponse.class)); - - SagaResponse response = argumentCaptor.getValue(); - assertThat(response, instanceOf(CompositeSagaResponse.class)); - assertThat(((CompositeSagaResponse) response).responses(), - containsInAnyOrder(response2, response3)); - }}; - } - - @Test - public void compensateAllCompletedTransactions() throws Exception { - new TestKit(actorSystem) {{ - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(SagaResponse.class); - when(task.commit(eq(NoOpSagaRequest.SAGA_END_REQUEST), argumentCaptor.capture())).thenReturn( - SagaResponse.EMPTY_RESPONSE); - - ActorRef root = actorBuilder.build(requests, tasks, getRef()).actorOf(NoOpSagaRequest.SAGA_START_REQUEST.id()); - - root.tell(new TransactMessage(NoOpSagaRequest.SAGA_START_REQUEST, SagaResponse.EMPTY_RESPONSE), getRef()); - - List responses = receiveN(1, Duration.of(2, SECONDS)).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, Matchers.containsInAnyOrder(SagaResponse.EMPTY_RESPONSE)); - - CompensateMessage message = new CompensateMessage(response1); - getLastSender().tell(message, getRef()); - expectMsg(message); - - verify(task).compensate(NoOpSagaRequest.SAGA_START_REQUEST); - verify(task).compensate(request1); - verify(task).compensate(request2); - verify(task).compensate(request3); - verify(task).compensate(NoOpSagaRequest.SAGA_END_REQUEST); - }}; - } -} diff --git a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorTest.java b/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorTest.java deleted file mode 100644 index a9d755fde..000000000 --- a/saga-core-akka/src/test/java/org/apache/servicecomb/saga/core/actors/RequestActorTest.java +++ /dev/null @@ -1,406 +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.core.actors; - -import static akka.actor.ActorRef.noSender; -import static akka.actor.Props.empty; -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static java.time.temporal.ChronoUnit.MILLIS; -import static java.time.temporal.ChronoUnit.SECONDS; -import static java.util.Collections.emptySet; -import static java.util.Collections.singleton; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.time.Duration; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - -import org.apache.servicecomb.saga.core.CompositeSagaResponse; -import org.apache.servicecomb.saga.core.FailedSagaResponse; -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SagaStartFailedException; -import org.apache.servicecomb.saga.core.SagaTask; -import org.apache.servicecomb.saga.core.TransactionFailedException; -import org.apache.servicecomb.saga.core.actors.messages.AbortMessage; -import org.apache.servicecomb.saga.core.actors.messages.CompensationRecoveryMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactMessage; -import org.apache.servicecomb.saga.core.actors.messages.TransactionRecoveryMessage; -import org.hamcrest.Matchers; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; -import org.scalatest.junit.JUnitSuite; - -import org.apache.servicecomb.saga.core.actors.messages.CompensateMessage; -import org.apache.servicecomb.saga.core.actors.messages.FailMessage; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; - -import akka.actor.ActorRef; -import akka.actor.ActorSystem; -import akka.testkit.javadsl.TestKit; - -@SuppressWarnings("unchecked") -public class RequestActorTest extends JUnitSuite { - - public static final Duration TWO_SECONDS = Duration.of(2, SECONDS); - - private final String parentRequestId1 = uniquify("parentRequestId1"); - private final String parentRequestId2 = uniquify("parentRequestId2"); - private final String requestId = uniquify("requestId"); - - private final SagaTask task = Mockito.mock(SagaTask.class); - private final SagaRequest request = Mockito.mock(SagaRequest.class, "request"); - private final SagaRequest request1 = Mockito.mock(SagaRequest.class, "request1"); - private final SagaRequest request2 = Mockito.mock(SagaRequest.class, "request2"); - private final SagaResponse response = Mockito.mock(SagaResponse.class); - private final FromJsonFormat> childrenExtractor = mock(FromJsonFormat.class); - - private final RequestActorContext context = new RequestActorContext(childrenExtractor); - - private final TransactionFailedException exception = new TransactionFailedException("oops"); - private static final ActorSystem actorSystem = ActorSystem.create(); - private final CompensateMessage compensateMessage = new CompensateMessage(new FailedSagaResponse(exception)); - - @Before - public void setUp() throws Exception { - when(childrenExtractor.fromJson(anyString())).thenReturn(emptySet()); - when(request.id()).thenReturn(requestId); - - when(request1.id()).thenReturn(parentRequestId1); - when(request2.id()).thenReturn(parentRequestId2); - } - - @AfterClass - public static void tearDown() throws Exception { - TestKit.shutdownActorSystem(actorSystem); - } - - @Test - public void tellNodeResponseToAllChildren() throws Exception { - new TestKit(actorSystem) {{ - addChildren(getRef()); - - ActorRef parent = someActor(); - context.addParent(requestId, parent); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - when(task.commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE)).thenReturn(response); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), parent); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(response, response)); - - verify(task).commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE); - }}; - } - - @Test - public void executeTransaction_OnlyWhenAllParentsResponsesAreReceived() throws Exception { - new TestKit(actorSystem) {{ - addChildren(getRef()); - - ActorRef parent1 = someActor(); - context.addParent(requestId, parent1); - - ActorRef parent2 = someActor(); - context.addParent(requestId, parent2); - - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(SagaResponse.class); - - when(request.parents()).thenReturn(new String[] {parentRequestId1, parentRequestId2}); - when(task.commit(eq(request), argumentCaptor.capture())).thenReturn(response); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), parent1); - expectNoMessage(Duration.of(500, MILLIS)); - - actorRef.tell(new TransactMessage(request2, SagaResponse.EMPTY_RESPONSE), parent2); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(response, response)); - - SagaResponse response = argumentCaptor.getValue(); - assertThat(response, instanceOf(CompositeSagaResponse.class)); - assertThat(((CompositeSagaResponse) response).responses(), - Matchers.containsInAnyOrder(SagaResponse.EMPTY_RESPONSE, Operation.SUCCESSFUL_SAGA_RESPONSE)); - }}; - } - - @Test - public void tellAllRelativesToAbortOnError() throws Exception { - new TestKit(actorSystem) {{ - context.addChild(requestId, getRef()); - context.addActor(requestId, getRef()); - - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - when(task.commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE)).thenThrow(exception); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), getRef()); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((AbortMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(instanceOf(FailedSagaResponse.class), instanceOf(FailedSagaResponse.class))); - }}; - } - - @Test - public void tellAllRelativesExceptSenderToAbortOnAbort() throws Exception { - new TestKit(actorSystem) {{ - context.addChild(requestId, getRef()); - context.addActor(requestId, getRef()); - - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new AbortMessage(exception), someActor()); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((AbortMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(instanceOf(FailedSagaResponse.class), instanceOf(FailedSagaResponse.class))); - - actorRef.tell(new AbortMessage(exception), someActor()); - expectNoMessage(Duration.of(500, MILLIS)); - }}; - } - - @Test - public void compensateIfTransactionIsCompleted() throws Exception { - new TestKit(actorSystem) {{ - addChildren(someActor()); - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - when(task.commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE)).thenReturn(response); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), getRef()); - actorRef.tell(new AbortMessage(exception), noSender()); - actorRef.tell(compensateMessage, getRef()); - actorRef.tell(compensateMessage, getRef()); - - expectMsg(TWO_SECONDS, compensateMessage); - verify(task).compensate(request); - - // no duplicate compensation - reset(task); - actorRef.tell(compensateMessage, getRef()); - actorRef.tell(compensateMessage, getRef()); - expectNoMessage(Duration.of(200, MILLIS)); - verify(task, never()).compensate(request); - }}; - } - - @Test - public void doNotCompensateIfTransactionIsNotCompleted() throws Exception { - new TestKit(actorSystem) {{ - addChildren(someActor()); - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new AbortMessage(exception), noSender()); - actorRef.tell(compensateMessage, getRef()); - actorRef.tell(compensateMessage, getRef()); - - List responses = receiveN(2, TWO_SECONDS); - assertThat(responses, contains(instanceOf(AbortMessage.class), instanceOf(CompensateMessage.class))); - verify(task, never()).compensate(request); - - // no duplicate compensation - reset(task); - actorRef.tell(compensateMessage, getRef()); - actorRef.tell(compensateMessage, getRef()); - expectNoMessage(Duration.of(200, MILLIS)); - verify(task, never()).compensate(request); - }}; - } - - @Test - public void skipIfActorIsNotChosenByAnyParent() throws Exception { - when(childrenExtractor.fromJson(Operation.SUCCESSFUL_SAGA_RESPONSE.body())).thenReturn(singleton("none")); - - new TestKit(actorSystem) {{ - addChildren(getRef()); - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), getRef()); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, Matchers.containsInAnyOrder(SagaResponse.NONE_RESPONSE, SagaResponse.NONE_RESPONSE)); - verify(task, never()).commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE); - - // skip compensation for ignored actor - actorRef.tell(compensateMessage, getRef()); - actorRef.tell(compensateMessage, getRef()); - - expectMsg(TWO_SECONDS, compensateMessage); - verify(task, never()).compensate(request); - }}; - } - - @Test - public void transactIfChosenByAnyParent() throws Exception { - when(childrenExtractor.fromJson(Operation.SUCCESSFUL_SAGA_RESPONSE.body())).thenReturn(singleton(requestId)); - - new TestKit(actorSystem) {{ - addChildren(getRef()); - - ActorRef parent1 = someActor(); - context.addParent(requestId, parent1); - - ActorRef parent2 = someActor(); - context.addParent(requestId, parent2); - - when(request.parents()).thenReturn(new String[] {parentRequestId1, parentRequestId2}); - when(task.commit(eq(request), any(CompositeSagaResponse.class))).thenReturn(response); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), parent1); - actorRef.tell(new TransactMessage(request2, Operation.SUCCESSFUL_SAGA_RESPONSE), parent2); - - List responses = receiveN(2, TWO_SECONDS).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(response, response)); - }}; - } - - @Test - public void tellTransactionResponseToChildrenOnRecovery() throws Exception { - new TestKit(actorSystem) {{ - context.addChild(requestId, getRef()); - - ActorRef parent = someActor(); - context.addParent(requestId, parent); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactionRecoveryMessage(response), noSender()); - actorRef.tell(new TransactMessage(request1, Operation.SUCCESSFUL_SAGA_RESPONSE), parent); - - List responses = receiveN(1, TWO_SECONDS).stream() - .map(o -> ((TransactMessage) o).response()) - .collect(Collectors.toList()); - - assertThat(responses, containsInAnyOrder(response)); - - verify(task, never()).commit(request, Operation.SUCCESSFUL_SAGA_RESPONSE); - }}; - } - - @Test - public void tellCompensationToParentsOnRecovery() throws Exception { - new TestKit(actorSystem) {{ - context.addChild(requestId, someActor()); - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new AbortMessage(exception), someActor()); - actorRef.tell(new CompensationRecoveryMessage(), someActor()); - actorRef.tell(compensateMessage, someActor()); - - List responses = receiveN(2, TWO_SECONDS); - assertThat(responses, contains(instanceOf(AbortMessage.class), instanceOf(CompensateMessage.class))); - - verify(task, never()).compensate(request); - }}; - } - - @Test - public void abortOnPersistenceFailure() throws Exception { - new TestKit(actorSystem) {{ - context.addChild(requestId, noSender()); - context.addParent(requestId, getRef()); - - when(request.parents()).thenReturn(new String[] {parentRequestId1}); - - SagaStartFailedException oops = new SagaStartFailedException("oops", exception); - when(task.commit(request, SagaResponse.EMPTY_RESPONSE)).thenThrow(oops); - - ActorRef actorRef = actorSystem.actorOf(RequestActor.props(context, task, request)); - - actorRef.tell(new TransactMessage(request, SagaResponse.EMPTY_RESPONSE), getRef()); - - expectMsgClass(FailMessage.class); - }}; - } - - private ActorRef someActor() { - return actorSystem.actorOf(empty()); - } - - private void addChildren(ActorRef ref) { - context.addChild(requestId, ref); - context.addChild(requestId, ref); - context.addActor(requestId, ref); - } -} diff --git a/saga-core-akka/src/test/resources/application.conf b/saga-core-akka/src/test/resources/application.conf deleted file mode 100644 index 0629dd633..000000000 --- a/saga-core-akka/src/test/resources/application.conf +++ /dev/null @@ -1,21 +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. -## --------------------------------------------------------------------------- -akka { - loggers = ["akka.event.slf4j.Slf4jLogger"] - loglevel = "DEBUG" - logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" -} diff --git a/saga-core/pom.xml b/saga-core/pom.xml deleted file mode 100644 index e460b1a6b..000000000 --- a/saga-core/pom.xml +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - saga-core - Saga::Core - - - - com.lmax - disruptor - - - org.slf4j - slf4j-api - - - org.apache.logging.log4j - log4j-slf4j-impl - - - org.apache.logging.log4j - log4j-api - - - org.apache.logging.log4j - log4j-core - - - io.kamon - kamon-annotation_2.12 - - - - - junit - junit - - - org.hamcrest - hamcrest-all - - - org.mockito - mockito-core - - 1.10.19 - - - org.apache.commons - commons-lang3 - - - org.awaitility - awaitility - - - com.github.seanyinx - unit-scaffolding - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - UTF-8 - 1.7 - 1.7 - - - - - - diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/BackwardRecovery.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/BackwardRecovery.java deleted file mode 100644 index 799dbbf1c..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/BackwardRecovery.java +++ /dev/null @@ -1,54 +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.core; - -import java.lang.invoke.MethodHandles; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -@EnableKamon -public class BackwardRecovery implements RecoveryPolicy { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Segment(name = "backwardPolicy", category = "application", library = "kamon") - @Override - public SagaResponse apply(SagaTask task, SagaRequest request, SagaResponse parentResponse) { - try { - return request.transaction().send(request.serviceName(), parentResponse); - } catch (Exception e) { - log.error("Applying {} policy due to failure in transaction {} of service {}", - description(), - request.transaction(), - request.serviceName(), - e - ); - - task.abort(request, e); - throw e; - } - } - - @Override - public String description() { - return getClass().getSimpleName(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Compensation.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Compensation.java deleted file mode 100644 index 758ebd90e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Compensation.java +++ /dev/null @@ -1,55 +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.core; - -public interface Compensation extends Operation { - - Compensation SAGA_START_COMPENSATION = new Compensation() { - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - - @Override - public int retries() { - return DEFAULT_RETRIES; - } - }; - - Compensation SAGA_END_COMPENSATION = new Compensation() { - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - - @Override - public int retries() { - return DEFAULT_RETRIES; - } - }; -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompensationTaskConsumer.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompensationTaskConsumer.java deleted file mode 100644 index 736c34d0b..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompensationTaskConsumer.java +++ /dev/null @@ -1,69 +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.core; - -import java.lang.invoke.MethodHandles; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.apache.servicecomb.saga.core.dag.Node; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -class CompensationTaskConsumer implements TaskConsumer { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Map tasks; - private final SagaContext sagaContext; - - CompensationTaskConsumer(Map tasks, SagaContext sagaContext) { - this.tasks = tasks; - this.sagaContext = sagaContext; - } - - @Override - public void consume(Collection> nodes) { - for (Node node : nodes) { - SagaRequest request = node.value(); - - if (sagaContext.isTransactionCompleted(request)) { - log.info("Starting request {} id={}", request.serviceName(), request.id()); - tasks.get(request.task()).compensate(request); - log.info("Completed request {} id={}", request.serviceName(), request.id()); - } - } - } - - @Override - public boolean replay(Collection> nodes) { - - for (Iterator> iterator = nodes.iterator(); iterator.hasNext(); ) { - SagaRequest request = iterator.next().value(); - if (sagaContext.isCompensationCompleted(request)) { - log.info("Skipped completed compensation id={} operation={} while replay", request.id(), request.transaction()); - iterator.remove(); - } else if (!sagaContext.isTransactionCompleted(request)) { - // this transaction never started - log.info("Skipped pending transaction id={} operation={} while replay", request.id(), request.transaction()); - iterator.remove(); - } - } - return !nodes.isEmpty(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaLog.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaLog.java deleted file mode 100644 index 017129aa2..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaLog.java +++ /dev/null @@ -1,40 +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.core; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -class CompositeSagaLog implements SagaLog { - - private final SagaLog embedded; - private final PersistentLog persistent; - - CompositeSagaLog(SagaLog embedded, PersistentLog persistent) { - this.embedded = embedded; - this.persistent = persistent; - } - - @Segment(name = "compositeSagaLog", category = "application", library = "kamon") - @Override - public void offer(SagaEvent sagaEvent) { - persistent.offer(sagaEvent); - embedded.offer(sagaEvent); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaResponse.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaResponse.java deleted file mode 100644 index 84753b99f..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/CompositeSagaResponse.java +++ /dev/null @@ -1,63 +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.core; - -import java.util.Collection; - -public class CompositeSagaResponse implements SagaResponse { - private final Collection responses; - - public CompositeSagaResponse(Collection responses) { - this.responses = responses; - } - - @Override - public boolean succeeded() { - if (responses.size() > 0) { - boolean result = true; - for (SagaResponse response : responses) { - result = result && response.succeeded(); - } - return result; - } else { - return false; - } - } - - @Override - public String body() { - StringBuffer result = new StringBuffer(); - if (responses.size() == 0) { - result.append("{}"); - } else { - result.append("["); - for (SagaResponse response : responses) { - result.append(response.body()); - result.append(", "); - } - result.delete(result.length()-2, result.length()); - result.append("]"); - } - return result.toString(); - } - - - public Collection responses() { - return responses; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Descriptive.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Descriptive.java deleted file mode 100644 index e8b4f4eb6..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Descriptive.java +++ /dev/null @@ -1,23 +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.core; - -interface Descriptive { - - String description(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventContext.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventContext.java deleted file mode 100644 index 79b0c3e47..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventContext.java +++ /dev/null @@ -1,28 +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.core; - -public interface EventContext { - void beginTransaction(SagaRequest request); - - void endTransaction(SagaRequest request, SagaResponse response); - - void abortTransaction(SagaRequest request, SagaResponse response); - - void compensateTransaction(SagaRequest request, SagaResponse response); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventEnvelope.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventEnvelope.java deleted file mode 100644 index 9283b33e0..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventEnvelope.java +++ /dev/null @@ -1,47 +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.core; - -public class EventEnvelope { - - public final long id; - public final long timestamp; - public final SagaEvent event; - - public EventEnvelope(long id, SagaEvent event) { - this.id = id; - this.event = event; - this.timestamp = System.currentTimeMillis(); - } - - // TODO: 8/21/2017 this class seems to be useless to saga - public EventEnvelope(long id, long timestamp, SagaEvent event) { - this.id = id; - this.timestamp = timestamp; - this.event = event; - } - - @Override - public String toString() { - return "EventEnvelope{" + - "id=" + id + - ", timestamp=" + timestamp + - ", event={" + event + - "}}"; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventStore.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventStore.java deleted file mode 100644 index 7b7e6e24a..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/EventStore.java +++ /dev/null @@ -1,25 +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.core; - -public interface EventStore extends SagaLog, Iterable { - - void populate(Iterable events); - - long size(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/FailedSagaResponse.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/FailedSagaResponse.java deleted file mode 100644 index 15d1701d0..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/FailedSagaResponse.java +++ /dev/null @@ -1,50 +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.core; - -import java.io.PrintWriter; -import java.io.StringWriter; - -public class FailedSagaResponse implements SagaResponse { - - private final String body; - - public FailedSagaResponse(String body) { - this.body = body; - } - - public FailedSagaResponse(Throwable e) { - this.body = stackTrace(e); - } - - @Override - public boolean succeeded() { - return false; - } - - @Override - public String body() { - return body; - } - - private String stackTrace(Throwable e) { - StringWriter writer = new StringWriter(); - e.printStackTrace(new PrintWriter(writer)); - return writer.toString(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Fallback.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Fallback.java deleted file mode 100644 index 7215a6b98..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Fallback.java +++ /dev/null @@ -1,45 +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.core; - -public interface Fallback extends Operation { - - Fallback NOP_FALLBACK = new Fallback() { - @Override - public String type() { - return TYPE_NOP; - } - - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - - @Override - public int retries() { - return 0; - } - }; - - String type(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/FallbackPolicy.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/FallbackPolicy.java deleted file mode 100644 index 48ad67dec..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/FallbackPolicy.java +++ /dev/null @@ -1,62 +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.core; - -import java.lang.invoke.MethodHandles; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class FallbackPolicy { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final int retryDelay; - - public FallbackPolicy(int retryDelay) { - this.retryDelay = retryDelay; - } - - public SagaResponse apply(String address, Compensation compensation, Fallback fallback) { - for (int i = 0; isRetryable(i, compensation) && !isInterrupted(); i++) { - try { - return compensation.send(address); - } catch (Exception e) { - log.error("Failed to send compensation to {}", address, e); - sleep(retryDelay); - } - } - - log.warn("Falling back after {} failures sending compensation to {}", compensation.retries(), address); - return fallback.send(address); - } - - private boolean isRetryable(int i, Compensation compensation) { - return compensation.retries() < 0 || i <= compensation.retries(); - } - - private boolean isInterrupted() { - return Thread.currentThread().isInterrupted(); - } - - private void sleep(int delay) { - try { - Thread.sleep(delay); - } catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/ForwardRecovery.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/ForwardRecovery.java deleted file mode 100644 index 8c10cc0af..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/ForwardRecovery.java +++ /dev/null @@ -1,67 +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.core; - -import java.lang.invoke.MethodHandles; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ForwardRecovery implements RecoveryPolicy { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Override - public SagaResponse apply(SagaTask task, SagaRequest request, SagaResponse parentResponse) { - try { - for(int i = 0; isRetryable(i, request.transaction()); i++) { - try { - return request.transaction().send(request.serviceName(), parentResponse); - } catch (Exception e) { - log.error("Applying {} policy due to failure in transaction {} of service {}", - description(), - request.transaction(), - request.serviceName(), - e - ); - Thread.sleep(request.failRetryDelayMilliseconds()); - } - } - } catch (InterruptedException ignored) { - log.warn("Applying {} interrupted in transaction {} of service {}", - description(), - request.transaction(), - request.serviceName(), - ignored); - throw new TransactionFailedException(ignored); - } - throw new TransactionAbortedException( - String.format( - "Too many failures in transaction %s of service %s, abort the transaction!", - request.transaction(), - request.serviceName())); - } - - private boolean isRetryable(int i, Transaction transaction) { - return transaction.retries() <= 0 || i <= transaction.retries(); - } - - @Override - public String description() { - return getClass().getSimpleName(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/GraphBasedSaga.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/GraphBasedSaga.java deleted file mode 100644 index d57dbe9fd..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/GraphBasedSaga.java +++ /dev/null @@ -1,139 +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.core; - -import java.lang.invoke.MethodHandles; -import java.util.Map; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorCompletionService; -import java.util.concurrent.Executors; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.apache.servicecomb.saga.core.dag.ByLevelTraveller; -import org.apache.servicecomb.saga.core.dag.FromLeafTraversalDirection; -import org.apache.servicecomb.saga.core.dag.FromRootTraversalDirection; -import org.apache.servicecomb.saga.core.dag.SingleLeafDirectedAcyclicGraph; -import org.apache.servicecomb.saga.core.dag.TraversalDirection; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class GraphBasedSaga implements Saga { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final EventStore eventStore; - private final Map tasks; - - private final TaskRunner transactionTaskRunner; - private final TaskRunner compensationTaskRunner; - private final SagaContext sagaContext; - private volatile SagaState currentTaskRunner; - - GraphBasedSaga(EventStore eventStore, - Map tasks, - SagaContext sagaContext, - SingleLeafDirectedAcyclicGraph sagaTaskGraph) { - - this(eventStore, Executors.newFixedThreadPool(5), tasks, sagaContext, sagaTaskGraph); - } - - public GraphBasedSaga(EventStore eventStore, - Executor executor, - Map tasks, - SagaContext sagaContext, - SingleLeafDirectedAcyclicGraph sagaTaskGraph) { - - this.eventStore = eventStore; - this.tasks = tasks; - - this.transactionTaskRunner = new TaskRunner( - traveller(sagaTaskGraph, new FromRootTraversalDirection()), - new TransactionTaskConsumer( - tasks, - sagaContext, - new ExecutorCompletionService(executor))); - - this.sagaContext = sagaContext; - this.compensationTaskRunner = new TaskRunner( - traveller(sagaTaskGraph, new FromLeafTraversalDirection()), - new CompensationTaskConsumer(tasks, sagaContext)); - - currentTaskRunner = transactionTaskRunner; - } - - @Override - @Segment(name = "runSaga", category = "application", library = "kamon") - public SagaResponse run() { - SagaResponse response = SagaResponse.EMPTY_RESPONSE; - log.info("Starting Saga"); - do { - try { - currentTaskRunner.run(); - } catch (TransactionFailedException e) { - response = new FailedSagaResponse(e); - log.error("Failed to run operation", e); - currentTaskRunner = compensationTaskRunner; - - sagaContext.handleHangingTransactions(new TransactionConsumer() { - @Override - public void accept(SagaRequest request) { - tasks.get(request.task()).commit(request, sagaContext.responseOf(request.parents())); - tasks.get(request.task()).compensate(request); - } - }); - } catch (TransactionAbortedException e) { - response = new FailedSagaResponse(e); - log.error("Transaction aborted ", e); - break; - } - } while (currentTaskRunner.hasNext()); - log.info("Completed Saga"); - return response; - } - - @Override - public void play() { - log.info("Start playing events"); - gatherEvents(eventStore); - - transactionTaskRunner.replay(); - - if (sagaContext.isCompensationStarted()) { - currentTaskRunner = compensationTaskRunner; - compensationTaskRunner.replay(); - } - - log.info("Completed playing events"); - } - - private void gatherEvents(Iterable events) { - for (SagaEvent event : events) { - event.gatherTo(sagaContext); - } - } - - private ByLevelTraveller traveller( - SingleLeafDirectedAcyclicGraph sagaTaskGraph, - TraversalDirection traversalDirection) { - - return new ByLevelTraveller<>(sagaTaskGraph, traversalDirection); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/IdGenerator.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/IdGenerator.java deleted file mode 100644 index 2add2603d..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/IdGenerator.java +++ /dev/null @@ -1,25 +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.core; - -import java.io.Serializable; - -public interface IdGenerator { - - T nextId(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/LoggingRecoveryPolicy.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/LoggingRecoveryPolicy.java deleted file mode 100644 index 593aa91ff..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/LoggingRecoveryPolicy.java +++ /dev/null @@ -1,51 +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.core; - -import java.lang.invoke.MethodHandles; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -@EnableKamon -public class LoggingRecoveryPolicy implements RecoveryPolicy { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final RecoveryPolicy recoveryPolicy; - - public LoggingRecoveryPolicy(RecoveryPolicy recoveryPolicy) { - this.recoveryPolicy = recoveryPolicy; - } - - @Segment(name = "loggingPolicy", category = "application", library = "kamon") - @Override - public SagaResponse apply(SagaTask task, SagaRequest request, SagaResponse parentResponse) { - log.info("Starting request id={} for service {}", request.id(), request.serviceName()); - SagaResponse response = recoveryPolicy.apply(task, request, parentResponse); - log.info("Completed request id={} for service {}", request.id(), request.serviceName()); - return response; - } - - @Override - public String description() { - return getClass().getSimpleName(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/LongIdGenerator.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/LongIdGenerator.java deleted file mode 100644 index 6b16075b9..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/LongIdGenerator.java +++ /dev/null @@ -1,30 +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.core; - -import java.util.concurrent.atomic.AtomicLong; - -public class LongIdGenerator implements IdGenerator { - - private final AtomicLong atomicLong = new AtomicLong(); - - @Override - public Long nextId() { - return atomicLong.incrementAndGet(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/NoOpSagaRequest.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/NoOpSagaRequest.java deleted file mode 100644 index 93bbda99e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/NoOpSagaRequest.java +++ /dev/null @@ -1,113 +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.core; - -import static org.apache.servicecomb.saga.core.Compensation.SAGA_END_COMPENSATION; -import static org.apache.servicecomb.saga.core.Compensation.SAGA_START_COMPENSATION; -import static org.apache.servicecomb.saga.core.Fallback.NOP_FALLBACK; -import static org.apache.servicecomb.saga.core.Operation.TYPE_NOP; -import static org.apache.servicecomb.saga.core.SagaTask.SAGA_END_TASK; -import static org.apache.servicecomb.saga.core.SagaTask.SAGA_START_TASK; -import static org.apache.servicecomb.saga.core.Transaction.SAGA_END_TRANSACTION; -import static org.apache.servicecomb.saga.core.Transaction.SAGA_START_TRANSACTION; - -import java.util.Arrays; - -public class NoOpSagaRequest implements SagaRequest { - - public static final SagaRequest SAGA_START_REQUEST = new NoOpSagaRequest( - "saga-start", - SAGA_START_TRANSACTION, - SAGA_START_COMPENSATION, - SAGA_START_TASK); - - public static final SagaRequest SAGA_END_REQUEST = new NoOpSagaRequest( - "saga-end", - SAGA_END_TRANSACTION, - SAGA_END_COMPENSATION, - SAGA_END_TASK); - - private final String id; - private final Transaction transaction; - private final Compensation compensation; - private final String task; - private final String[] parents = {}; - - private NoOpSagaRequest(String id, Transaction transaction, Compensation compensation, String task) { - this.id = id; - this.transaction = transaction; - this.compensation = compensation; - this.task = task; - } - - @Override - public Transaction transaction() { - return transaction; - } - - @Override - public Compensation compensation() { - return compensation; - } - - @Override - public Fallback fallback() { - return NOP_FALLBACK; - } - - @Override - public String serviceName() { - return "Saga"; - } - - @Override - public String id() { - return id; - } - - @Override - public String type() { - return TYPE_NOP; - } - - @Override - public String task() { - return task; - } - - @Override - public String[] parents() { - return parents; - } - - @Override - public int failRetryDelayMilliseconds() { - return 50; - } - - @Override - public String toString() { - return "NoOpSagaRequest{" + - "id='" + id + '\'' + - ", transaction=" + transaction + - ", compensation=" + compensation + - ", task='" + task + '\'' + - ", parents=" + Arrays.toString(parents) + - '}'; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Operation.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Operation.java deleted file mode 100644 index c693dd270..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Operation.java +++ /dev/null @@ -1,33 +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.core; - -public interface Operation { - - int DEFAULT_RETRIES = 3; - String TYPE_NOP = "NOP"; - String TYPE_REST = "rest"; - String TYPE_SQL = "sql"; - SagaResponse SUCCESSFUL_SAGA_RESPONSE = new SuccessfulSagaResponse("success"); - - SagaResponse send(String address); - - SagaResponse send(String address, SagaResponse response); - - int retries(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentLog.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentLog.java deleted file mode 100644 index 26ec4bcb8..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentLog.java +++ /dev/null @@ -1,22 +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.core; - -public interface PersistentLog { - void offer(SagaEvent sagaEvent); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentStore.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentStore.java deleted file mode 100644 index a7620b3cf..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/PersistentStore.java +++ /dev/null @@ -1,26 +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.core; - -import java.util.List; -import java.util.Map; - -public interface PersistentStore extends PersistentLog { - - Map> findPendingSagaEvents(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RecoveryPolicy.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/RecoveryPolicy.java deleted file mode 100644 index c67d64044..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RecoveryPolicy.java +++ /dev/null @@ -1,26 +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.core; - -public interface RecoveryPolicy extends Descriptive { - - String SAGA_FORWARD_RECOVERY_POLICY = "ForwardRecovery"; - String SAGA_BACKWARD_RECOVERY_POLICY = "BackwardRecovery"; - - SagaResponse apply(SagaTask task, SagaRequest request, SagaResponse parentResponse); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RequestProcessTask.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/RequestProcessTask.java deleted file mode 100644 index e19c7bf41..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RequestProcessTask.java +++ /dev/null @@ -1,67 +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.core; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class RequestProcessTask implements SagaTask { - - private final String sagaId; - private final SagaLog sagaLog; - private final RecoveryPolicy recoveryPolicy; - private final FallbackPolicy fallbackPolicy; - - public RequestProcessTask( - String sagaId, - SagaLog sagaLog, - RecoveryPolicy recoveryPolicy, - FallbackPolicy fallbackPolicy) { - - this.sagaId = sagaId; - this.sagaLog = sagaLog; - this.recoveryPolicy = recoveryPolicy; - this.fallbackPolicy = fallbackPolicy; - } - - @Segment(name = "commit", category = "application", library = "kamon") - @Override - public SagaResponse commit(SagaRequest request, SagaResponse parentResponse) { - sagaLog.offer(new TransactionStartedEvent(sagaId, request)); - - SagaResponse response = recoveryPolicy.apply(this, request, parentResponse); - - sagaLog.offer(new TransactionEndedEvent(sagaId, request, response)); - return response; - } - - @Segment(name = "compensate", category = "application", library = "kamon") - @Override - public void compensate(SagaRequest request) { - Compensation compensation = request.compensation(); - SagaResponse response = fallbackPolicy.apply(request.serviceName(), compensation, request.fallback()); - - sagaLog.offer(new TransactionCompensatedEvent(sagaId, request, response)); - } - - @Override - public void abort(SagaRequest request, Exception e) { - sagaLog.offer(new TransactionAbortedEvent(sagaId, request, e)); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RestOperation.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/RestOperation.java deleted file mode 100644 index d961b2ef4..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/RestOperation.java +++ /dev/null @@ -1,78 +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.core; - -import org.apache.servicecomb.saga.core.application.interpreter.RestRequestChecker; -import java.util.Map; - -public class RestOperation implements Operation { - - private final String path; - private final String method; - private final int retries; - private final Map> params; - - public RestOperation(String path, String method, Map> params) { - this(path, method, DEFAULT_RETRIES, params); - } - - public RestOperation(String path, String method, int retries, Map> params) { - RestRequestChecker.checkParameters(method, params); - - this.path = path; - this.method = method; - this.retries = retries; - this.params = params == null? java.util.Collections.>emptyMap() : params; - } - - public String path() { - return path; - } - - public String method() { - return method; - } - - public Map> params() { - return params; - } - - @Override - public String toString() { - return "Operation{" + - "path='" + path + '\'' + - ", method='" + method + '\'' + - ", params=" + params + - '}'; - } - - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - - @Override - public int retries() { - return this.retries; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SQLOperation.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SQLOperation.java deleted file mode 100644 index 5e1ad831f..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SQLOperation.java +++ /dev/null @@ -1,65 +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.core; - -import java.util.Collections; -import java.util.List; - -public class SQLOperation implements Operation { - - private final String sql; - private final int retries; - private final List> params; - - public SQLOperation(String sql, int retries, List> params) { - this.sql = sql; - this.retries = retries; - this.params = params == null ? Collections.>emptyList() : params; - } - - public String sql() { - return sql; - } - - public List> params() { - return params; - } - - @Override - public String toString() { - return "SQLOperation{" + - "sql='" + sql + '\'' + - ", params=" + params + - '}'; - } - - @Override - public SagaResponse send(String datasource) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String datasource, SagaResponse response) { - return send(datasource); - } - - @Override - public int retries() { - return this.retries; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Saga.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Saga.java deleted file mode 100644 index 44f62ea55..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Saga.java +++ /dev/null @@ -1,27 +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.core; - -import kamon.annotation.Segment; - -public interface Saga { - @Segment(name = "runSaga", category = "application", library = "kamon") - SagaResponse run(); - - void play(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContext.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContext.java deleted file mode 100644 index 2f7603126..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContext.java +++ /dev/null @@ -1,34 +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.core; - -public interface SagaContext extends EventContext { - boolean isCompensationStarted(); - - boolean isTransactionCompleted(SagaRequest request); - - boolean isCompensationCompleted(SagaRequest request); - - void handleHangingTransactions(TransactionConsumer consumer); - - SagaResponse responseOf(String requestId); - - boolean isChosenChild(SagaRequest request); - - SagaResponse responseOf(String[] parentRequestIds); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContextImpl.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContextImpl.java deleted file mode 100644 index bc4253c8e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaContextImpl.java +++ /dev/null @@ -1,144 +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.core; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentSkipListSet; - - -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; - -public class SagaContextImpl implements SagaContext { - - private final Map completedTransactions; - private final Map completedCompensations; - private final Set abortedTransactions; - private final Map hangingTransactions; - private final FromJsonFormat> childrenExtractor; - - public SagaContextImpl(FromJsonFormat> childrenExtractor) { - this.childrenExtractor = childrenExtractor; - this.completedTransactions = new ConcurrentHashMap<>(); - this.completedCompensations = new HashMap<>(); - this.abortedTransactions = new ConcurrentSkipListSet<>(); - this.hangingTransactions = new ConcurrentHashMap<>(); - } - - @Override - public boolean isCompensationStarted() { - return !abortedTransactions.isEmpty() || !completedCompensations.isEmpty(); - } - - @Override - public boolean isTransactionCompleted(SagaRequest request) { - return completedTransactions.containsKey(request.id()); - } - - @Override - public boolean isCompensationCompleted(SagaRequest request) { - return completedCompensations.containsKey(request.id()); - } - - @Override - public void beginTransaction(SagaRequest request) { - hangingTransactions.put(request.id(), request); - } - - @Override - public void endTransaction(SagaRequest request, SagaResponse response) { - completedTransactions.put(request.id(), response); - hangingTransactions.remove(request.id()); - } - - @Override - public void abortTransaction(SagaRequest request, SagaResponse response) { - completedTransactions.remove(request.id()); - abortedTransactions.add(request.id()); - hangingTransactions.remove(request.id()); - } - - @Override - public void compensateTransaction(SagaRequest request, SagaResponse response) { - completedCompensations.put(request.id(), response); - completedTransactions.remove(request.id()); - } - - @Override - public void handleHangingTransactions(TransactionConsumer consumer) { - for (Iterator iterator = hangingTransactions.values().iterator(); iterator.hasNext(); ) { - consumer.accept(iterator.next()); - } - } - - @Override - public SagaResponse responseOf(String requestId) { - SagaResponse response = completedTransactions.get(requestId); - if (response == null) { - response = SagaResponse.NONE_RESPONSE; - } - return response; - } - - private List responsesOf(String[] parentRequestIds) { - List result = new ArrayList<>(); - for(String parentRequestId: parentRequestIds) { - result.add(responseOf(parentRequestId)); - } - return result; - } - - @Override - public SagaResponse responseOf(String[] parentRequestIds) { - List responses = responsesOf(parentRequestIds); - - if (responses.isEmpty()) { - return SagaResponse.EMPTY_RESPONSE; - } - - if (responses.size() == 1) { - return responses.get(0); - } - - return new CompositeSagaResponse(responses); - } - - @Override - public boolean isChosenChild(SagaRequest request) { - Set chosenChildren = chosenChildrenOf(request.parents()); - return chosenChildren.isEmpty() || chosenChildren.contains(request.id()); - } - - private Set chosenChildrenOf(String[] parentRequestIds) { - Set result = new HashSet<>(); - for(String parentRequestId: parentRequestIds) { - SagaResponse response = responseOf(parentRequestId); - Set jsons = childrenExtractor.fromJson(response.body()); - for (String json : jsons) { - result.add(json); - } - } - return result; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaDefinition.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaDefinition.java deleted file mode 100644 index 406c8df58..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaDefinition.java +++ /dev/null @@ -1,25 +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.core; - -public interface SagaDefinition { - - RecoveryPolicy policy(); - - SagaRequest[] requests(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndTask.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndTask.java deleted file mode 100644 index 69daba7da..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndTask.java +++ /dev/null @@ -1,48 +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.core; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class SagaEndTask implements SagaTask { - - private final String sagaId; - private final SagaLog sagaLog; - - public SagaEndTask(String sagaId, SagaLog sagaLog) { - this.sagaId = sagaId; - this.sagaLog = sagaLog; - } - - @Segment(name = "endTaskCommit", category = "application", library = "kamon") - @Override - public SagaResponse commit(SagaRequest request, SagaResponse parentResponse) { - sagaLog.offer(new SagaEndedEvent(sagaId, request)); - return SagaResponse.EMPTY_RESPONSE; - } - - @Override - public void compensate(SagaRequest request) { - } - - @Override - public void abort(SagaRequest request, Exception e) { - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndedEvent.java deleted file mode 100644 index c6f4f9f07..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEndedEvent.java +++ /dev/null @@ -1,38 +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.core; - -public class SagaEndedEvent extends SagaEvent { - - public SagaEndedEvent(String sagaId, SagaRequest sagaTask) { - super(sagaId, sagaTask); - } - - @Override - public void gatherTo(EventContext sagaContext) { - sagaContext.endTransaction(payload(), SagaResponse.EMPTY_RESPONSE); - } - - @Override - public String toString() { - return "SagaEndedEvent{id=" - + payload().id() - + ", sagaId=" + sagaId - + "}"; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEvent.java deleted file mode 100644 index ffe31d037..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaEvent.java +++ /dev/null @@ -1,44 +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.core; - -public abstract class SagaEvent implements Descriptive { - - public final String sagaId; - private final SagaRequest payload; - - public SagaEvent(String sagaId, SagaRequest payload) { - this.sagaId = sagaId; - this.payload = payload; - } - - public SagaRequest payload() { - return payload; - } - - public abstract void gatherTo(EventContext sagaContext); - - public String json(ToJsonFormat toJsonFormat) { - return "{}"; - } - - @Override - public String description() { - return getClass().getSimpleName(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaException.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaException.java deleted file mode 100644 index 49ce9890f..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaException.java +++ /dev/null @@ -1,29 +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.core; - -public class SagaException extends RuntimeException { - - public SagaException(String cause, Throwable e) { - super(cause, e); - } - - public SagaException(String cause) { - super(cause); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaLog.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaLog.java deleted file mode 100644 index 2e07b9f64..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaLog.java +++ /dev/null @@ -1,22 +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.core; - -public interface SagaLog extends PersistentLog { - -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequest.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequest.java deleted file mode 100644 index 4578e4231..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequest.java +++ /dev/null @@ -1,44 +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.core; - -public interface SagaRequest { - - String PARAM_FORM = "form"; - String PARAM_JSON = "json"; - String PARAM_JSON_BODY = "body"; - String PARAM_QUERY = "query"; - - Transaction transaction(); - - Compensation compensation(); - - Fallback fallback(); - - String serviceName(); - - String id(); - - String type(); - - String task(); - - String[] parents(); - - int failRetryDelayMilliseconds(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequestImpl.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequestImpl.java deleted file mode 100644 index cbb7a230e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaRequestImpl.java +++ /dev/null @@ -1,153 +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.core; - -import static org.apache.servicecomb.saga.core.Fallback.NOP_FALLBACK; - -import java.util.Arrays; - -public class SagaRequestImpl implements SagaRequest { - - private final String id; - private final String serviceName; - private final String type; - private final Transaction transaction; - private final Compensation compensation; - private final String[] parents; - private final Fallback fallback; - private final int failRetryDelayMilliseconds; - - public SagaRequestImpl( - String id, - String serviceName, - String type, - Transaction transaction, - Compensation compensation, - Fallback fallback, - String[] parents, - int failRetryDelayMilliseconds) { - - this.id = id; - this.serviceName = serviceName; - this.type = type; - this.transaction = transaction; - this.compensation = compensation; - this.fallback = fallback; - this.failRetryDelayMilliseconds = failRetryDelayMilliseconds <= 0 ? 50 : failRetryDelayMilliseconds; - // TODO: 2017/10/21 set parent to root when null - this.parents = parents == null ? new String[0] : parents; - } - - public SagaRequestImpl( - String id, - String serviceName, - String type, - Transaction transaction, - Compensation compensation, - Fallback fallback, - String[] parents) { - this(id, serviceName, type, transaction, compensation, fallback, parents, 0); - } - - public SagaRequestImpl( - String id, - String serviceName, - String type, - Transaction transaction, - Compensation compensation, - Fallback fallback) { - this(id, serviceName, type, transaction, compensation, fallback, new String[0]); - } - - public SagaRequestImpl( - String id, - String serviceName, - String type, - Transaction transaction, - Compensation compensation) { - this(id, serviceName, type, transaction, compensation, NOP_FALLBACK, new String[0]); - } - - public SagaRequestImpl( - String id, - String serviceName, - String type, - Transaction transaction, - Compensation compensation, - String[] parents) { - this(id, serviceName, type, transaction, compensation, NOP_FALLBACK, parents); - } - - @Override - public Transaction transaction() { - return transaction; - } - - @Override - public Compensation compensation() { - return compensation; - } - - @Override - public Fallback fallback() { - return fallback; - } - - @Override - public String serviceName() { - return serviceName; - } - - @Override - public String id() { - return id; - } - - @Override - public String type() { - return type; - } - - @Override - public String task() { - return SagaTask.SAGA_REQUEST_TASK; - } - - @Override - public String[] parents() { - return parents; - } - - @Override - public int failRetryDelayMilliseconds() { - return failRetryDelayMilliseconds; - } - - @Override - public String toString() { - return "SagaRequest{" + - "id='" + id + '\'' + - ", serviceName='" + serviceName + '\'' + - ", type='" + type + '\'' + - ", transaction=" + transaction + - ", compensation=" + compensation + - ", fallback=" + fallback + - ", parents=" + Arrays.toString(parents) + - '}'; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaResponse.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaResponse.java deleted file mode 100644 index ecdfe4a03..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaResponse.java +++ /dev/null @@ -1,61 +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.core; - -public interface SagaResponse { - - SagaResponse EMPTY_RESPONSE = new SagaResponse() { - @Override - public boolean succeeded() { - return true; - } - - @Override - public String body() { - return "{}"; - } - - @Override - public String toString() { - return "EMPTY_RESPONSE{body={}}"; - } - }; - - SagaResponse NONE_RESPONSE = new SagaResponse() { - @Override - public boolean succeeded() { - return false; - } - - @Override - public String body() { - return "{\n" - + " \"sagaChildren\": [\"none\"]\n" - + "}"; - } - - @Override - public String toString() { - return "NONE_RESPONSE{body={\"sagaChildren\": [\"none\"]\n}}"; - } - }; - - boolean succeeded(); - - String body(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartFailedException.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartFailedException.java deleted file mode 100644 index 0de35da0e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartFailedException.java +++ /dev/null @@ -1,25 +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.core; - -public class SagaStartFailedException extends RuntimeException { - - public SagaStartFailedException(String cause, Throwable e) { - super(cause, e); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartTask.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartTask.java deleted file mode 100644 index d8a6bd122..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartTask.java +++ /dev/null @@ -1,56 +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.core; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class SagaStartTask implements SagaTask { - - private final String sagaId; - private final String requestJson; - private final SagaLog sagaLog; - - public SagaStartTask(String sagaId, String requestJson, SagaLog sagaLog) { - this.sagaId = sagaId; - this.requestJson = requestJson; - this.sagaLog = sagaLog; - } - - @Segment(name = "startTaskCommit", category = "application", library = "kamon") - @Override - public SagaResponse commit(SagaRequest request, SagaResponse parentResponse) { - try { - sagaLog.offer(new SagaStartedEvent(sagaId, requestJson, request)); - } catch (Exception e) { - throw new SagaStartFailedException("Failed to persist SagaStartedEvent for " + requestJson, e); - } - return SagaResponse.EMPTY_RESPONSE; - } - - @Override - public void compensate(SagaRequest request) { - sagaLog.offer(new SagaEndedEvent(sagaId, request)); - } - - @Override - public void abort(SagaRequest request, Exception e) { - - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartedEvent.java deleted file mode 100644 index 0d82feed7..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaStartedEvent.java +++ /dev/null @@ -1,46 +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.core; - -public class SagaStartedEvent extends SagaEvent { - - private final String requestJson; - - public SagaStartedEvent(String sagaId, String requestJson, SagaRequest request) { - super(sagaId, request); - this.requestJson = requestJson; - } - - @Override - public void gatherTo(EventContext sagaContext) { - sagaContext.endTransaction(payload(), SagaResponse.EMPTY_RESPONSE); - } - - @Override - public String json(ToJsonFormat toJsonFormat) { - return requestJson; - } - - @Override - public String toString() { - return "SagaStartedEvent{id=" - + payload().id() - + ", sagaId=" + sagaId - + "}"; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaState.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaState.java deleted file mode 100644 index eae3678e3..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaState.java +++ /dev/null @@ -1,27 +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.core; - -interface SagaState { - - boolean hasNext(); - - void run(); - - void replay(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTask.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTask.java deleted file mode 100644 index 73efcc0ce..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTask.java +++ /dev/null @@ -1,31 +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.core; - -public interface SagaTask { - - String SAGA_START_TASK = "SagaStart"; - String SAGA_REQUEST_TASK = "SagaRequest"; - String SAGA_END_TASK = "SagaEnd"; - - SagaResponse commit(SagaRequest request, SagaResponse parentResponse); - - void compensate(SagaRequest request); - - void abort(SagaRequest request, Exception e); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTaskFactory.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTaskFactory.java deleted file mode 100644 index b6d9585b2..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SagaTaskFactory.java +++ /dev/null @@ -1,98 +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.core; - -import java.lang.invoke.MethodHandles; -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class SagaTaskFactory { - private final FallbackPolicy fallbackPolicy; - private final RetrySagaLog retrySagaLog; - private final PersistentStore persistentStore; - - public SagaTaskFactory(int retryDelay, PersistentStore persistentStore) { - this.persistentStore = persistentStore; - - fallbackPolicy = new FallbackPolicy(retryDelay); - retrySagaLog = new RetrySagaLog(persistentStore, retryDelay); - } - - public Map sagaTasks(final String sagaId, - final String requestJson, - final RecoveryPolicy recoveryPolicy, - final EventStore sagaLog) { - - final SagaLog compositeSagaLog = compositeSagaLog(sagaLog, persistentStore); - - return new HashMap() {{ - put(SagaTask.SAGA_START_TASK, new SagaStartTask(sagaId, requestJson, compositeSagaLog)); - - SagaLog retrySagaLog = compositeSagaLog(sagaLog, SagaTaskFactory.this.retrySagaLog); - put(SagaTask.SAGA_REQUEST_TASK, - new RequestProcessTask(sagaId, retrySagaLog, new LoggingRecoveryPolicy(recoveryPolicy), fallbackPolicy)); - put(SagaTask.SAGA_END_TASK, new SagaEndTask(sagaId, retrySagaLog)); - }}; - } - - private CompositeSagaLog compositeSagaLog(SagaLog sagaLog, PersistentLog persistentLog) { - return new CompositeSagaLog(sagaLog, persistentLog); - } - - static class RetrySagaLog implements PersistentLog { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final PersistentStore persistentStore; - private final int retryDelay; - - RetrySagaLog(PersistentStore persistentStore, int retryDelay) { - this.persistentStore = persistentStore; - this.retryDelay = retryDelay; - } - - @Override - public void offer(SagaEvent sagaEvent) { - boolean success = false; - do { - try { - persistentStore.offer(sagaEvent); - success = true; - log.info("Persisted saga event {} successfully", sagaEvent); - } catch (Exception e) { - log.error("Failed to persist saga event {}", sagaEvent, e); - sleep(retryDelay); - } - } while (!success && !isInterrupted()); - } - - private boolean isInterrupted() { - return Thread.currentThread().isInterrupted(); - } - - private void sleep(int delay) { - try { - Thread.sleep(delay); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaResponse.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaResponse.java deleted file mode 100644 index d69bdcd08..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaResponse.java +++ /dev/null @@ -1,43 +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.core; - -public class SuccessfulSagaResponse implements SagaResponse { - private final String body; - - public SuccessfulSagaResponse(String body) { - this.body = body; - } - - @Override - public boolean succeeded() { - return true; - } - - @Override - public String body() { - return body; - } - - @Override - public String toString() { - return "SuccessfulSagaResponse{" + - "body='" + body + '\'' + - '}'; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskConsumer.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskConsumer.java deleted file mode 100644 index 5ae749462..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskConsumer.java +++ /dev/null @@ -1,29 +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.core; - -import java.util.Collection; - -import org.apache.servicecomb.saga.core.dag.Node; - -interface TaskConsumer { - - void consume(Collection> nodes); - - boolean replay(Collection> nodes); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskRunner.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskRunner.java deleted file mode 100644 index c07800180..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TaskRunner.java +++ /dev/null @@ -1,72 +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.core; - -import org.apache.servicecomb.saga.core.dag.Node; -import org.apache.servicecomb.saga.core.dag.Traveller; - -import java.util.Collection; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -class TaskRunner implements SagaState { - - private final Traveller traveller; - private final TaskConsumer taskConsumer; - - TaskRunner(Traveller traveller, TaskConsumer taskConsumer) { - this.traveller = traveller; - this.taskConsumer = taskConsumer; - } - - @Override - public boolean hasNext() { - return traveller.hasNext(); - } - - @Segment(name = "runTask", category = "application", library = "kamon") - @Override - public void run() { - Collection> nodes = traveller.nodes(); - - // finish pending tasks from saga log at startup - if (!nodes.isEmpty()) { - taskConsumer.consume(nodes); - nodes.clear(); - } - - while (traveller.hasNext()) { - traveller.next(); - taskConsumer.consume(nodes); - nodes.clear(); - } - } - - @Override - public void replay() { - boolean played = false; - Collection> nodes = traveller.nodes(); - - while (traveller.hasNext() && !played) { - traveller.next(); - played = taskConsumer.replay(nodes); - } - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/ToJsonFormat.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/ToJsonFormat.java deleted file mode 100644 index cd6c44953..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/ToJsonFormat.java +++ /dev/null @@ -1,26 +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.core; - -public interface ToJsonFormat { - - String toJson(SagaRequest request); - - String toJson(SagaRequest request, SagaResponse response); - -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transaction.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transaction.java deleted file mode 100644 index a6d4c5489..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transaction.java +++ /dev/null @@ -1,57 +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.core; - -public interface Transaction extends Operation { - - Transaction SAGA_START_TRANSACTION = new Transaction() { - @Override - public int retries() { - return INFINITE_RETRY; - } - - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - }; - - Transaction SAGA_END_TRANSACTION = new Transaction() { - @Override - public int retries() { - return INFINITE_RETRY; - } - - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - }; - - int INFINITE_RETRY = -1; -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedEvent.java deleted file mode 100644 index b117c94b3..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedEvent.java +++ /dev/null @@ -1,57 +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.core; - -public class TransactionAbortedEvent extends SagaEvent { - - private final SagaResponse response; - - public TransactionAbortedEvent(String sagaId, SagaRequest payload, Exception exception) { - super(sagaId, payload); - this.response = new FailedSagaResponse(exception); - } - - public TransactionAbortedEvent(String sagaId, SagaRequest payload, SagaResponse response) { - super(sagaId, payload); - this.response = response; - } - - @Override - public void gatherTo(EventContext sagaContext) { - // remove from completed operations in order not to compensate it - sagaContext.abortTransaction(payload(), response); - } - - @Override - public String json(ToJsonFormat toJsonFormat) { - return toJsonFormat.toJson(payload(), response); - } - - @Override - public String toString() { - return "TransactionAbortedEvent{id=" - + payload().id() - + ", operation=" - + payload().compensation() - + "}"; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedException.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedException.java deleted file mode 100644 index 02cbf984a..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionAbortedException.java +++ /dev/null @@ -1,28 +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.core; - -public class TransactionAbortedException extends RuntimeException{ - public TransactionAbortedException(Throwable throwable) { - super(throwable); - } - - public TransactionAbortedException(String cause) { - super(cause); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionCompensatedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionCompensatedEvent.java deleted file mode 100644 index d6ab2984a..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionCompensatedEvent.java +++ /dev/null @@ -1,56 +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.core; - -public class TransactionCompensatedEvent extends SagaEvent { - - private final SagaResponse response; - - public TransactionCompensatedEvent(String sagaId, SagaRequest request) { - this(sagaId, request, SagaResponse.EMPTY_RESPONSE); - } - - public TransactionCompensatedEvent(String sagaId, SagaRequest request, SagaResponse response) { - super(sagaId, request); - this.response = response; - } - - @Override - public void gatherTo(EventContext sagaContext) { - sagaContext.compensateTransaction(payload(), response); - } - - @Override - public String json(ToJsonFormat toJsonFormat) { - return toJsonFormat.toJson(payload(), response); - } - - @Override - public String toString() { - return "TransactionCompensatedEvent{id=" - + payload().id() - + ", sagaId=" + sagaId - + ", operation=" - + payload().compensation() - + "}"; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionConsumer.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionConsumer.java deleted file mode 100644 index b5bb0984a..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionConsumer.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.apache.servicecomb.saga.core; - -public interface TransactionConsumer { - void accept(T request); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionEndedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionEndedEvent.java deleted file mode 100644 index 603c542ab..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionEndedEvent.java +++ /dev/null @@ -1,56 +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.core; - -public class TransactionEndedEvent extends SagaEvent { - - private final SagaResponse response; - - public TransactionEndedEvent(String sagaId, SagaRequest request) { - this(sagaId, request, SagaResponse.EMPTY_RESPONSE); - } - - public TransactionEndedEvent(String sagaId, SagaRequest request, SagaResponse response) { - super(sagaId, request); - this.response = response; - } - - @Override - public void gatherTo(EventContext sagaContext) { - sagaContext.endTransaction(payload(), response); - } - - @Override - public String toString() { - return "TransactionEndedEvent{id=" - + payload().id() - + ", sagaId=" + sagaId - + ", operation=" - + payload().transaction() - + "}"; - } - - @Override - public String json(ToJsonFormat toJsonFormat) { - return toJsonFormat.toJson(payload(), response); - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionFailedException.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionFailedException.java deleted file mode 100644 index b55e01a3d..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionFailedException.java +++ /dev/null @@ -1,29 +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.core; - -public class TransactionFailedException extends RuntimeException { - - public TransactionFailedException(Throwable throwable) { - super(throwable); - } - - public TransactionFailedException(String cause) { - super(cause); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionStartedEvent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionStartedEvent.java deleted file mode 100644 index cc3558938..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionStartedEvent.java +++ /dev/null @@ -1,45 +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.core; - -public class TransactionStartedEvent extends SagaEvent { - - public TransactionStartedEvent(String sagaId, SagaRequest transaction) { - super(sagaId, transaction); - } - - @Override - public void gatherTo(EventContext sagaContext) { - sagaContext.beginTransaction(payload()); - } - - @Override - public String toString() { - return "TransactionStartedEvent{id=" - + payload().id() - + ", sagaId=" + sagaId - + ", operation=" - + payload().transaction() - + "}"; - } - - @Override - public String json(ToJsonFormat toJsonFormat) { - return toJsonFormat.toJson(payload()); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionTaskConsumer.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionTaskConsumer.java deleted file mode 100644 index ac470a03e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransactionTaskConsumer.java +++ /dev/null @@ -1,126 +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.core; - -import org.apache.servicecomb.saga.core.dag.Node; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.CompletionService; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; -import kamon.annotation.Trace; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@EnableKamon -class TransactionTaskConsumer implements TaskConsumer { - - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Map tasks; - private final SagaContext sagaContext; - private final CompletionService executorService; - - TransactionTaskConsumer( - Map tasks, - SagaContext sagaContext, - CompletionService executorService) { - - this.tasks = tasks; - this.sagaContext = sagaContext; - this.executorService = executorService; - } - - @Segment(name = "consumeTask", category = "application", library = "kamon") - @Override - public void consume(Collection> nodes) { - List> futures = new ArrayList<>(nodes.size()); - for (Node node : nodes) { - SagaRequest request = node.value(); - if (sagaContext.isChosenChild(request)) { - futures.add(futureOf(request)); - } - } - - for (int i = 0; i < futures.size(); i++) { - try { - executorService.take().get(); - } catch (ExecutionException e) { - if (e.getCause() instanceof SagaStartFailedException) { - throw ((SagaStartFailedException) e.getCause()); - } - if (e.getCause() instanceof TransactionAbortedException) { - throw ((TransactionAbortedException) e.getCause()); - } - throw new TransactionFailedException(e.getCause()); - } catch (InterruptedException e) { - // TODO: 7/29/2017 what shall we do when system is shutting down? - throw new TransactionFailedException(e); - } - } - } - - @Override - public boolean replay(Collection> nodes) { - for (Iterator> iterator = nodes.iterator(); iterator.hasNext(); ) { - SagaRequest request = iterator.next().value(); - if (sagaContext.isTransactionCompleted(request)) { - log.info("Skipped completed transaction id={} operation={} while replay", request.id(), request.transaction()); - iterator.remove(); - } - } - return !nodes.isEmpty(); - } - - @Segment(name = "submitCallable", category = "application", library = "kamon") - private Future futureOf(SagaRequest request) { - return executorService.submit(new OperationCallable(tasks, request, sagaContext.responseOf(request.parents()))); - } - - @EnableKamon - private static class OperationCallable implements Callable { - - private final SagaRequest request; - private final Map tasks; - private final SagaResponse parentResponse; - - private OperationCallable( - Map tasks, - SagaRequest request, - SagaResponse parentResponse) { - this.request = request; - this.tasks = tasks; - this.parentResponse = parentResponse; - } - - @Trace("runTransactionCallable") - @Override - public Operation call() throws Exception { - tasks.get(request.task()).commit(request, parentResponse); - return request.transaction(); - } - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transport.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transport.java deleted file mode 100644 index 5679e0a4c..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/Transport.java +++ /dev/null @@ -1,22 +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.core; - -public interface Transport { - -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransportFailedException.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransportFailedException.java deleted file mode 100644 index e01a9d580..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/TransportFailedException.java +++ /dev/null @@ -1,28 +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.core; - -public class TransportFailedException extends RuntimeException { - public TransportFailedException(String cause) { - super(cause); - } - - public TransportFailedException(String cause, Throwable e) { - super(cause, e); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaExecutionComponent.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaExecutionComponent.java deleted file mode 100644 index 7a600d7e3..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaExecutionComponent.java +++ /dev/null @@ -1,87 +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.core.application; - -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - -import org.apache.servicecomb.saga.core.EventEnvelope; -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.Saga; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.ToJsonFormat; -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.infrastructure.EmbeddedEventStore; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class SagaExecutionComponent { - - private final PersistentStore persistentStore; - private final FromJsonFormat fromJsonFormat; - private final ToJsonFormat toJsonFormat; - private final SagaFactory sagaFactory; - - public SagaExecutionComponent( - PersistentStore persistentStore, - FromJsonFormat fromJsonFormat, - ToJsonFormat toJsonFormat, - SagaFactory sagaFactory) { - this.persistentStore = persistentStore; - this.fromJsonFormat = fromJsonFormat; - this.toJsonFormat = toJsonFormat; - this.sagaFactory = sagaFactory; - } - - @Segment(name = "runSagaExecutionComponent", category = "application", library = "kamon") - public SagaResponse run(String requestJson) { - String sagaId = UUID.randomUUID().toString(); - EventStore sagaLog = new EmbeddedEventStore(); - SagaDefinition definition = fromJsonFormat.fromJson(requestJson); - Saga saga = sagaFactory.createSaga(requestJson, sagaId, sagaLog, definition); - return saga.run(); - } - - public void reanimate() { - Map> pendingSagaEvents = persistentStore.findPendingSagaEvents(); - - for (Entry> entry : pendingSagaEvents.entrySet()) { - EventStore eventStore = new EmbeddedEventStore(); - eventStore.populate(entry.getValue()); - SagaEvent event = entry.getValue().iterator().next().event; - - String requestJson = event.json(toJsonFormat); - SagaDefinition definition = fromJsonFormat.fromJson(requestJson); - - Saga saga = sagaFactory.createSaga(requestJson, event.sagaId, eventStore, definition); - - saga.play(); - saga.run(); - } - } - - public void terminate() throws Exception { - sagaFactory.terminate(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaFactory.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaFactory.java deleted file mode 100644 index b60b5e741..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/SagaFactory.java +++ /dev/null @@ -1,30 +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.core.application; - -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.Saga; -import org.apache.servicecomb.saga.core.SagaDefinition; - -public interface SagaFactory { - Saga createSaga(String requestJson, String sagaId, EventStore sagaLog, SagaDefinition definition); - - boolean isTerminated(); - - void terminate() throws Exception; -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/FromJsonFormat.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/FromJsonFormat.java deleted file mode 100644 index ccfb40826..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/FromJsonFormat.java +++ /dev/null @@ -1,24 +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.core.application.interpreter; - -public interface FromJsonFormat { - - T fromJson(String requestJson); - -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/RestRequestChecker.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/RestRequestChecker.java deleted file mode 100644 index 7a65e48ce..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/application/interpreter/RestRequestChecker.java +++ /dev/null @@ -1,55 +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.core.application.interpreter; - -import static java.util.Arrays.asList; - -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -public class RestRequestChecker { - - private static final Set validMethods = new HashSet<>(asList( - "GET", - "POST", - "PUT", - "DELETE" - )); - - private RestRequestChecker() { - } - - public static void checkParameters(String method, Map> params) { - if (method == null || !validMethods.contains(method.toUpperCase())) { - throw new IllegalArgumentException("Unsupported method " + method); - } - - if (isDeleteOrGet(method) && hasBody(params)) { - throw new IllegalArgumentException("GET & DELETE request cannot enclose a body"); - } - } - - private static boolean isDeleteOrGet(String method) { - return "GET".equalsIgnoreCase(method) || "DELETE".equalsIgnoreCase(method); - } - - private static boolean hasBody(Map> params) { - return params != null && (params.containsKey("form") || params.containsKey("json")); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/ByLevelTraveller.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/ByLevelTraveller.java deleted file mode 100644 index 24891170b..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/ByLevelTraveller.java +++ /dev/null @@ -1,86 +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.core.dag; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.Queue; -import java.util.Set; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class ByLevelTraveller implements Traveller { - - private final Collection> nodes; - private final Collection> nodesBuffer; - - private final Queue> nodesWithoutParent = new LinkedList<>(); - private final Map>> nodeParents = new HashMap<>(); - private final TraversalDirection traversalDirection; - - - public ByLevelTraveller(SingleLeafDirectedAcyclicGraph dag, TraversalDirection traversalDirection) { - this.nodes = new LinkedHashSet<>(); - this.nodesBuffer = new LinkedList<>(); - this.traversalDirection = traversalDirection; - - nodesWithoutParent.offer(traversalDirection.root(dag)); - } - - @Segment(name = "travelNext", category = "application", library = "kamon") - @Override - public void next() { - nodes.addAll(nodesBuffer); - nodesBuffer.clear(); - boolean buffered = false; - - while (!nodesWithoutParent.isEmpty() && !buffered) { - Node node = nodesWithoutParent.poll(); - nodes.add(node); - - for (Node child : traversalDirection.children(node)) { - // This is not thread safe - if (nodeParents.get(child.id()) == null) { - nodeParents.put(child.id(), new HashSet<>(traversalDirection.parents(child))); - } - nodeParents.get(child.id()).remove(node); - - if (nodeParents.get(child.id()).isEmpty()) { - nodesWithoutParent.offer(child); - nodesBuffer.add(child); - buffered = true; - } - } - } - } - - @Override - public boolean hasNext() { - return !nodesWithoutParent.isEmpty(); - } - - @Override - public Collection> nodes() { - return nodes; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromLeafTraversalDirection.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromLeafTraversalDirection.java deleted file mode 100644 index d97c40fca..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromLeafTraversalDirection.java +++ /dev/null @@ -1,38 +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.core.dag; - -import java.util.Set; - -public class FromLeafTraversalDirection implements TraversalDirection { - - @Override - public Node root(SingleLeafDirectedAcyclicGraph dag) { - return dag.leaf(); - } - - @Override - public Set> parents(Node node) { - return node.children(); - } - - @Override - public Set> children(Node node) { - return node.parents(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromRootTraversalDirection.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromRootTraversalDirection.java deleted file mode 100644 index 8c664ac5d..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/FromRootTraversalDirection.java +++ /dev/null @@ -1,38 +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.core.dag; - -import java.util.Set; - -public class FromRootTraversalDirection implements TraversalDirection { - - @Override - public Node root(SingleLeafDirectedAcyclicGraph dag) { - return dag.root(); - } - - @Override - public Set> parents(Node node) { - return node.parents(); - } - - @Override - public Set> children(Node node) { - return node.children(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaFactory.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaFactory.java deleted file mode 100644 index 55c71c1e3..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaFactory.java +++ /dev/null @@ -1,81 +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.core.dag; - -import java.util.Set; -import java.util.concurrent.Executor; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.atomic.AtomicBoolean; - -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.GraphBasedSaga; -import org.apache.servicecomb.saga.core.Saga; -import org.apache.servicecomb.saga.core.SagaContext; -import org.apache.servicecomb.saga.core.SagaContextImpl; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.application.SagaFactory; -import org.apache.servicecomb.saga.infrastructure.ContextAwareEventStore; -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaTaskFactory; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; - -public class GraphBasedSagaFactory implements SagaFactory { - private final AtomicBoolean isRunning = new AtomicBoolean(true); - private final FromJsonFormat> childrenExtractor; - private final Executor executorService; - private final GraphBuilder graphBuilder; - private final SagaTaskFactory sagaTaskFactory; - - public GraphBasedSagaFactory(int retryDelay, - PersistentStore persistentStore, - FromJsonFormat> childrenExtractor, - ExecutorService executorService) { - - this.childrenExtractor = childrenExtractor; - this.executorService = executorService; - this.sagaTaskFactory = new SagaTaskFactory(retryDelay, persistentStore); - this.graphBuilder = new GraphBuilder(new GraphCycleDetectorImpl()); - } - - @Override - public Saga createSaga(String requestJson, String sagaId, EventStore sagaLog, SagaDefinition definition) { - SagaContext sagaContext = new SagaContextImpl(childrenExtractor); - - return new GraphBasedSaga( - sagaLog, - executorService, - sagaTaskFactory.sagaTasks(sagaId, - requestJson, - definition.policy(), - new ContextAwareEventStore(sagaLog, sagaContext) - ), - sagaContext, - graphBuilder.build(definition.requests())); - } - - @Override - public boolean isTerminated() { - return !isRunning.get(); - } - - @Override - public void terminate() throws Exception { - isRunning.compareAndSet(true, false); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBuilder.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBuilder.java deleted file mode 100644 index c5cd8502d..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphBuilder.java +++ /dev/null @@ -1,110 +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.core.dag; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; - -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.SagaRequest; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class GraphBuilder { - - private final GraphCycleDetector detector; - - public GraphBuilder(GraphCycleDetector detector) { - this.detector = detector; - } - - @Segment(name = "buildGraph", category = "application", library = "kamon") - public SingleLeafDirectedAcyclicGraph build(SagaRequest[] sagaRequests) { - Map> requestNodes = requestsToNodes(sagaRequests); - - SingleLeafDirectedAcyclicGraph graph = linkNodesToGraph(sagaRequests, requestNodes); - detectCycle(graph); - return graph; - } - - private SingleLeafDirectedAcyclicGraph linkNodesToGraph( - SagaRequest[] sagaRequests, - Map> requestNodes) { - - Node root = rootNode(0); - Node leaf = leafNode(sagaRequests.length + 1); - - for (SagaRequest sagaRequest : sagaRequests) { - if (isOrphan(sagaRequest)) { - root.addChild(requestNodes.get(sagaRequest.id())); - } else { - for (String parent : sagaRequest.parents()) { - requestNodes.get(parent).addChild(requestNodes.get(sagaRequest.id())); - } - } - } - - for(Node node : requestNodes.values()) { - if (node.children().isEmpty()) { - node.addChild(leaf); - } - } - return new SingleLeafDirectedAcyclicGraph<>(root, leaf); - } - - private Node rootNode(int id) { - return new Node<>( - id, - NoOpSagaRequest.SAGA_START_REQUEST); - } - - private Node leafNode(int id) { - return new Node<>( - id, - NoOpSagaRequest.SAGA_END_REQUEST); - } - - private boolean isOrphan(SagaRequest sagaRequest) { - return sagaRequest.parents().length == 0; - } - - private Map> requestsToNodes(SagaRequest[] sagaRequests) { - long index = 1; - Map> requestMap = new HashMap<>(); - for (SagaRequest sagaRequest : sagaRequests) { - if (requestMap.containsKey(sagaRequest.id())) { - // TODO: 8/20/2017 add random id if user didn't provide one - throw new SagaException("Failed to interpret requests with duplicate request id: " + sagaRequest.id()); - } - requestMap.put(sagaRequest.id(), new Node<>(index++, sagaRequest)); - } - return requestMap; - } - - private void detectCycle(SingleLeafDirectedAcyclicGraph graph) { - Set> jointNodes = detector.cycleJoints(graph); - - if (!jointNodes.isEmpty()) { - throw new SagaException("Cycle detected in the request graph at nodes " + jointNodes); - } - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetector.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetector.java deleted file mode 100644 index 9b12bc887..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetector.java +++ /dev/null @@ -1,25 +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.core.dag; - -import java.util.Set; - -public interface GraphCycleDetector { - - Set> cycleJoints(SingleLeafDirectedAcyclicGraph graph); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorImpl.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorImpl.java deleted file mode 100644 index f2869b3d4..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorImpl.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.core.dag; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Queue; -import java.util.Set; -import java.util.stream.Collectors; - -/** - * Cycle detection is based on topological sort with Kahn's algorithm. - * - * @see Topological Sorting - */ -public class GraphCycleDetectorImpl implements GraphCycleDetector { - - @Override - public Set> cycleJoints(SingleLeafDirectedAcyclicGraph graph) { - Queue> orphanNodes = new LinkedList<>(); - Map, Set>> nodeParents = new HashMap<>(); - - orphanNodes.add(graph.root()); - - traverse(orphanNodes, nodeParents); - - return unvisitedNodes(nodeParents); - } - - // This method is not thread safe - private void traverse(Queue> orphanNodes, Map, Set>> nodeParents) { - while (!orphanNodes.isEmpty()) { - Node node = orphanNodes.poll(); - - for(Node child : node.children()) { - Set> parent = nodeParents.get(child); - if (parent == null) { - parent = new HashSet<>(child.parents()); - nodeParents.put(child, parent); - } - parent.remove(node); - if (nodeParents.get(child).isEmpty()) { - orphanNodes.add(child); - } - } - } - } - - private Set> unvisitedNodes(Map, Set>> nodeParents) { - Set> result = new HashSet<>(); - for (Map.Entry, Set>> entry : nodeParents.entrySet()) { - if (!entry.getValue().isEmpty()) { - result.add(entry.getKey()); - } - } - return result; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Node.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Node.java deleted file mode 100644 index 3e5bcad65..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Node.java +++ /dev/null @@ -1,88 +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.core.dag; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -public class Node { - private final long id; - private final T value; - private final Set> children = new HashSet<>(); - private final Set> parents = new HashSet<>(); - - public Node(long id, T value) { - this.id = id; - this.value = value; - } - - long id() { - return id; - } - - public T value() { - return value; - } - - Set> parents() { - return parents; - } - - public Set> children() { - return children; - } - - public void addChild(Node node) { - children.add(node); - node.parents.add(this); - } - - public void addChildren(Collection> nodes) { - children.addAll(nodes); - for (Node node : nodes) { - node.parents.add(this); - } - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Node node = (Node) o; - return id == node.id; - } - - @Override - public int hashCode() { - return Objects.hash(id); - } - - @Override - public String toString() { - return "Node{" + - "id=" + id + - ", value=" + value + - '}'; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/SingleLeafDirectedAcyclicGraph.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/SingleLeafDirectedAcyclicGraph.java deleted file mode 100644 index cf0d19b15..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/SingleLeafDirectedAcyclicGraph.java +++ /dev/null @@ -1,38 +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.core.dag; - -public class SingleLeafDirectedAcyclicGraph { - - private final Node root; - private final Node leaf; - - public SingleLeafDirectedAcyclicGraph(Node root, Node leaf) { - - this.root = root; - this.leaf = leaf; - } - - public Node root() { - return root; - } - - Node leaf() { - return leaf; - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Traveller.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Traveller.java deleted file mode 100644 index e44848be6..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/Traveller.java +++ /dev/null @@ -1,29 +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.core.dag; - -import java.util.Collection; - -public interface Traveller { - - void next(); - - boolean hasNext(); - - Collection> nodes(); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/TraversalDirection.java b/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/TraversalDirection.java deleted file mode 100644 index 22f734316..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/core/dag/TraversalDirection.java +++ /dev/null @@ -1,29 +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.core.dag; - -import java.util.Set; - -public interface TraversalDirection { - - Node root(SingleLeafDirectedAcyclicGraph dag); - - Set> parents(Node node); - - Set> children(Node node); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStore.java b/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStore.java deleted file mode 100644 index 40fa71d1a..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStore.java +++ /dev/null @@ -1,56 +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.infrastructure; - -import java.util.Iterator; - -import org.apache.servicecomb.saga.core.EventEnvelope; -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.SagaContext; -import org.apache.servicecomb.saga.core.SagaEvent; - -public class ContextAwareEventStore implements EventStore { - private final EventStore eventStore; - private final SagaContext sagaContext; - - public ContextAwareEventStore(EventStore eventStore, SagaContext sagaContext) { - this.eventStore = eventStore; - this.sagaContext = sagaContext; - } - - @Override - public void offer(SagaEvent sagaEvent) { - sagaEvent.gatherTo(sagaContext); - eventStore.offer(sagaEvent); - } - - @Override - public void populate(Iterable events) { - eventStore.populate(events); - } - - @Override - public long size() { - return eventStore.size(); - } - - @Override - public Iterator iterator() { - return eventStore.iterator(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/EmbeddedEventStore.java b/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/EmbeddedEventStore.java deleted file mode 100644 index d3422643e..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/infrastructure/EmbeddedEventStore.java +++ /dev/null @@ -1,58 +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.infrastructure; - -import java.lang.invoke.MethodHandles; -import java.util.Iterator; -import java.util.Queue; -import java.util.concurrent.LinkedBlockingQueue; - -import org.apache.servicecomb.saga.core.EventEnvelope; -import org.apache.servicecomb.saga.core.EventStore; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class EmbeddedEventStore implements EventStore { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final Queue events = new LinkedBlockingQueue<>(); - - @Override - public void offer(SagaEvent sagaEvent) { - events.offer(sagaEvent); - log.info("Added event {}", sagaEvent); - } - - @Override - public void populate(Iterable events) { - for (EventEnvelope event : events) { - this.events.offer(event.event); - log.info("Populated event {}", event); - } - } - - @Override - public long size() { - return events.size(); - } - - @Override - public Iterator iterator() { - return events.iterator(); - } -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/RestTransport.java b/saga-core/src/main/java/org/apache/servicecomb/saga/transports/RestTransport.java deleted file mode 100644 index 3d5bda390..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/RestTransport.java +++ /dev/null @@ -1,27 +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.transports; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.Transport; -import java.util.Map; - -public interface RestTransport extends Transport { - - SagaResponse with(String address, String path, String method, Map> params); -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/SQLTransport.java b/saga-core/src/main/java/org/apache/servicecomb/saga/transports/SQLTransport.java deleted file mode 100644 index 9438f6521..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/SQLTransport.java +++ /dev/null @@ -1,29 +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.transports; - -import java.util.List; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.Transport; - -public interface SQLTransport extends Transport { - - SagaResponse with(String datasource, String sql, List> params); - -} diff --git a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/TransportFactory.java b/saga-core/src/main/java/org/apache/servicecomb/saga/transports/TransportFactory.java deleted file mode 100644 index 053149faf..000000000 --- a/saga-core/src/main/java/org/apache/servicecomb/saga/transports/TransportFactory.java +++ /dev/null @@ -1,25 +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.transports; - -import org.apache.servicecomb.saga.core.Transport; - -public interface TransportFactory { - - T getTransport(); -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/BackwardRecoveryTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/BackwardRecoveryTest.java deleted file mode 100644 index 4f0399287..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/BackwardRecoveryTest.java +++ /dev/null @@ -1,57 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; - -public class BackwardRecoveryTest { - - private final String serviceName = "aaa"; - private final Transaction transaction = mock(Transaction.class); - private final SagaTask sagaTask = mock(SagaTask.class); - private final SagaRequest sagaRequest = mock(SagaRequest.class); - private final SagaResponse parentResponse = mock(SagaResponse.class); - private final BackwardRecovery backwardRecovery = new BackwardRecovery(); - private final RuntimeException exception = new RuntimeException("oops"); - - @Before - public void setUp() throws Exception { - when(sagaRequest.serviceName()).thenReturn(serviceName); - when(sagaRequest.transaction()).thenReturn(transaction); - } - - @Test - public void blowsUpWhenTaskIsNotCommitted() { - doThrow(exception).when(transaction).send(serviceName, parentResponse); - - try { - backwardRecovery.apply(sagaTask, sagaRequest, parentResponse); - expectFailing(RuntimeException.class); - } catch (RuntimeException ignored) { - } - - verify(sagaTask).abort(sagaRequest, exception); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompensationImpl.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompensationImpl.java deleted file mode 100644 index 00778023e..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompensationImpl.java +++ /dev/null @@ -1,32 +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.core; - -import java.util.Map; - -public class CompensationImpl extends RestOperation implements Compensation { - - public CompensationImpl(String path, String method, Map> params) { - super(path, method, params); - } - - @Override - public int retries() { - return DEFAULT_RETRIES; - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaLogTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaLogTest.java deleted file mode 100644 index c7dea517d..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaLogTest.java +++ /dev/null @@ -1,49 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; - -import org.junit.Test; - -public class CompositeSagaLogTest { - - private final SagaRequest request = mock(SagaRequest.class); - private final DummyEvent sagaEvent = new DummyEvent(request); - private final SagaLog embedded = mock(SagaLog.class); - private final SagaLog persistent = mock(SagaLog.class); - - private final SagaLog compositeSagaLog = new CompositeSagaLog(embedded, persistent); - - @Test - public void addsLogsToEmbeddedOnlyAfterPersisted() { - doThrow(RuntimeException.class).when(persistent).offer(sagaEvent); - - try { - compositeSagaLog.offer(sagaEvent); - expectFailing(RuntimeException.class); - } catch (RuntimeException ignored) { - } - - verify(embedded, never()).offer(sagaEvent); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaResponseTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaResponseTest.java deleted file mode 100644 index 449340c5a..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/CompositeSagaResponseTest.java +++ /dev/null @@ -1,81 +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.core; - -import static java.util.Arrays.asList; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; - -import org.junit.Test; -import org.mockito.Mockito; - -public class CompositeSagaResponseTest { - - private final SagaResponse response1 = Mockito.mock(SagaResponse.class); - private final SagaResponse response2 = Mockito.mock(SagaResponse.class); - - private final SagaResponse compositeSagaResponse = new CompositeSagaResponse(asList(response1, response2)); - private final SagaResponse emptySagaResponse = new CompositeSagaResponse(new ArrayList()); - - @Test - public void succeededOnlyWhenAllAreSuccessful() throws Exception { - when(response1.succeeded()).thenReturn(true); - when(response2.succeeded()).thenReturn(true); - - assertThat(compositeSagaResponse.succeeded(), is(true)); - } - - @Test - public void failedWhenAnyIsNotSuccessful() throws Exception { - when(response1.succeeded()).thenReturn(true); - when(response2.succeeded()).thenReturn(false); - - assertThat(compositeSagaResponse.succeeded(), is(false)); - } - - @Test - public void bodyCombinesAllResponseBodies() throws Exception { - when(response1.body()).thenReturn("{\n" - + " \"status\": 500,\n" - + " \"body\" : \"oops\"\n" - + "}\n"); - - when(response2.body()).thenReturn("{\n" - + " \"status\": 200,\n" - + " \"body\" : \"blah\"\n" - + "}\n"); - - assertThat(compositeSagaResponse.body(), is("[{\n" - + " \"status\": 500,\n" - + " \"body\" : \"oops\"\n" - + "}\n" - + ", {\n" - + " \"status\": 200,\n" - + " \"body\" : \"blah\"\n" - + "}\n" - + "]")); - } - - @Test - public void EmptyCompositeSagaResponse() { - assertThat(emptySagaResponse.body(), is("{}")); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/DummyEvent.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/DummyEvent.java deleted file mode 100644 index c775afe50..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/DummyEvent.java +++ /dev/null @@ -1,31 +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.core; - -public class DummyEvent extends SagaEvent { - - DummyEvent(SagaRequest payload) { - super("0", payload); - } - - @Override - public void gatherTo(EventContext sagaContext) { - - } - -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/FallbackPolicyTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/FallbackPolicyTest.java deleted file mode 100644 index a2d1f32b6..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/FallbackPolicyTest.java +++ /dev/null @@ -1,91 +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.core; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -public class FallbackPolicyTest { - - private final int numberOfRetries = 3; - private final String address = uniquify("address"); - - private final SagaResponse success = Mockito.mock(SagaResponse.class); - private final SagaResponse failure = Mockito.mock(SagaResponse.class); - private final Fallback fallback = Mockito.mock(Fallback.class); - private final Compensation compensation = Mockito.mock(Compensation.class); - private final FallbackPolicy fallbackPolicy = new FallbackPolicy(100); - - @SuppressWarnings("ThrowableInstanceNeverThrown") - private final RuntimeException exception = new RuntimeException("oops"); - - @Before - public void setUp() throws Exception { - when(compensation.retries()).thenReturn(numberOfRetries); - when(fallback.send(address)).thenReturn(failure); - } - - @Test - public void retriesTransportForSpecifiedTimes() { - when(compensation.send(address)) - .thenThrow(exception) - .thenThrow(exception) - .thenReturn(success); - - SagaResponse response = fallbackPolicy.apply(address, compensation, fallback); - - assertThat(response, is(success)); - verify(compensation, times(3)).send(address); - } - - @Test - public void fallbackIfTransportFailedWithRetry() { - when(compensation.send(address)).thenThrow(exception); - - SagaResponse response = fallbackPolicy.apply(address, compensation, fallback); - assertThat(response, is(failure)); - - verify(compensation, times(numberOfRetries + 1)).send(address); - verify(fallback).send(address); - } - - @Test - public void retryUntilSuccessIfNumberOfRetriesIsNegative() throws InterruptedException { - reset(compensation); - when(compensation.retries()).thenReturn(-1); - when(compensation.send(address)) - .thenThrow(exception, exception, exception, exception, exception) - .thenReturn(success); - - SagaResponse response = fallbackPolicy.apply(address, compensation, fallback); - - assertThat(response, is(success)); - verify(fallback, never()).send(anyString()); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/ForwardRecoveryTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/ForwardRecoveryTest.java deleted file mode 100644 index 1d21914e9..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/ForwardRecoveryTest.java +++ /dev/null @@ -1,86 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; - -public class ForwardRecoveryTest { - - private final SagaTask sagaTask = mock(SagaTask.class); - - private final Transaction transaction = mock(Transaction.class); - - private final SagaRequest sagaRequest = mock(SagaRequest.class); - private final SagaResponse parentResponse = mock(SagaResponse.class); - - private final ForwardRecovery forwardRecovery = new ForwardRecovery(); - - private final String serviceName = "aaa"; - - private final int numberOfRetries = 3; - - @Before - public void setUp() { - when(sagaRequest.serviceName()).thenReturn(serviceName); - when(sagaRequest.transaction()).thenReturn(transaction); - when(sagaRequest.failRetryDelayMilliseconds()).thenReturn(300); - when(transaction.retries()).thenReturn(numberOfRetries); - when(transaction.toString()).thenReturn(serviceName); - } - - @Test - public void blowsUpWhenTaskIsNotCommittedWithFailRetryDelaySeconds() throws Exception { - doThrow(Exception.class).when(transaction).send(serviceName, parentResponse); - - Thread t = new Thread(new Runnable() { - @Override - public void run() { - forwardRecovery.apply(sagaTask, sagaRequest, parentResponse); - } - }); - t.start(); - Thread.sleep(400); - t.interrupt(); - - verify(transaction, times(2)).send(serviceName, parentResponse); - } - - @Test - public void retriesTransportForSpecifiedTimes() { - doThrow(Exception.class).when(transaction).send(serviceName, parentResponse); - - try { - forwardRecovery.apply(sagaTask, sagaRequest, parentResponse); - expectFailing(TransactionFailedException.class); - } catch (TransactionAbortedException e) { - assertThat(e.getMessage(), is("Too many failures in transaction aaa of service aaa, abort the transaction!")); - } - - verify(transaction, times(4)).send(serviceName, parentResponse); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/LongIdGeneratorTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/LongIdGeneratorTest.java deleted file mode 100644 index 775866b63..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/LongIdGeneratorTest.java +++ /dev/null @@ -1,36 +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.core; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; - -public class LongIdGeneratorTest { - - - private final LongIdGenerator generator = new LongIdGenerator(); - - @Test - public void generatesLongInSequence() { - for (long index = 0; index < 10; index++) { - assertThat(generator.nextId(), is(index + 1)); - } - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/RestOperationTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/RestOperationTest.java deleted file mode 100644 index 900bb8be1..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/RestOperationTest.java +++ /dev/null @@ -1,95 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.util.Collections; -import java.util.Map; - -import org.junit.Test; - -public class RestOperationTest { - - public static final Map> EMPTY_MAP_MAP = Collections.>emptyMap(); - public static final Map EMPTY_MAP = Collections.emptyMap(); - - @Test - public void blowsUpWhenGetMethodWithForm() { - try { - new RestOperation("blah", "GET", singletonMap("form", EMPTY_MAP)); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("GET & DELETE request cannot enclose a body")); - } - } - - @Test - public void blowsUpWhenGetMethodWithJson() { - try { - new RestOperation("blah", "GET", singletonMap("json", EMPTY_MAP)); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("GET & DELETE request cannot enclose a body")); - } - } - - @Test - public void blowsUpWhenDeleteMethodWithForm() { - try { - new RestOperation("blah", "DELETE", singletonMap("form", EMPTY_MAP)); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("GET & DELETE request cannot enclose a body")); - } - } - - @Test - public void blowsUpWhenDeleteMethodWithJson() { - try { - new RestOperation("blah", "DELETE", singletonMap("json", EMPTY_MAP)); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("GET & DELETE request cannot enclose a body")); - } - } - - @Test - public void blowsUpWhenMethodIsNotSupported() { - try { - new RestOperation("blah", "foo", EMPTY_MAP_MAP ); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Unsupported method foo")); - } - } - - @Test - public void blowsUpWhenMethodIsNull() { - try { - new RestOperation("blah", null, EMPTY_MAP_MAP); - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Unsupported method null")); - } - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/RetrySagaLogTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/RetrySagaLogTest.java deleted file mode 100644 index 9f9bdc86b..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/RetrySagaLogTest.java +++ /dev/null @@ -1,89 +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.core; - - -import static org.awaitility.Awaitility.await; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.junit.Test; - -import org.apache.servicecomb.saga.core.SagaTaskFactory.RetrySagaLog; - -public class RetrySagaLogTest { - - private final PersistentStore persistentStore = mock(PersistentStore.class); - private final SagaRequest sagaRequest = mock(SagaRequest.class); - private final SagaEvent dummyEvent = new DummyEvent(sagaRequest); - private final RetrySagaLog retrySagaLog = new RetrySagaLog(persistentStore, 100); - - private volatile boolean interrupted = false; - - @Test - public void retryUntilSuccessWhenEventIsNotPersisted() throws InterruptedException { - doThrow(RuntimeException.class). - doThrow(RuntimeException.class). - doThrow(RuntimeException.class). - doThrow(RuntimeException.class). - doThrow(RuntimeException.class). - doNothing(). - when(persistentStore).offer(dummyEvent); - - retrySagaLog.offer(dummyEvent); - - verify(persistentStore, times(6)).offer(dummyEvent); - } - - @Test - public void exitOnInterruption() throws InterruptedException { - ExecutorService executor = Executors.newSingleThreadExecutor(); - - Future future = executor.submit(new Runnable() { - @Override - public void run() { - doThrow(RuntimeException.class).when(persistentStore).offer(dummyEvent); - - retrySagaLog.offer(dummyEvent); - interrupted = true; - } - }); - - Thread.sleep(500); - - assertThat(future.cancel(true), is(true)); - - await().atMost(2, TimeUnit.SECONDS).until(new Callable() { - @Override - public Boolean call() { - return interrupted; - } - }); - executor.shutdown(); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEndTaskTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEndTaskTest.java deleted file mode 100644 index 22f5fa15e..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEndTaskTest.java +++ /dev/null @@ -1,47 +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.core; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.mock; - -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -public class SagaEndTaskTest { - private final SagaRequest request = mock(SagaRequest.class); - private final SagaLog sagaLog = mock(SagaLog.class); - - private final String sagaId = "0"; - private final SagaEndTask sagaEndTask = new SagaEndTask(sagaId, sagaLog); - - @Test - public void emptyResponseOnSuccessfulEventPersistence() throws Exception { - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(SagaEndedEvent.class); - doNothing().when(sagaLog).offer(argumentCaptor.capture()); - - sagaEndTask.commit(request, SagaResponse.EMPTY_RESPONSE); - - SagaEndedEvent event = argumentCaptor.getValue(); - assertThat(event.sagaId, is(sagaId)); - assertThat(event.json(null), is("{}")); - assertThat(event.payload(), is(request)); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEventMatcher.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEventMatcher.java deleted file mode 100644 index 7e8289c71..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaEventMatcher.java +++ /dev/null @@ -1,68 +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.core; - -import java.util.Objects; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; - -public class SagaEventMatcher extends TypeSafeMatcher { - - private final String sagaId; - private final Operation operation; - private final Class aClass; - - public static Matcher eventWith(String sagaId, Operation operation, Class aClass) { - return new SagaEventMatcher(sagaId, operation, aClass); - } - - static Matcher eventWith(Operation operation, Class aClass) { - return eventWith("0", operation, aClass); - } - - private SagaEventMatcher(String sagaId, Operation operation, Class aClass) { - this.sagaId = sagaId; - this.operation = operation; - this.aClass = aClass; - } - - @Override - protected void describeMismatchSafely(SagaEvent item, Description description) { - description - .appendText("SagaEvent {sagaId=" + item.sagaId + ", operation=" + operation(item) + ", class=" + item.getClass()); - } - - @Override - protected boolean matchesSafely(SagaEvent envelope) { - return Objects.equals(envelope.sagaId, sagaId) - && operation(envelope).equals(operation) - && envelope.getClass().equals(aClass); - } - - @Override - public void describeTo(Description description) { - description - .appendText("SagaEvent {sagaId=" + sagaId + ", operation=" + operation + ", class=" + aClass.getCanonicalName()); - } - - private Operation operation(SagaEvent envelope) { - return operation instanceof Compensation ? envelope.payload().compensation() : envelope.payload().transaction(); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaExecutionComponentTestBase.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaExecutionComponentTestBase.java deleted file mode 100644 index d4f88c405..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaExecutionComponentTestBase.java +++ /dev/null @@ -1,272 +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.core; - -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static java.util.Collections.singletonList; -import static java.util.Collections.singletonMap; -import static java.util.concurrent.TimeUnit.SECONDS; -import static org.awaitility.Awaitility.waitAtMost; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.apache.servicecomb.saga.core.application.SagaFactory; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.infrastructure.EmbeddedEventStore; - -@SuppressWarnings("unchecked") -public abstract class SagaExecutionComponentTestBase { - - private static final String requestJson = "[\n" - + " {\n" - + " \"id\": \"request-1\",\n" - + " \"serviceName\": \"aaa\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/as\"\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/as\"\n" - + " }\n" - + " }\n" - + "]\n"; - - private static final String sagaJson = "{\n" - + " \"policy\": \"ForwardRecovery\",\n" - + " \"requests\": " + requestJson + "\n" - + "}"; - - private static final String anotherRequestJson = "[\n" - + " {\n" - + " \"id\": \"request-2\",\n" - + " \"serviceName\": \"bbb\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/bs\"\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/bs\"\n" - + " }\n" - + " }\n" - + "]\n"; - - private static final String anotherSagaJson = "{\n" - + " \"policy\": \"ForwardRecovery\",\n" - + " \"requests\": " + anotherRequestJson + "\n" - + "}"; - - public static final Map> EMPTY_MAP = Collections.>emptyMap(); - - private final SagaRequest request1 = new SagaRequestImpl( - "request-1", - "aaa", - TYPE_REST, - new TransactionImpl("/rest/as", "post", EMPTY_MAP), - new CompensationImpl("/rest/as", "delete", EMPTY_MAP) - ); - - private final SagaRequest request2 = new SagaRequestImpl( - "request-2", - "bbb", - TYPE_REST, - new TransactionImpl("/rest/bs", "post", EMPTY_MAP), - new CompensationImpl("/rest/bs", "delete", EMPTY_MAP) - ); - - private final SagaDefinition definition1 = new SagaDefinition() { - @Override - public RecoveryPolicy policy() { - return new ForwardRecovery(); - } - - @Override - public SagaRequest[] requests() { - return new SagaRequest[]{request1}; - } - }; - - private final SagaDefinition definition2 = new SagaDefinition() { - @Override - public RecoveryPolicy policy() { - return new BackwardRecovery(); - } - - @Override - public SagaRequest[] requests() { - return new SagaRequest[]{request2}; - } - }; - - private final FromJsonFormat fromJsonFormat = Mockito.mock(FromJsonFormat.class); - private final EmbeddedPersistentStore eventStore = new EmbeddedPersistentStore(); - - private final SagaExecutionComponent coordinator = new SagaExecutionComponent( - eventStore, - fromJsonFormat, - null, - sagaFactory(eventStore) - ); - - private final String sagaId = "1"; - - @Before - public void setUp() throws Exception { - when(fromJsonFormat.fromJson(sagaJson)).thenReturn(definition1); - when(fromJsonFormat.fromJson(anotherSagaJson)).thenReturn(definition2); - } - - @Test - public void recoverSagaWithEventsFromEventStore() throws IOException { - eventStore.offer(new SagaStartedEvent(sagaId, sagaJson, NoOpSagaRequest.SAGA_START_REQUEST)); - coordinator.reanimate(); - - assertThat(eventStore, contains( - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request1, TransactionStartedEvent.class), - eventWith(request1, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class) - )); - } - - @Test - public void runSagaWithEventStore() throws IOException { - SagaResponse response = coordinator.run(sagaJson); - - assertThat(response, is(SagaResponse.EMPTY_RESPONSE)); - assertThat(eventStore, contains( - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request1, TransactionStartedEvent.class), - eventWith(request1, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class) - )); - } - - @Test - public void processRequestsInParallel() { - ExecutorService executor = Executors.newFixedThreadPool(2); - - executor.submit(new Runnable() { - @Override - public void run() { - coordinator.run(sagaJson); - } - }); - executor.submit(new Runnable() { - @Override - public void run() { - coordinator.run(anotherSagaJson); - } - }); - - waitAtMost(2, SECONDS).until(new Callable() { - @Override - public Boolean call() throws Exception { - return eventStore.size() == 8; - } - }); - - assertThat(eventStore, containsInAnyOrder( - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request1, TransactionStartedEvent.class), - eventWith(request1, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request2, TransactionStartedEvent.class), - eventWith(request2, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class) - )); - } - - @Test - public void runSagaAfterRecovery() throws IOException { - eventStore.offer(new SagaStartedEvent(sagaId, sagaJson, NoOpSagaRequest.SAGA_START_REQUEST)); - coordinator.reanimate(); - - coordinator.run(anotherSagaJson); - - assertThat(eventStore, contains( - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request1, TransactionStartedEvent.class), - eventWith(request1, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_START_REQUEST, SagaStartedEvent.class), - eventWith(request2, TransactionStartedEvent.class), - eventWith(request2, TransactionEndedEvent.class), - eventWith(NoOpSagaRequest.SAGA_END_REQUEST, SagaEndedEvent.class) - )); - } - - private Matcher eventWith( - final SagaRequest sagaRequest, - final Class type) { - - return new TypeSafeMatcher() { - @Override - protected boolean matchesSafely(SagaEvent event) { - SagaRequest request = event.payload(); - return sagaRequest.equals(request) - && event.getClass().equals(type); - } - - @Override - protected void describeMismatchSafely(SagaEvent item, Description mismatchDescription) { - SagaRequest request = item.payload(); - mismatchDescription.appendText( - "SagaEvent {" + request + "}"); - } - - @Override - public void describeTo(Description description) { - description.appendText( - "SagaEvent {" + sagaRequest + "}"); - } - }; - } - - private class EmbeddedPersistentStore extends EmbeddedEventStore implements PersistentStore { - - @Override - public Map> findPendingSagaEvents() { - return singletonMap(sagaId, singletonList( - new EventEnvelope(1L, new SagaStartedEvent(sagaId, sagaJson, NoOpSagaRequest.SAGA_START_REQUEST)))); - } - } - - protected abstract SagaFactory sagaFactory(PersistentStore eventStore); -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaIntegrationTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaIntegrationTest.java deleted file mode 100644 index 64187ebb4..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaIntegrationTest.java +++ /dev/null @@ -1,738 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.apache.servicecomb.saga.core.Compensation.SAGA_START_COMPENSATION; -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static org.apache.servicecomb.saga.core.SagaEventMatcher.eventWith; -import static org.apache.servicecomb.saga.core.SagaResponse.EMPTY_RESPONSE; -import static org.apache.servicecomb.saga.core.SagaResponse.NONE_RESPONSE; -import static org.apache.servicecomb.saga.core.SagaTask.SAGA_END_TASK; -import static org.apache.servicecomb.saga.core.SagaTask.SAGA_REQUEST_TASK; -import static org.apache.servicecomb.saga.core.SagaTask.SAGA_START_TASK; -import static org.apache.servicecomb.saga.core.Transaction.SAGA_END_TRANSACTION; -import static org.apache.servicecomb.saga.core.Transaction.SAGA_START_TRANSACTION; -import static java.util.Arrays.asList; -import static java.util.Collections.emptySet; -import static java.util.Collections.singletonList; -import static org.hamcrest.Matchers.anyOf; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.CyclicBarrier; - -import org.hamcrest.core.Is; -import org.junit.Before; -import org.junit.Test; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; - -import com.seanyinx.github.unit.scaffolding.Randomness; - -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.core.dag.Node; -import org.apache.servicecomb.saga.core.dag.SingleLeafDirectedAcyclicGraph; -import org.apache.servicecomb.saga.infrastructure.ContextAwareEventStore; -import org.apache.servicecomb.saga.infrastructure.EmbeddedEventStore; - -@SuppressWarnings("unchecked") -public class SagaIntegrationTest { - private static final String sagaId = Randomness.uniquify("sagaId"); - - private final FromJsonFormat> childrenExtractor = mock(FromJsonFormat.class); - private final SagaContext sagaContext = new SagaContextImpl(childrenExtractor); - private final IdGenerator idGenerator = new LongIdGenerator(); - private final EventStore eventStore = new EmbeddedEventStore(); - private final ContextAwareEventStore sagaLog = new ContextAwareEventStore(eventStore, sagaContext); - - private final Transaction transaction1 = mock(Transaction.class, "transaction1"); - private final Transaction transaction2 = mock(Transaction.class, "transaction2"); - private final Transaction transaction3 = mock(Transaction.class, "transaction3"); - private final Transaction transaction4 = mock(Transaction.class, "transaction4"); - - private final Compensation compensation1 = mock(Compensation.class, "compensation1"); - private final Compensation compensation2 = mock(Compensation.class, "compensation2"); - private final Compensation compensation3 = mock(Compensation.class, "compensation3"); - private final Compensation compensation4 = mock(Compensation.class, "compensation4"); - - private final Fallback fallback1 = mock(Fallback.class, "fallback1"); - - private final String requestJson = "{}"; - private final SagaRequest request1 = request("request1", "service1", transaction1, compensation1, fallback1); - private final SagaRequest request2 = request("request2", "service2", transaction2, compensation2, request1.id()); - private final SagaRequest request3 = request("request3", "service3", transaction3, compensation3, request1.id()); - private final SagaRequest request4 = request("request4", "service4", transaction4, compensation4, request3.id()); - - private final SagaResponse transactionResponse1 = new SuccessfulSagaResponse("transaction1"); - private final SagaResponse transactionResponse2 = new SuccessfulSagaResponse("transaction2"); - private final SagaResponse transactionResponse3 = new SuccessfulSagaResponse("transaction3"); - private final SagaResponse compensationResponse1 = new SuccessfulSagaResponse("compensation1"); - private final SagaResponse compensationResponse2 = new SuccessfulSagaResponse("compensation2"); - private final SagaResponse compensationResponse3 = new SuccessfulSagaResponse("compensation3"); - - @SuppressWarnings("ThrowableInstanceNeverThrown") - private final RuntimeException exception = new RuntimeException("oops"); - - private final Node node1 = new Node<>(1, request1); - private final Node node2 = new Node<>(2, request2); - private final Node node3 = new Node<>(3, request3); - private final Node node4 = new Node<>(4, request4); - private final Node root = new Node<>(0, NoOpSagaRequest.SAGA_START_REQUEST); - private final Node leaf = new Node<>(5, NoOpSagaRequest.SAGA_END_REQUEST); - private final SingleLeafDirectedAcyclicGraph sagaTaskGraph = new SingleLeafDirectedAcyclicGraph<>(root, leaf); - - private Saga saga; - private final Map tasks = new HashMap<>(); - - // root - node1 - node2 - leaf - @Before - public void setUp() throws Exception { - when(childrenExtractor.fromJson(anyString())).thenReturn(Collections.emptySet()); - when(childrenExtractor.fromJson(NONE_RESPONSE.body())).thenReturn(setOf("none")); - - when(transaction1.send(request1.serviceName(), EMPTY_RESPONSE)).thenReturn(transactionResponse1); - when(transaction2.send(request2.serviceName(), transactionResponse1)).thenReturn(transactionResponse2); - when(transaction3.send(request3.serviceName(), transactionResponse1)).thenReturn(transactionResponse3); - - when(compensation1.send(request1.serviceName(), compensationResponse2)).thenReturn(compensationResponse1); - when(compensation2.send(request2.serviceName(), compensationResponse3)).thenReturn(compensationResponse2); - when(compensation3.send(request3.serviceName(), EMPTY_RESPONSE)).thenReturn(compensationResponse3); - - root.addChild(node1); - node1.addChild(node2); - node2.addChild(leaf); - - SagaStartTask sagaStartTask = new SagaStartTask(sagaId, requestJson, sagaLog); - SagaEndTask sagaEndTask = new SagaEndTask(sagaId, sagaLog); - RequestProcessTask processTask = requestProcessTask(new BackwardRecovery()); - - tasks.put(SAGA_START_TASK, sagaStartTask); - tasks.put(SAGA_REQUEST_TASK, processTask); - tasks.put(SAGA_END_TASK, sagaEndTask); - - saga = new GraphBasedSaga(eventStore, tasks, sagaContext, sagaTaskGraph); - } - - @Test - public void transactionsAreRunSuccessfully() { - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - // root - node1 - node2 - leaf - // \_ node3 _/ - @Test - public void compensateCommittedTransactionsOnFailure() { - addExtraChildToNode1(); - - // barrier to make sure the two transactions starts at the same time - final CyclicBarrier barrier = new CyclicBarrier(2); - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenAnswer( - withAnswer(new Callable() { - @Override - public SagaResponse call() throws Exception { - barrier.await(); - Thread.sleep(100); - throw exception; - } - })); - - when(transaction3.send(request3.serviceName(), transactionResponse1)) - .thenAnswer( - withAnswer(new Callable() { - @Override - public SagaResponse call() throws Exception { - barrier.await(); - return transactionResponse3; - } - })); - - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - anyOf(eventWith(sagaId, transaction2, TransactionStartedEvent.class), eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - anyOf(eventWith(sagaId, transaction2, TransactionStartedEvent.class), eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionAbortedEvent.class), - eventWith(sagaId, compensation3, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class))); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3).send(request3.serviceName()); - } - - @Test - public void skipIgnoredTransaction() throws Exception { - addExtraChildToNode1(); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf(request3.id())); - - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void skipAllIgnoredTransactions() throws Exception { - node1.addChild(node3); - node3.addChild(node4); - node4.addChild(leaf); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf("none")); - - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction4, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - verify(compensation4, never()).send(request4.serviceName()); - } - - @Test - public void doNotCompensateIgnoredTransactions() throws Exception { - node1.addChild(node3); - node3.addChild(node4); - node4.addChild(leaf); - - when(childrenExtractor.fromJson(transactionResponse1.body())).thenReturn(setOf(request3.id())); - - when(transaction4.send(request4.serviceName(), transactionResponse3)).thenThrow(exception); - - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, transaction4, TransactionStartedEvent.class), - eventWith(sagaId, transaction4, TransactionAbortedEvent.class), - eventWith(sagaId, transaction3, TransactionCompensatedEvent.class), - eventWith(sagaId, transaction1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - verify(transaction4).send(request4.serviceName(), transactionResponse3); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation3).send(request3.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation4, never()).send(request4.serviceName()); - } - - // root - node1 - node2 - leaf - // \_ node3 _/ - @Test - public void redoHangingTransactionsOnFailure() throws InterruptedException { - addExtraChildToNode1(); - - // barrier to make sure the two transactions starts at the same time - final CyclicBarrier barrier = new CyclicBarrier(2); - when(transaction3.send(request3.serviceName(), transactionResponse1)) - .thenAnswer(withAnswer(new Callable() { - @Override - public SagaResponse call() throws Exception { - barrier.await(); - throw exception; - } - })); - - final CountDownLatch latch = new CountDownLatch(1); - - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenAnswer(withAnswer(new Callable() { - @Override - public SagaResponse call() throws Exception { - barrier.await(); - latch.await(); - return transactionResponse2; - } - })).thenReturn(transactionResponse2); - - saga.run(); - - // the ordering of events may not be consistence due to concurrent processing of requests - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - anyOf( - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class)), - anyOf( - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class)), - eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class))); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2, times(2)).send(request2.serviceName(), transactionResponse1); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - - latch.countDown(); - } - - @Test - public void retriesFailedTransactionTillSuccess() { - RequestProcessTask processTask = requestProcessTask(new ForwardRecovery()); - tasks.put(SAGA_REQUEST_TASK, processTask); - - when(transaction2.retries()).thenReturn(-1); - when(transaction2.send(request2.serviceName(), transactionResponse1)) - .thenThrow(exception).thenThrow(exception).thenReturn(transactionResponse2); - - saga.run(); - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2, times(3)).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(anyString(), any(SagaResponse.class)); - verify(compensation2, never()).send(anyString(), any(SagaResponse.class)); - } - - @Test - public void retriesFailedTransactionTillMaximum() { - RequestProcessTask processTask = requestProcessTask(new ForwardRecovery()); - tasks.put(SAGA_REQUEST_TASK, processTask); - - when(transaction2.send(request2.serviceName(), transactionResponse1)).thenThrow(exception); - when(transaction2.retries()).thenReturn(2); - when(transaction2.toString()).thenReturn("transaction2"); - - try { - saga.run(); - } catch (TransactionAbortedException e) { - assertThat(e.getMessage(), - Is.is("Too many failures in transaction transaction2 of service " + request2.serviceName() + ", stop transaction!")); - } - - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class) - )); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2, times(3)).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(anyString(), any(SagaResponse.class)); - verify(compensation2, never()).send(anyString(), any(SagaResponse.class)); - } - - @Test - public void fallbackWhenCompensationFailed() { - int retries = 3; - - when(transaction2.send(request2.serviceName(), transactionResponse1)).thenThrow(exception); - when(compensation1.send(request1.serviceName())).thenThrow(exception); - when(compensation1.retries()).thenReturn(retries); - - saga.run(); - - verify(transaction1).send(request1.serviceName(), EMPTY_RESPONSE); - verify(transaction2).send(request2.serviceName(), transactionResponse1); - - verify(compensation1, times(retries + 1)).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - - verify(fallback1).send(request1.serviceName()); - } - - @Test - public void restoresSagaToTransactionStateByPlayingAllEvents() { - addExtraChildToNode1(); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1, transactionResponse1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2, transactionResponse2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresPartialTransactionByPlayingAllEvents() { - addExtraChildToNode1(); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1, transactionResponse1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2, transactionResponse2)), - envelope(new TransactionStartedEvent(sagaId, request3)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3).send(request3.serviceName(), transactionResponse1); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresToCompensationFromAbortedTransactionByPlayingAllEvents() { - addExtraChildToNode1(); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionAbortedEvent(sagaId, request3, exception)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresSagaToCompensationStateByPlayingAllEvents() { - addExtraChildToNode1(); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionEndedEvent(sagaId, request3)), - envelope(new TransactionCompensatedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionEndedEvent.class), - eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation3, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3).send(request3.serviceName()); - } - - @Test - public void restoresPartialCompensationByPlayingAllEvents() { - addExtraChildToNode1(); - - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)), - envelope(new TransactionStartedEvent(sagaId, request3)), - envelope(new TransactionAbortedEvent(sagaId, request3, exception)), - envelope(new TransactionCompensatedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, transaction3, TransactionStartedEvent.class), - eventWith(sagaId, transaction3, TransactionAbortedEvent.class), - eventWith(sagaId, compensation2, TransactionCompensatedEvent.class), - eventWith(sagaId, compensation1, TransactionCompensatedEvent.class), - eventWith(sagaId, SAGA_START_COMPENSATION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction3, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - verify(compensation3, never()).send(request3.serviceName()); - } - - @Test - public void restoresSagaToEndStateByPlayingAllEvents() { - Iterable events = asList( - envelope(new SagaStartedEvent(sagaId, requestJson, NoOpSagaRequest.SAGA_START_REQUEST)), - envelope(new TransactionStartedEvent(sagaId, request1)), - envelope(new TransactionEndedEvent(sagaId, request1)), - envelope(new TransactionStartedEvent(sagaId, request2)), - envelope(new TransactionEndedEvent(sagaId, request2)) - ); - - eventStore.populate(events); - saga.play(); - - saga.run(); - assertThat(eventStore, contains( - eventWith(sagaId, SAGA_START_TRANSACTION, SagaStartedEvent.class), - eventWith(sagaId, transaction1, TransactionStartedEvent.class), - eventWith(sagaId, transaction1, TransactionEndedEvent.class), - eventWith(sagaId, transaction2, TransactionStartedEvent.class), - eventWith(sagaId, transaction2, TransactionEndedEvent.class), - eventWith(sagaId, SAGA_END_TRANSACTION, SagaEndedEvent.class) - )); - - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - @Test - public void failFastIfSagaLogIsDown() throws Exception { - SagaLog sagaLog = mock(SagaLog.class); - tasks.put(SAGA_START_TASK, new SagaStartTask(sagaId, requestJson, sagaLog)); - - doThrow(RuntimeException.class).when(sagaLog).offer(any(SagaStartedEvent.class)); - - try { - saga.run(); - expectFailing(SagaStartFailedException.class); - } catch (SagaStartFailedException e) { - assertThat(e.getMessage(), is("Failed to persist SagaStartedEvent for " + requestJson)); - } - - verify(sagaLog).offer(any(SagaStartedEvent.class)); - verify(transaction1, never()).send(anyString(), any(SagaResponse.class)); - verify(transaction2, never()).send(anyString(), any(SagaResponse.class)); - - verify(compensation1, never()).send(request1.serviceName()); - verify(compensation2, never()).send(request2.serviceName()); - } - - private Answer withAnswer(final Callable callable) { - return new Answer() { - @Override - public SagaResponse answer(InvocationOnMock invocation) throws Throwable { - return callable.call(); - } - }; - } - - private EventEnvelope envelope(SagaEvent event) { - return new EventEnvelope(idGenerator.nextId(), event); - } - - private void addExtraChildToNode1() { - node1.addChild(node3); - node3.addChild(leaf); - } - - private SagaRequest request(String requestId, - String serviceName, - Transaction transaction, - Compensation compensation, - String... parentIds) { - - return new SagaRequestImpl(requestId, serviceName, TYPE_REST, transaction, compensation, parentIds); - } - - private SagaRequest request(String requestId, - String serviceName, - Transaction transaction, - Compensation compensation, - Fallback fallback) { - - return new SagaRequestImpl(requestId, serviceName, TYPE_REST, transaction, compensation, fallback); - } - - private HashSet setOf(String requestId) { - return new HashSet<>(singletonList(requestId)); - } - - private RequestProcessTask requestProcessTask(RecoveryPolicy recoveryPolicy) { - return new RequestProcessTask(sagaId, sagaLog, recoveryPolicy, new FallbackPolicy(100)); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaStartTaskTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaStartTaskTest.java deleted file mode 100644 index b1d0c4e45..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/SagaStartTaskTest.java +++ /dev/null @@ -1,64 +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.core; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; - -import org.junit.Test; -import org.mockito.ArgumentCaptor; - -public class SagaStartTaskTest { - private final SagaRequest request = mock(SagaRequest.class); - private final SagaLog sagaLog = mock(SagaLog.class); - - private final String sagaId = "0"; - private final String requestJson = null; - private final SagaStartTask sagaStartTask = new SagaStartTask(sagaId, requestJson, sagaLog); - - @Test - public void emptyResponseOnSuccessfulEventPersistence() throws Exception { - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(SagaStartedEvent.class); - doNothing().when(sagaLog).offer(argumentCaptor.capture()); - - sagaStartTask.commit(request, SagaResponse.EMPTY_RESPONSE); - - SagaStartedEvent event = argumentCaptor.getValue(); - assertThat(event.sagaId, is(sagaId)); - assertThat(event.json(null), is(requestJson)); - assertThat(event.payload(), is(request)); - } - - @Test - public void blowsUpWhenEventIsNotPersisted() { - doThrow(RuntimeException.class).when(sagaLog).offer(any(SagaStartedEvent.class)); - - try { - sagaStartTask.commit(request, SagaResponse.EMPTY_RESPONSE); - expectFailing(SagaStartFailedException.class); - } catch (SagaStartFailedException e) { - assertThat(e.getMessage(), startsWith("Failed to persist SagaStartedEvent")); - } - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/TransactionImpl.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/TransactionImpl.java deleted file mode 100644 index b0d4a3586..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/TransactionImpl.java +++ /dev/null @@ -1,32 +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.core; - -import java.util.Map; - -public class TransactionImpl extends RestOperation implements Transaction { - - public TransactionImpl(String path, String method, Map> params) { - super(path, method, params); - } - - @Override - public int retries() { - return INFINITE_RETRY; - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/DirectedAcyclicGraphTraversalTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/DirectedAcyclicGraphTraversalTest.java deleted file mode 100644 index 3c54fcff5..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/DirectedAcyclicGraphTraversalTest.java +++ /dev/null @@ -1,102 +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.core.dag; - -import static java.util.Arrays.asList; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertThat; - -import java.util.Collection; -import org.junit.Before; -import org.junit.Test; - -public class DirectedAcyclicGraphTraversalTest { - - private final Node root = new Node<>(0, "i don't care"); - private final Node node1 = new Node<>(1, "i don't care"); - private final Node node2 = new Node<>(2, "i don't care"); - private final Node node3 = new Node<>(3, "i don't care"); - private final Node node4 = new Node<>(4, "i don't care"); - private final Node node5 = new Node<>(5, "i don't care"); - private final Node leaf = new Node<>(6, "i don't care"); - - private final SingleLeafDirectedAcyclicGraph dag = new SingleLeafDirectedAcyclicGraph<>(root, leaf); - - // 0 - // / \ - // 1 \ - // / \ \ - // 3 4 2 - // \ / / - // 5 / - // \ / - // 6 - @Before - public void setUp() throws Exception { - root.addChildren(asList(node1, node2)); - node1.addChildren(asList(node3, node4)); - node3.addChild(node5); - node4.addChild(node5); - node5.addChild(leaf); - node2.addChild(leaf); - } - - @Test - public void traverseGraphOneLevelPerStepFromRoot() { - Traveller traveller = new ByLevelTraveller<>(dag, new FromRootTraversalDirection()); - - Collection> nodes = traveller.nodes(); - - traveller.next(); - assertThat(nodes, contains(root)); - - traveller.next(); - assertThat(nodes, contains(root, node1, node2)); - - traveller.next(); - assertThat(nodes, contains(root, node1, node2, node3, node4)); - - traveller.next(); - assertThat(nodes, contains(root, node1, node2, node3, node4, node5)); - - traveller.next(); - assertThat(nodes, contains(root, node1, node2, node3, node4, node5, leaf)); - } - - @Test - public void traverseGraphOneLevelPerStepFromLeaf() { - Traveller traveller = new ByLevelTraveller<>(dag, new FromLeafTraversalDirection()); - - Collection> nodes = traveller.nodes(); - - traveller.next(); - assertThat(nodes, contains(leaf)); - - traveller.next(); - assertThat(nodes, contains(leaf, node2, node5)); - - traveller.next(); - assertThat(nodes, contains(leaf, node2, node5, node3, node4)); - - traveller.next(); - assertThat(nodes, contains(leaf, node2, node5, node3, node4, node1)); - - traveller.next(); - assertThat(nodes, contains(leaf, node2, node5, node3, node4, node1, root)); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaExecutionComponentTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaExecutionComponentTest.java deleted file mode 100644 index 8515f93db..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBasedSagaExecutionComponentTest.java +++ /dev/null @@ -1,33 +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.core.dag; - -import java.util.concurrent.Executors; - -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaExecutionComponentTestBase; -import org.apache.servicecomb.saga.core.application.SagaFactory; - - -public class GraphBasedSagaExecutionComponentTest extends SagaExecutionComponentTestBase { - - @Override - protected SagaFactory sagaFactory(PersistentStore eventStore) { - return new GraphBasedSagaFactory(500, eventStore, null, Executors.newFixedThreadPool(5)); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBuilderTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBuilderTest.java deleted file mode 100644 index 9a6c0f806..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphBuilderTest.java +++ /dev/null @@ -1,154 +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.core.dag; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static java.util.Collections.singleton; -import static org.hamcrest.CoreMatchers.startsWith; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.hamcrest.collection.IsIterableContainingInOrder; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import org.apache.servicecomb.saga.core.CompensationImpl; -import org.apache.servicecomb.saga.core.TransactionImpl; - -@SuppressWarnings("unchecked") -public class GraphBuilderTest { - - public static final Map> EMPTY_MAP = Collections.>emptyMap(); - - private final SagaRequest request1 = new SagaRequestImpl( - "request-aaa", - "aaa", - TYPE_REST, - new TransactionImpl("/rest/as", "post", EMPTY_MAP), - new CompensationImpl("/rest/as","delete", EMPTY_MAP) - ); - - private final SagaRequest request2 = new SagaRequestImpl( - "request-bbb", - "bbb", - TYPE_REST, - new TransactionImpl("/rest/bs", "post", EMPTY_MAP), - new CompensationImpl("/rest/bs","delete", EMPTY_MAP) - ); - - private final SagaRequest request3 = new SagaRequestImpl( - "request-ccc", - "ccc", - TYPE_REST, - new TransactionImpl("/rest/cs", "post", EMPTY_MAP), - new CompensationImpl("/rest/cs","delete", EMPTY_MAP), - null, - new String[]{"request-aaa", "request-bbb"} - ); - private final SagaRequest[] requests = {request1, request2, request3}; - - private final SagaRequest duplicateRequest = new SagaRequestImpl( - "request-duplicate-id", - "xxx", - TYPE_REST, - new TransactionImpl("/rest/xs", "post", EMPTY_MAP), - new CompensationImpl("/rest/xs","delete", EMPTY_MAP) - ); - private final SagaRequest[] duplicateRequests = {duplicateRequest, duplicateRequest}; - - private final GraphCycleDetector detector = Mockito.mock(GraphCycleDetector.class); - private final GraphBuilder graphBuilder = new GraphBuilder(detector); - - @Before - public void setUp() throws Exception { - when(detector.cycleJoints((SingleLeafDirectedAcyclicGraph)any())).thenReturn((Set>) Collections.EMPTY_SET); - } - - @Test - public void buildsGraphOfParallelRequests() { - SingleLeafDirectedAcyclicGraph tasks = graphBuilder.build(requests); - - Traveller traveller = new ByLevelTraveller<>(tasks, new FromRootTraversalDirection()); - Collection> nodes = traveller.nodes(); - - traveller.next(); - assertThat(requestsOf(nodes), IsIterableContainingInOrder.contains(NoOpSagaRequest.SAGA_START_REQUEST)); - nodes.clear(); - - traveller.next(); - assertThat(requestsOf(nodes), contains(request1, request2)); - nodes.clear(); - - traveller.next(); - assertThat(requestsOf(nodes), contains(request3)); - nodes.clear(); - - traveller.next(); - assertThat(requestsOf(nodes), IsIterableContainingInOrder.contains(NoOpSagaRequest.SAGA_END_REQUEST)); - } - - @Test - public void blowsUpWhenJsonContainsDuplicateRequestId() { - try { - graphBuilder.build(duplicateRequests); - fail(SagaException.class.getSimpleName() + " is expected, but none thrown"); - } catch (SagaException e) { - assertThat(e.getMessage(), - is("Failed to interpret requests with duplicate request id: request-duplicate-id")); - } - } - - @Test - public void blowsUpWhenGraphContainsCycle() { - reset(detector); - when(detector.cycleJoints((SingleLeafDirectedAcyclicGraph) any())).thenReturn(singleton(new Node(0L, null))); - - try { - graphBuilder.build(requests); - expectFailing(SagaException.class); - } catch (SagaException e) { - assertThat(e.getMessage(), startsWith("Cycle detected in the request graph at nodes ")); - } - } - - private Collection requestsOf(Collection> nodes) { - List result = new ArrayList<>(); - for(Node node: nodes) { - result.add(node.value()); - } - return result; - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorTest.java deleted file mode 100644 index 190beeb0e..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/GraphCycleDetectorTest.java +++ /dev/null @@ -1,72 +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.core.dag; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.util.Set; -import org.junit.Before; -import org.junit.Test; - -@SuppressWarnings("unchecked") -public class GraphCycleDetectorTest { - - private final Node root = node(0); - private final Node leaf = node(Long.MAX_VALUE); - - private final Node node1 = node(1); - private final Node node2 = node(2); - private final Node node3 = node(3); - - private final SingleLeafDirectedAcyclicGraph graph = new SingleLeafDirectedAcyclicGraph<>(root, leaf); - private final GraphCycleDetector detector = new GraphCycleDetectorImpl<>(); - - @Before - public void setUp() throws Exception { - root.addChild(node1); - - node2.addChild(leaf); - node3.addChild(leaf); - } - - @Test - public void emptyNodesWhenNoCycleInGraph() { - node1.addChild(node2); - node1.addChild(node3); - - Set> nodes = detector.cycleJoints(graph); - assertThat(nodes.isEmpty(), is(true)); - } - - @Test - public void nonEmptyNodesIfGraphContainsCycle() { - node1.addChild(node2); - node2.addChild(node3); - node3.addChild(node1); - - Set> nodes = detector.cycleJoints(graph); - - assertThat(nodes, contains(node1)); - } - - private Node node(long id) { - return new Node<>(id, "value " + id); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/NodeTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/NodeTest.java deleted file mode 100644 index 2da4ba0b3..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/core/dag/NodeTest.java +++ /dev/null @@ -1,80 +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.core.dag; - -import static java.util.Arrays.asList; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Before; -import org.junit.Test; - -public class NodeTest { - - - private final Node parent = new Node<>(0, "i don't care"); - private final Node node1 = new Node<>(1, "i don't care"); - private final Node node2 = new Node<>(2, "i don't care"); - private final Node node3 = new Node<>(3, "i don't care"); - private final Node node4 = new Node<>(4, "i don't care"); - private final Node node5 = new Node<>(5, "i don't care"); - private final Node node6 = new Node<>(6, "i don't care"); - - // 0 - // / \ - // 1 \ - // / \ \ - // 3 4 2 - // \ / / - // 5 / - // \ / - // 6 - @Before - public void setUp() throws Exception { - parent.addChildren(asList(node1, node2)); - node1.addChildren(asList(node3, node4)); - node3.addChild(node5); - node4.addChild(node5); - node5.addChild(node6); - node2.addChild(node6); - } - - @Test - public void nodeIsLinkedBidirectionally() { - assertThat(parent.children(), containsInAnyOrder(node1, node2)); - assertThat(node1.parents(), contains(parent)); - assertThat(node1.children(), containsInAnyOrder(node3, node4)); - - assertThat(node2.parents(), contains(parent)); - assertThat(node2.children(), contains(node6)); - - assertThat(node3.parents(), contains(node1)); - assertThat(node3.children(), contains(node5)); - - assertThat(node4.parents(), contains(node1)); - assertThat(node4.children(), contains(node5)); - - assertThat(node5.parents(), containsInAnyOrder(node3, node4)); - assertThat(node5.children(), contains(node6)); - - assertThat(node6.parents(), containsInAnyOrder(node2, node5)); - assertThat(node6.children().isEmpty(), is(true)); - } -} diff --git a/saga-core/src/test/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStoreTest.java b/saga-core/src/test/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStoreTest.java deleted file mode 100644 index 1216e5f14..000000000 --- a/saga-core/src/test/java/org/apache/servicecomb/saga/infrastructure/ContextAwareEventStoreTest.java +++ /dev/null @@ -1,43 +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.infrastructure; - -import static org.mockito.Mockito.verify; - -import org.apache.servicecomb.saga.core.EventStore; -import org.junit.Test; -import org.mockito.Mockito; - -import org.apache.servicecomb.saga.core.SagaContext; -import org.apache.servicecomb.saga.core.SagaEvent; - -public class ContextAwareEventStoreTest { - private final EventStore underlying = Mockito.mock(EventStore.class); - private final SagaContext context = Mockito.mock(SagaContext.class); - private final SagaEvent sagaEvent = Mockito.mock(SagaEvent.class); - - private final ContextAwareEventStore contextAwareEventStore = new ContextAwareEventStore(underlying, context); - - @Test - public void persistWithUnderlyingStore() throws Exception { - contextAwareEventStore.offer(sagaEvent); - - verify(sagaEvent).gatherTo(context); - verify(underlying).offer(sagaEvent); - } -} diff --git a/saga-core/src/test/resources/application.conf b/saga-core/src/test/resources/application.conf deleted file mode 100644 index 0629dd633..000000000 --- a/saga-core/src/test/resources/application.conf +++ /dev/null @@ -1,21 +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. -## --------------------------------------------------------------------------- -akka { - loggers = ["akka.event.slf4j.Slf4jLogger"] - loglevel = "DEBUG" - logging-filter = "akka.event.slf4j.Slf4jLoggingFilter" -} diff --git a/saga-demo/conditional-transaction-demo/README.md b/saga-demo/conditional-transaction-demo/README.md deleted file mode 100755 index 4e62c8e53..000000000 --- a/saga-demo/conditional-transaction-demo/README.md +++ /dev/null @@ -1,177 +0,0 @@ -# Conditional Transaction Demo -This demo simulates a partial backend of an e-commerce application including four services: -* payment -* membership -* inventory -* supplier - -**Note** Please go through the dependency-free-transaction-demo first, before proceeding with this demo. - -## Background -Many e-commerce sites have membership concept, which will level up when a customer makes a certain amount of purchase. -Moreover, as goods are sold and the stock drops to a certain level, the e-commerce company needs to fetch more goods from -its suppliers. Both scenarios introduce conditional transactions. - -## Workflow -``` - /---> if total purchase >= 1K, level up membership -start ---> make payment ---> dispatch product from inventory ---> end - \---> if product stock < 10, replenish product from supplier -``` -The conditions are business logic and belong to business service. Therefore, the decision to level up membership is made -in payment service and the decision to replenish products is made in inventory service. Saga is to be informed of service -decision by adding an additional element `sagaChildren` in service response JSON to indicate which services are to be invoked -next as shown below. -```json -{ - "customerId": "mike", - "body": "Payment made with id xxx for customer mike", - "sagaChildren": ["inventory"] -} -``` - -If `sagaChildren` is empty or not provided in service response, saga will invoke all of its child services. To invoke none -of them, explicitly return `"sagaChildren": ["none"]`. - -If any of the sub-transaction specified in sagaChildren fails, all completed sub-transactions will be compensated as usual, -when the recovery policy if backward recovery. - -## Running Demo -1. run the following command to create docker images in saga project root folder. - ``` - mvn package -DskipTests -Pdocker -Pdemo - ``` - -2. stop application - ``` - ./conditional-transaction-demo.sh down - ``` - -## User Requests -The request JSON to ensure the workflow order looks like the following: -```json -{ - "policy": "BackwardRecovery", - "requests": [ - { - "id": "payment", - "type": "rest", - "serviceName": "payment.servicecomb.io:8080", - "transaction": { - "method": "post", - "path": "/payment", - "params": { - "form": { - "customerId": "mike", - "purchaseAmount": 400 - } - } - }, - "compensation": { - "method": "put", - "path": "/payment", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "membership", - "type": "rest", - "serviceName": "membership.servicecomb.io:8080", - "parents": [ - "payment" - ], - "transaction": { - "method": "post", - "path": "/membership", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/membership", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "inventory", - "type": "rest", - "serviceName": "inventory.servicecomb.io:8080", - "parents": [ - "payment" - ], - "transaction": { - "method": "post", - "path": "/inventory", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/inventory", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "supplier", - "type": "rest", - "serviceName": "supplier.servicecomb.io:8080", - "parents": [ - "inventory" - ], - "transaction": { - "method": "post", - "path": "/supplier", - "params": { - "form": { - "customerId": "servicecomb_mall" - } - } - }, - "compensation": { - "method": "put", - "path": "/supplier", - "params": { - "form": { - "customerId": "servicecomb_mall" - } - } - } - } - ] -} - -``` - -To send the above JSON request to Saga, use [postman](https://www.getpostman.com/postman) with POST request to url `http://:8083/requests` - -Each request to payment service will increase user mike's total purchase by $400. The 3rd request will trigger -membership level up. - -The initial product stock is 11 in inventory and each request to inventory service will deduct product stock by 1. -So the 2nd request will trigger product replenishment from supplier. - -**Note** transactions and compensations implemented by services must be idempotent. In this demo, we did not enforce that -for simplicity. - -To see all events generated by Saga, visit `http://:8083/events` with postman. - -## Debugging -Take the [spring-demo debugging](../saga-spring-demo#debugging) as a reference. diff --git a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml b/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml deleted file mode 100644 index 57a3895f2..000000000 --- a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/pom.xml +++ /dev/null @@ -1,301 +0,0 @@ - - - - - - conditional-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - conditional-transaction-demo-tests - Saga::Demo::Conditional Transaction::Tests - - - - - commons-logging - commons-logging - 1.2 - - - io.rest-assured - rest-assured - test - - - junit - junit - test - - - org.codehaus.groovy - groovy-all - test - - - - - - - io.fabric8 - docker-maven-plugin - - - - postgres - postgres - - - saga - saga - password - - - database system is ready to accept connections - - - 5432 - - - - - - postgres.port:5432 - - - - - payment:${project.version} - payment - - - - - - Tomcat started on port - - - 8080 - - - - - - payment.port:8080 - - - - - membership:${project.version} - membership - - - - - - Tomcat started on port - - - 8080 - - - - - - membership.port:8080 - - - - - inventory:${project.version} - inventory - - - - - - Tomcat started on port - - - 8080 - - - - - - inventory.port:8080 - - - - - supplier:${project.version} - supplier - - - - - - Tomcat started on port - - - 8080 - - - - - - supplier.port:8080 - - - - - saga-spring:${project.version} - saga - - - - -Dspring.profiles.active=prd -Dspring.main.webEnvironment=true - - - - postgres:postgres.servicecomb.io - payment:payment.servicecomb.io - membership:membership.servicecomb.io - inventory:inventory.servicecomb.io - supplier:supplier.servicecomb.io - - - Tomcat started on port - - - 8080 - - - - - - saga.port:8080 - - - postgres - - - - - - - - start - pre-integration-test - - start - - - - stop - post-integration-test - - stop - - - - - - - - - docker - - - - org.codehaus.gmaven - gmaven-plugin - - - add-default-properties - initialize - - execute - - - - project.properties.setProperty('docker.hostname', 'localhost') - log.info("Docker hostname is " + project.properties['docker.hostname']) - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven.failsafe.version} - - - - http://${docker.hostname}:${saga.port} - - - ${jacoco.failsafe.argLine} - - - - - integration-test - verify - - - - - - - - - docker-machine - - - - org.codehaus.gmaven - gmaven-plugin - - - add-dynamic-properties - prepare-package - - execute - - - - def process = "docker-machine ip default".execute() - process.waitFor() - project.properties.setProperty('docker.hostname', process.in.text.trim()) - - log.info("Docker hostname is " + project.properties['docker.hostname']) - - - - - - - - - - - diff --git a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/ConditionalTransactionIT.java b/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/ConditionalTransactionIT.java deleted file mode 100644 index d1734d59a..000000000 --- a/saga-demo/conditional-transaction-demo/conditional-transaction-demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/ConditionalTransactionIT.java +++ /dev/null @@ -1,155 +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.demo.tests; - -import static io.restassured.RestAssured.given; -import static io.restassured.http.ContentType.TEXT; -import static org.hamcrest.core.Is.is; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class ConditionalTransactionIT { - - private static final String requests = "{\n" - + " \"policy\": \"BackwardRecovery\",\n" - + " \"requests\": [\n" - + " {\n" - + " \"id\": \"payment\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"payment.servicecomb.io:8080\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/payment\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\",\n" - + " \"purchaseAmount\": 400\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/payment\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"membership\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"membership.servicecomb.io:8080\",\n" - + " \"parents\": [\n" - + " \"payment\"\n" - + " ],\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/membership\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/membership\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"inventory\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"inventory.servicecomb.io:8080\",\n" - + " \"parents\": [\n" - + " \"payment\"\n" - + " ],\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/inventory\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/inventory\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"supplier\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"supplier.servicecomb.io:8080\",\n" - + " \"parents\": [\n" - + " \"inventory\"\n" - + " ],\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/supplier\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"servicecomb_mall\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/supplier\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"servicecomb_mall\"\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + " ]\n" - + "}\n"; - - private static String sagaAddress; - - @BeforeClass - public static void setUp() throws Exception { - sagaAddress = System.getProperty("saga.address"); - } - - @Test - public void ableToSendRequestsToServicesThroughSaga() { - given() - .contentType(TEXT) - .body(requests) - .when() - .post(sagaAddress + "/requests") - .then() - .statusCode(is(200)) - .body(is("success")); - } -} diff --git a/saga-demo/conditional-transaction-demo/conditional-transaction-demo.sh b/saga-demo/conditional-transaction-demo/conditional-transaction-demo.sh deleted file mode 100755 index 2f0c8fe5f..000000000 --- a/saga-demo/conditional-transaction-demo/conditional-transaction-demo.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# 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. - -service=conditional-transaction-demo - -show_usage() { - echo "Usage: $0 {up|down}" >&2 -} - -fetch_version() { - version="$(printf 'VER\t${project.version}' | mvn help:evaluate | grep '^VER' | cut -f2)" -} - -if [[ -z $1 ]]; then - show_usage - exit 2 -fi - -case $1 in - up) - fetch_version - echo "Starting ${service}:${version}" - TAG=$version docker-compose up - exit $? - ;; - - down) - fetch_version - echo "Stopping ${service}:${version}" - TAG=$version docker-compose down - exit $? - ;; - - *) - show_usage - exit 2 - ;; -esac - diff --git a/saga-demo/conditional-transaction-demo/docker-compose.yaml b/saga-demo/conditional-transaction-demo/docker-compose.yaml deleted file mode 100755 index c9eb9f4c2..000000000 --- a/saga-demo/conditional-transaction-demo/docker-compose.yaml +++ /dev/null @@ -1,75 +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. -## --------------------------------------------------------------------------- - -version: '2.1' - -services: - postgres: - image: "postgres" - hostname: postgres - environment: - - POSTGRES_DB=saga - - POSTGRES_USER=saga - - POSTGRES_PASSWORD=password - ports: - - "5432:5432" - healthcheck: - test: ["CMD-SHELL", "nc -z localhost 5432 &> /dev/null; echo $$?"] - interval: 30s - timeout: 10s - retries: 5 - - payment: - image: "payment:${TAG}" - hostname: payment - ports: - - "8080" - - membership: - image: "membership:${TAG}" - hostname: membership - ports: - - "8080" - - inventory: - image: "inventory:${TAG}" - hostname: inventory - ports: - - "8080" - - supplier: - image: "supplier:${TAG}" - hostname: supplier - ports: - - "8080" - - saga: - image: "saga-spring:${TAG}" - hostname: saga - links: - - "postgres:postgres.servicecomb.io" - - "payment:payment.servicecomb.io" - - "membership:membership.servicecomb.io" - - "inventory:inventory.servicecomb.io" - - "supplier:supplier.servicecomb.io" - environment: - - JAVA_OPTS=-Dspring.profiles.active=prd -Dspring.main.webEnvironment=true - ports: - - "8083:8080" - depends_on: - postgres: - condition: service_healthy diff --git a/saga-demo/conditional-transaction-demo/inventory/pom.xml b/saga-demo/conditional-transaction-demo/inventory/pom.xml deleted file mode 100644 index 12fca4202..000000000 --- a/saga-demo/conditional-transaction-demo/inventory/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - conditional-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - inventory - Saga::Demo::Conditional Transaction::Inventory - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryApplication.java b/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryApplication.java deleted file mode 100644 index f0b8e68dc..000000000 --- a/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryApplication.java +++ /dev/null @@ -1,29 +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.demo.conditional.transaction.inventory; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class InventoryApplication { - - public static void main(String[] args) { - SpringApplication.run(InventoryApplication.class, args); - } -} diff --git a/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryController.java b/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryController.java deleted file mode 100644 index 1f829555b..000000000 --- a/saga-demo/conditional-transaction-demo/inventory/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryController.java +++ /dev/null @@ -1,89 +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.demo.conditional.transaction.inventory; - -import static org.springframework.http.HttpStatus.BAD_REQUEST; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.io.IOException; -import java.util.UUID; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -@Controller -@RequestMapping("/") -public class InventoryController { - private static final int FETCH_THRESHOLD = 10; - private static final String CUSTOMER_ID = "customerId"; - private final ObjectMapper objectMapper = new ObjectMapper(); - - private int stock = 11; - - @RequestMapping(value = "inventory", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity dispatch(@RequestParam String response) { - try { - ObjectNode jsonNodes = objectMapper.readValue(response, ObjectNode.class); - if (jsonNodes.has(CUSTOMER_ID)) { - String customerId = jsonNodes.get(CUSTOMER_ID).textValue(); - - stock--; - if (isStockShort()) { - // when no sagaChildren is provided, all child sub-transaction of inventory will be run - return response(customerId, ""); - } - - // select no child sub-transaction to run next, by specifying none in sagaChildren - return response(customerId,", \"sagaChildren\": [\"none\"] \n"); - } - return new ResponseEntity<>("Customer Id is missing", BAD_REQUEST); - } catch (IOException e) { - return new ResponseEntity<>(e.getMessage(), INTERNAL_SERVER_ERROR); - } - } - - @RequestMapping(value = "inventory", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity recall(@RequestParam String customerId) { - stock++; - return ResponseEntity.ok(String.format("Dispatch recalled with id %s for customer %s", - UUID.randomUUID().toString(), - customerId)); - } - - private ResponseEntity response(String customerId, String optionalSagaChildren) { - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Goods dispatched with id %s for customer %s\"\n" - + optionalSagaChildren - + "}", - UUID.randomUUID().toString(), - customerId)); - } - - private boolean isStockShort() { - return stock < FETCH_THRESHOLD; - } -} diff --git a/saga-demo/conditional-transaction-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryControllerTest.java b/saga-demo/conditional-transaction-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryControllerTest.java deleted file mode 100644 index d58a6100f..000000000 --- a/saga-demo/conditional-transaction-demo/inventory/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/inventory/InventoryControllerTest.java +++ /dev/null @@ -1,79 +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.demo.conditional.transaction.inventory; - -import static org.hamcrest.core.Is.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -@RunWith(SpringRunner.class) -@WebMvcTest(InventoryController.class) -public class InventoryControllerTest { - private static final String content = "response=" + encode("{\n" - + " \"customerId\": \"mike\",\n" - + " \"foo\": \"bar\"\n" - + "}"); - - private static String encode(String param) { - try { - return URLEncoder.encode(param, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new IllegalArgumentException(e); - } - } - - @Autowired - private MockMvc mockMvc; - - @Test - public void respondWithChildren_IfStockIsLowerThanThreshold() throws Exception { - mockMvc.perform(post("/inventory") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(content)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.sagaChildren[0]", is("none"))); - - mockMvc.perform(post("/inventory") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(content)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.sagaChildren[0]").doesNotExist()); - } - - @Test - public void badRequestIfCustomerIdIsNotInRequestContent() throws Exception { - String content = "response=" + encode("{}"); - - mockMvc.perform(post("/inventory") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(content)) - .andExpect(status().isBadRequest()); - } -} diff --git a/saga-demo/conditional-transaction-demo/membership/pom.xml b/saga-demo/conditional-transaction-demo/membership/pom.xml deleted file mode 100644 index 52b04e836..000000000 --- a/saga-demo/conditional-transaction-demo/membership/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - conditional-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - membership - Saga::Demo::Conditional Transaction::Membership - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - diff --git a/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipApplication.java b/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipApplication.java deleted file mode 100644 index 4be730010..000000000 --- a/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipApplication.java +++ /dev/null @@ -1,29 +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.demo.conditional.transaction.membership; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class MembershipApplication { - - public static void main(String[] args) { - SpringApplication.run(MembershipApplication.class, args); - } -} diff --git a/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipController.java b/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipController.java deleted file mode 100644 index f7efc3934..000000000 --- a/saga-demo/conditional-transaction-demo/membership/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/membership/MembershipController.java +++ /dev/null @@ -1,62 +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.demo.conditional.transaction.membership; - -import static java.util.Collections.singleton; -import static org.springframework.http.HttpStatus.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.util.Set; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -@RequestMapping("/") -public class MembershipController { - - private final Set customers = singleton("mike"); - - @RequestMapping(value = "membership", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity levelUp(@RequestParam String customerId) { - if (!customers.contains(customerId)) { - return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); - } - - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Level up customer %s to silver member\"\n" - + "}", - customerId)); - } - - @RequestMapping(value = "membership", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity levelDown(@RequestParam String customerId) { - if (!customers.contains(customerId)) { - return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); - } - - return ResponseEntity.ok(String.format("Level down customer %s to bronze member", - customerId)); - } - -} diff --git a/saga-demo/conditional-transaction-demo/payment/pom.xml b/saga-demo/conditional-transaction-demo/payment/pom.xml deleted file mode 100644 index 21ce51f44..000000000 --- a/saga-demo/conditional-transaction-demo/payment/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - conditional-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - payment - Saga::Demo::Conditional Transaction::Payment - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentApplication.java b/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentApplication.java deleted file mode 100644 index 7e0a643bb..000000000 --- a/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentApplication.java +++ /dev/null @@ -1,29 +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.demo.conditional.transaction.payment; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class PaymentApplication { - - public static void main(String[] args) { - SpringApplication.run(PaymentApplication.class, args); - } -} diff --git a/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentController.java b/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentController.java deleted file mode 100644 index 531414b07..000000000 --- a/saga-demo/conditional-transaction-demo/payment/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentController.java +++ /dev/null @@ -1,84 +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.demo.conditional.transaction.payment; - -import static java.util.Collections.singletonMap; -import static org.springframework.http.HttpStatus.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -@RequestMapping("/") -public class PaymentController { - private static final int UPGRADE_THRESHOLD = 1000; - - private final Map customerPurchases = new HashMap<>(singletonMap("mike", 0)); - - @RequestMapping(value = "payment", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity purchase(@RequestParam String customerId, @RequestParam int purchaseAmount) { - if (!customerPurchases.containsKey(customerId)) { - return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); - } - - customerPurchases.compute(customerId, (id, purchases) -> purchases + purchaseAmount); - - if (isUpgradable(customerId)) { - // when no sagaChildren is provided, all child sub-transaction of payment will be run - return response(customerId, ""); - } - - // select only sub-transaction of inventory service to run next, by specifying inventory in sagaChildren - return response(customerId, ", \"sagaChildren\": [\"inventory\"] \n"); - } - - @RequestMapping(value = "payment", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity refund(@RequestParam String customerId) { - if (!customerPurchases.containsKey(customerId)) { - return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); - } - - return ResponseEntity.ok(String.format("Payment refunded with id %s for customer %s", - UUID.randomUUID().toString(), - customerId)); - } - - private ResponseEntity response(String customerId, String optionalSagaChildren) { - return ResponseEntity.ok(String.format("{\n" - + " \"customerId\": \"mike\",\n" - + " \"body\": \"Payment made with id %s for customer %s\"\n" - + optionalSagaChildren - + "}", - UUID.randomUUID().toString(), - customerId)); - } - - private boolean isUpgradable(String customerId) { - return customerPurchases.get(customerId) >= UPGRADE_THRESHOLD; - } -} diff --git a/saga-demo/conditional-transaction-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentControllerTest.java b/saga-demo/conditional-transaction-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentControllerTest.java deleted file mode 100644 index 99e61871e..000000000 --- a/saga-demo/conditional-transaction-demo/payment/src/test/java/org/apache/servicecomb/saga/demo/conditional/transaction/payment/PaymentControllerTest.java +++ /dev/null @@ -1,61 +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.demo.conditional.transaction.payment; - -import static org.hamcrest.core.Is.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.http.MediaType; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; - -@RunWith(SpringRunner.class) -@WebMvcTest(PaymentController.class) -public class PaymentControllerTest { - private static final String requestContent = "customerId=mike&purchaseAmount=400"; - - @Autowired - private MockMvc mockMvc; - - @Test - public void respondWithChildren_IfTotalPurchaseIsLowerThanThreshold() throws Exception { - mockMvc.perform(post("/payment") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(requestContent)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.sagaChildren[0]", is("inventory"))); - - mockMvc.perform(post("/payment") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(requestContent)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.sagaChildren[0]", is("inventory"))); - - mockMvc.perform(post("/payment") - .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .content(requestContent)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.sagaChildren[0]").doesNotExist()); - } -} diff --git a/saga-demo/conditional-transaction-demo/pom.xml b/saga-demo/conditional-transaction-demo/pom.xml deleted file mode 100644 index ac5f4ca50..000000000 --- a/saga-demo/conditional-transaction-demo/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - saga-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - conditional-transaction-demo - Saga::Demo::Conditional Transaction - pom - - - payment - membership - inventory - supplier - conditional-transaction-demo-tests - - - - diff --git a/saga-demo/conditional-transaction-demo/supplier/pom.xml b/saga-demo/conditional-transaction-demo/supplier/pom.xml deleted file mode 100644 index 5220e519c..000000000 --- a/saga-demo/conditional-transaction-demo/supplier/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - conditional-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - supplier - Saga::Demo::Conditional Transaction::Supplier - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - diff --git a/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierApplication.java b/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierApplication.java deleted file mode 100644 index e6729d921..000000000 --- a/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierApplication.java +++ /dev/null @@ -1,29 +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.demo.conditional.transaction.supplier; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SupplierApplication { - - public static void main(String[] args) { - SpringApplication.run(SupplierApplication.class, args); - } -} diff --git a/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierController.java b/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierController.java deleted file mode 100644 index bd71070c5..000000000 --- a/saga-demo/conditional-transaction-demo/supplier/src/main/java/org/apache/servicecomb/saga/demo/conditional/transaction/supplier/SupplierController.java +++ /dev/null @@ -1,52 +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.demo.conditional.transaction.supplier; - -import static java.util.Collections.singleton; -import static org.springframework.http.HttpStatus.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -import java.util.Set; -import java.util.UUID; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -@Controller -@RequestMapping("/") -public class SupplierController { - - private final Set customers = singleton("servicecomb_mall"); - - @RequestMapping(value = "supplier", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity supply(@RequestParam String customerId) { - if (!customers.contains(customerId)) { - return new ResponseEntity<>("No such customer with id " + customerId, FORBIDDEN); - } - - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Goods supply with id %s on the way for customer %s\"\n" - + "}", - UUID.randomUUID().toString(), - customerId)); - } -} diff --git a/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/LICENSE.txt b/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/LICENSE.txt deleted file mode 100644 index d64569567..000000000 --- a/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/NOTICE.txt b/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/NOTICE.txt deleted file mode 100644 index 2e215bf2e..000000000 --- a/saga-demo/conditional-transaction-demo/supplier/src/main/resources/META-INF/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Camel distribution. == - ========================================================================= - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - Please read the different LICENSE files present in the licenses directory of - this distribution. diff --git a/saga-demo/dependency-free-transaction-demo/README.md b/saga-demo/dependency-free-transaction-demo/README.md deleted file mode 100755 index c6c5f6a65..000000000 --- a/saga-demo/dependency-free-transaction-demo/README.md +++ /dev/null @@ -1,170 +0,0 @@ -# Dependency Free Transaction Demo -This demo simulates a bare minimal travel application including four services: -* car rental -* flight booking -* hotel reservation -* payment - -## Background -A user with travel plans may like making car rental, flight booking, and hotel reservation with just a single service -instead of three separate services. That's why this application can help. - -With microservice architecture, each of the services may have its own database technology and it's not feasible to ensure -all transactions on these services are either committed or rolled back with database. In this demo, we make use of Saga to -ensure eventual data consistency among services. - -## Architecture - -``` - - /----> car rental service -User ---> Saga -----> flight booking service - \----> hotel reservation service - \---> payment service -``` - -## Running Demo -1. run the following command to create docker images in saga project root folder. - ``` - mvn package -DskipTests -Pdocker -Pdemo - ``` -2. stop application - ``` - ./dependency-free-transaction-demo.sh down - ``` - -## User Requests -A user normally expects to make payment only when transactions with all three services are completed successfully. So Saga -will talk to car rental, flight booking, and hotel reservation services in parallel and then payment service only when the -former three services return success. - -The request JSON to ensure this process order looks like the following: -```json -{ - "policy": "BackwardRecovery", - "requests": [ - { - "id": "request-car", - "type": "rest", - "serviceName": "car-rental-service", - "transaction": { - "method": "post", - "path": "/rentals", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/rentals", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "request-hotel", - "type": "rest", - "serviceName": "hotel-reservation-service", - "transaction": { - "method": "post", - "path": "/reservations", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/reservations", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "request-flight", - "type": "rest", - "serviceName": "flight-booking-service", - "transaction": { - "method": "post", - "path": "/bookings", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/bookings", - "params": { - "form": { - "customerId": "mike" - } - } - } - }, - { - "id": "request-payment", - "type": "rest", - "serviceName": "saga-crossapp:payment-service", - "parents": [ - "request-car", - "request-flight", - "request-hotel" - ], - "transaction": { - "method": "post", - "path": "/payments", - "params": { - "form": { - "customerId": "mike" - } - } - }, - "compensation": { - "method": "put", - "path": "/payments", - "params": { - "form": { - "customerId": "mike" - } - } - } - } - ] -} -``` - -The key to the request dependency lies in definition of parents field in the payment request. It means the payment request -is only executed after `request-car` , `request-flight` , and `request-hotel` are completed. -``` - "id": "request-payment", - "type": "rest", - "serviceName": "payment.servicecomb.io:8080", - "parents": [ - "request-car", // request id to car service in the full request json - "request-flight", // request id to flight service in the full request json - "request-hotel" // request id to hotel service in the full request json - ] -``` - -To send the above JSON request to Saga, use [postman](https://www.getpostman.com/postman) with POST request to url `http://:8083/requests` - -Sending the request more than once will trigger compensation due to insufficient account balance in payment-service. - -**Note** transactions and compensations implemented by services must be idempotent. In this demo, we did not enforce that -for simplicity. - -To see all events generated by Saga, visit `http://:8083/events` with browser. - -## Debugging -Take the [spring-demo debugging](../saga-spring-demo#debugging) as a reference. diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/pom.xml b/saga-demo/dependency-free-transaction-demo/car-rental-service/pom.xml deleted file mode 100644 index bf0267313..000000000 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - dependency-free-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - car-rental-service - Saga::Demo::Dependency Free Transaction::Car Rental Service - - - - - org.apache.servicecomb - spring-boot-starter-provider - - - log4j - log4j - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java deleted file mode 100644 index ae9e5e59b..000000000 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalApplication.java +++ /dev/null @@ -1,32 +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.demo.car.rental; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@SpringBootApplication -@EnableServiceComb -public class CarRentalApplication { - - public static void main(String[] args) { - SpringApplication.run(CarRentalApplication.class, args); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java deleted file mode 100644 index 68580e2cf..000000000 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/java/org/apache/servicecomb/saga/demo/car/rental/CarRentalController.java +++ /dev/null @@ -1,100 +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.demo.car.rental; - -import static java.util.Arrays.asList; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.lang.invoke.MethodHandles; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Controller -@RequestMapping("/") -@RestSchema(schemaId = "car-endpoint") -public class CarRentalController { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final Set customers = new HashSet<>(asList("mike", "snail")); - private int delay = 60; - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "rentals", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity rent(@RequestAttribute String customerId) { - log.info("Received car rental request from customer {}", customerId); - if (!customers.contains(customerId)) { - log.info("No such customer {}", customerId); - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - if ("snail".equals(customerId)) { - try { - log.info("Encountered extremely slow customer {}", customerId); - int timeout = delay; - delay = 0; - TimeUnit.SECONDS.sleep(timeout); - log.info("Finally served the extremely slow customer {}", customerId); - } catch (InterruptedException e) { - return new ResponseEntity<>("Interrupted", INTERNAL_SERVER_ERROR); - } - } - - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Car rented with id %s for customer %s\"\n" - + "}", - UUID.randomUUID().toString(), - customerId)); - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "rentals", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity cancel(@RequestAttribute String customerId) { - if (!customers.contains(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - return ResponseEntity.ok(String.format("Car rental cancelled with id %s for customer %s", - UUID.randomUUID().toString(), - customerId)); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml deleted file mode 100644 index 0c47d2f35..000000000 --- a/saga-demo/dependency-free-transaction-demo/car-rental-service/src/main/resources/microservice.yaml +++ /dev/null @@ -1,30 +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. -## --------------------------------------------------------------------------- -APPLICATION_ID: saga -service_description: - name: car-rental-service - version: 0.0.1 -servicecomb: - service: - registry: - address: http://sc.servicecomb.io:30100 - rest: - address: 0.0.0.0:8080 - handler: - chain: - Consumer: - default: loadbalance diff --git a/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml b/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml deleted file mode 100644 index 51196bf61..000000000 --- a/saga-demo/dependency-free-transaction-demo/demo-tests/pom.xml +++ /dev/null @@ -1,333 +0,0 @@ - - - - - - dependency-free-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - demo-tests - Saga::Demo::Dependency Free Transaction:: Tests - - - - - commons-logging - commons-logging - 1.2 - - - io.rest-assured - rest-assured - test - - - junit - junit - test - - - org.codehaus.groovy - groovy-all - test - - - - - - - io.fabric8 - docker-maven-plugin - - - - servicecomb/service-center:latest - service-center - - - Local listen address - - - 30100 - - - - - - service.center.port:30100 - - - - - postgres - postgres - - - saga - saga - password - - - database system is ready to accept connections - - - 5432 - - - - - - postgres.port:5432 - - - - - car-rental-service:${project.version} - car - - - - - - Started [a-zA-Z]+ in [0-9.]+ seconds - - - 8080 - - - - - - service-center:sc.servicecomb.io - - - car.port:8080 - - - - - flight-booking-service:${project.version} - flight - - - - - - Started [a-zA-Z]+ in [0-9.]+ seconds - - - 8080 - - - - - - service-center:sc.servicecomb.io - - - flight.port:8080 - - - - - hotel-reservation-service:${project.version} - hotel - - - - - - Started [a-zA-Z]+ in [0-9.]+ seconds - - - 8080 - - - - - - service-center:sc.servicecomb.io - - - hotel.port:8080 - - - - - payment-service:${project.version} - payment - - - - - - Started [a-zA-Z]+ in [0-9.]+ seconds - - - 8080 - - - - - - service-center:sc.servicecomb.io - - - payment.port:8080 - - - - - saga-spring:${project.version} - saga - - - - -Dspring.profiles.active=prd,servicecomb - -Dcse.service.registry.address=http://sc.servicecomb.io:30100 - - - - service-center:sc.servicecomb.io - postgres:postgres.servicecomb.io - car:car.servicecomb.io - flight:flight.servicecomb.io - hotel:hotel.servicecomb.io - payment:payment.servicecomb.io - - - Started [a-zA-Z]+ in [0-9.]+ seconds - - - 8080 - - - - - - saga.port:8080 - - - postgres - - - - - - - - start - pre-integration-test - - start - - - - stop - post-integration-test - - stop - - - - - - - - - docker - - - - org.codehaus.gmaven - gmaven-plugin - - - add-default-properties - initialize - - execute - - - - project.properties.setProperty('docker.hostname', 'localhost') - log.info("Docker hostname is " + project.properties['docker.hostname']) - - - - - - - org.apache.maven.plugins - maven-failsafe-plugin - ${maven.failsafe.version} - - - - http://${docker.hostname}:${saga.port} - - - ${jacoco.failsafe.argLine} - - - - - integration-test - verify - - - - - - - - - docker-machine - - - - org.codehaus.gmaven - gmaven-plugin - - - add-dynamic-properties - prepare-package - - execute - - - - def process = "docker-machine ip default".execute() - process.waitFor() - project.properties.setProperty('docker.hostname', process.in.text.trim()) - - log.info("Docker hostname is " + project.properties['docker.hostname']) - - - - - - - - - - - diff --git a/saga-demo/dependency-free-transaction-demo/demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/DemoIT.java b/saga-demo/dependency-free-transaction-demo/demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/DemoIT.java deleted file mode 100644 index 750b1e4c6..000000000 --- a/saga-demo/dependency-free-transaction-demo/demo-tests/src/test/java/org/apache/servicecomb/saga/demo/tests/DemoIT.java +++ /dev/null @@ -1,150 +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.demo.tests; - -import static io.restassured.RestAssured.given; -import static io.restassured.http.ContentType.TEXT; -import static org.hamcrest.core.Is.is; - -import org.junit.BeforeClass; -import org.junit.Test; - -public class DemoIT { - - private static final String requests = "{\n" - + " \"policy\": \"BackwardRecovery\",\n" - + " \"requests\": [\n" - + " {\n" - + " \"id\": \"request-car\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"car-rental-service\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rentals\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/rentals\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-hotel\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"hotel-reservation-service\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/reservations\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/reservations\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-flight\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"flight-booking-service\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/bookings\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/bookings\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-payment\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"saga-crossapp:payment-service\",\n" - + " \"parents\": [\n" - + " \"request-car\",\n" - + " \"request-flight\",\n" - + " \"request-hotel\"\n" - + " ],\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/payments\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"put\",\n" - + " \"path\": \"/payments\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"customerId\": \"mike\"\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + " ]\n" - + "}\n"; - - private static String sagaAddress; - - @BeforeClass - public static void setUp() throws Exception { - sagaAddress = System.getProperty("saga.address"); - } - - @Test - public void ableToSendRequestsToServicesThroughSaga() { - given() - .contentType(TEXT) - .body(requests) - .when() - .post(sagaAddress + "/requests") - .then() - .statusCode(is(200)) - .body(is("success")); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/dependency-free-transaction-demo.sh b/saga-demo/dependency-free-transaction-demo/dependency-free-transaction-demo.sh deleted file mode 100755 index d0aa52b79..000000000 --- a/saga-demo/dependency-free-transaction-demo/dependency-free-transaction-demo.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env bash - -# 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. - -service=dependency-free-transaction-demo - -show_usage() { - echo "Usage: $0 {up|down}" >&2 -} - -fetch_version() { - version="$(printf 'VER\t${project.version}' | mvn help:evaluate | grep '^VER' | cut -f2)" -} - -if [[ -z $1 ]]; then - show_usage - exit 2 -fi - -case $1 in - up) - fetch_version - echo "Starting ${service}:${version}" - TAG=$version docker-compose up - exit $? - ;; - - down) - fetch_version - echo "Stopping ${service}:${version}" - TAG=$version docker-compose down - exit $? - ;; - - *) - show_usage - exit 2 - ;; -esac - diff --git a/saga-demo/dependency-free-transaction-demo/docker-compose.yaml b/saga-demo/dependency-free-transaction-demo/docker-compose.yaml deleted file mode 100755 index 4c85dda13..000000000 --- a/saga-demo/dependency-free-transaction-demo/docker-compose.yaml +++ /dev/null @@ -1,101 +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. -## --------------------------------------------------------------------------- - -version: '2.1' - -services: - service-center: - image: "servicecomb/service-center" - hostname: service-center - ports: - - "30100:30100" - - postgres: - image: "postgres" - hostname: postgres - environment: - - POSTGRES_DB=saga - - POSTGRES_USER=saga - - POSTGRES_PASSWORD=password - ports: - - "5432:5432" - healthcheck: - test: ["CMD-SHELL", "nc -z localhost 5432 &> /dev/null; echo $$?"] - interval: 30s - timeout: 10s - retries: 5 - - car-rental-service: - image: "car-rental-service:${TAG}" - hostname: car - links: - - "service-center:sc.servicecomb.io" - ports: - - "8080" - - flight-booking-service: - image: "flight-booking-service:${TAG}" - hostname: flight - links: - - "service-center:sc.servicecomb.io" - ports: - - "8080" - - hotel-reservation-service: - image: "hotel-reservation-service:${TAG}" - hostname: hotel - links: - - "service-center:sc.servicecomb.io" - ports: - - "8080" - - payment-service: - image: "payment-service:${TAG}" - hostname: payment - links: - - "service-center:sc.servicecomb.io" - ports: - - "8080" - - saga: - image: "saga-spring:${TAG}" - hostname: saga - links: - - "postgres:postgres.servicecomb.io" - - "service-center:sc.servicecomb.io" - - "car-rental-service:car.servicecomb.io" - - "flight-booking-service:flight.servicecomb.io" - - "hotel-reservation-service:hotel.servicecomb.io" - - "payment-service:payment.servicecomb.io" - environment: - - JAVA_OPTS=-Dspring.profiles.active=prd,servicecomb -Dcse.service.registry.address=http://sc.servicecomb.io:30100 - ports: - - "8083:8080" - depends_on: - postgres: - condition: service_healthy - - web: - image: "saga-web:${TAG}" - hostname: web - links: - - "service-center:sc.servicecomb.io" - - "saga:saga.servicecomb.io" - environment: - - JAVA_OPTS=-Dspring.profiles.active=prd,servicecomb -Dcse.service.registry.address=http://sc.servicecomb.io:30100 - ports: - - "8888:8888" diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/pom.xml b/saga-demo/dependency-free-transaction-demo/flight-booking-service/pom.xml deleted file mode 100644 index 2897db87c..000000000 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - dependency-free-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - flight-booking-service - Saga::Demo::Dependency Free Transaction::Flight Booking Service - - - - - org.apache.servicecomb - spring-boot-starter-provider - - - log4j - log4j - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java deleted file mode 100644 index d4a514c45..000000000 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingApplication.java +++ /dev/null @@ -1,32 +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.demo.flight.booking; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@SpringBootApplication -@EnableServiceComb -public class FlightBookingApplication { - - public static void main(String[] args) { - SpringApplication.run(FlightBookingApplication.class, args); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingController.java b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingController.java deleted file mode 100644 index beb37dfd5..000000000 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/java/org/apache/servicecomb/saga/demo/flight/booking/FlightBookingController.java +++ /dev/null @@ -1,77 +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.demo.flight.booking; - -import static java.util.Collections.singleton; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.util.Set; -import java.util.UUID; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Controller -@RequestMapping("/") -@RestSchema(schemaId = "flight-endpoint") -public class FlightBookingController { - private final Set customers = singleton("mike"); - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "bookings", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity book(@RequestAttribute String customerId) { - if (!customers.contains(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Flight booked with id %s for customer %s\"\n" - + "}", - UUID.randomUUID().toString(), - customerId)); - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "bookings", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity cancel(@RequestAttribute String customerId) { - if (!customers.contains(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - return ResponseEntity.ok(String.format("Flight booking cancelled with id %s for customer %s", - UUID.randomUUID().toString(), - customerId)); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml deleted file mode 100644 index d2dd30229..000000000 --- a/saga-demo/dependency-free-transaction-demo/flight-booking-service/src/main/resources/microservice.yaml +++ /dev/null @@ -1,30 +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. -## --------------------------------------------------------------------------- -APPLICATION_ID: saga -service_description: - name: flight-booking-service - version: 0.0.1 -servicecomb: - service: - registry: - address: http://sc.servicecomb.io:30100 - rest: - address: 0.0.0.0:8080 - handler: - chain: - Consumer: - default: loadbalance diff --git a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/pom.xml b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/pom.xml deleted file mode 100644 index c17db001a..000000000 --- a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - dependency-free-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - hotel-reservation-service - Saga::Demo::Dependency Free Transaction::Hotel Reservation Service - - - - - org.apache.servicecomb - spring-boot-starter-provider - - - log4j - log4j - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationApplication.java b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationApplication.java deleted file mode 100644 index 174e339df..000000000 --- a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationApplication.java +++ /dev/null @@ -1,32 +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.demo.hotel.reservation; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@SpringBootApplication -@EnableServiceComb -public class HotelReservationApplication { - - public static void main(String[] args) { - SpringApplication.run(HotelReservationApplication.class, args); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationController.java b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationController.java deleted file mode 100644 index 1342c6d7c..000000000 --- a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/java/org/apache/servicecomb/saga/demo/hotel/reservation/HotelReservationController.java +++ /dev/null @@ -1,78 +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.demo.hotel.reservation; - -import static java.util.Collections.singleton; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import java.util.Set; -import java.util.UUID; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Controller -@RequestMapping("/") -@RestSchema(schemaId = "hotel-endpoint") -public class HotelReservationController { - - private final Set customers = singleton("mike"); - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "reservations", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity reserve(@RequestAttribute String customerId) { - if (!customers.contains(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Hotel reserved with id %s for customer %s\"\n" - + "}", - UUID.randomUUID().toString(), - customerId)); - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "reservations", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity cancel(@RequestAttribute String customerId) { - if (!customers.contains(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - return ResponseEntity.ok(String.format("Hotel reservation cancelled with id %s for customer %s", - UUID.randomUUID().toString(), - customerId)); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml deleted file mode 100644 index 4342d6c9e..000000000 --- a/saga-demo/dependency-free-transaction-demo/hotel-reservation-service/src/main/resources/microservice.yaml +++ /dev/null @@ -1,30 +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. -## --------------------------------------------------------------------------- -APPLICATION_ID: saga -service_description: - name: hotel-reservation-service - version: 0.0.1 -servicecomb: - service: - registry: - address: http://sc.servicecomb.io:30100 - rest: - address: 0.0.0.0:8080 - handler: - chain: - Consumer: - default: loadbalance diff --git a/saga-demo/dependency-free-transaction-demo/payment-service/pom.xml b/saga-demo/dependency-free-transaction-demo/payment-service/pom.xml deleted file mode 100644 index 07cd8970b..000000000 --- a/saga-demo/dependency-free-transaction-demo/payment-service/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - dependency-free-transaction-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - payment-service - Saga::Demo::Dependency Free Transaction::Payment Service - - - - - org.apache.servicecomb - spring-boot-starter-provider - - - log4j - log4j - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-web - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - - diff --git a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentApplication.java b/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentApplication.java deleted file mode 100644 index 450bd0ce1..000000000 --- a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentApplication.java +++ /dev/null @@ -1,32 +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.demo.payment; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@SpringBootApplication -@EnableServiceComb -public class PaymentApplication { - - public static void main(String[] args) { - SpringApplication.run(PaymentApplication.class, args); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentController.java b/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentController.java deleted file mode 100644 index 6ed24a3df..000000000 --- a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/java/org/apache/servicecomb/saga/demo/payment/PaymentController.java +++ /dev/null @@ -1,81 +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.demo.payment; - -import static javax.ws.rs.core.Response.Status.BAD_REQUEST; -import static javax.ws.rs.core.Response.Status.FORBIDDEN; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -@Controller -@RequestMapping("/") -@RestSchema(schemaId = "payment-endpoint") -public class PaymentController { - private int balance = 1000; - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user"), - @ApiResponse(code = 400, response = String.class, message = "insufficient account balance") - }) - @RequestMapping(value = "payments", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity pay(@RequestAttribute String customerId) { - if ("anonymous".equals(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - if (balance < 800) { - throw new InvocationException(BAD_REQUEST, "Not enough balance in account of customer " + customerId); - } - - balance -= 800; - return ResponseEntity.ok(String.format("{\n" - + " \"body\": \"Payment made for customer %s and remaining balance is %d\"\n" - + "}", - customerId, - balance)); - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "authenticated user"), - @ApiResponse(code = 403, response = String.class, message = "unauthenticated user") - }) - @RequestMapping(value = "payments", method = PUT, consumes = APPLICATION_FORM_URLENCODED_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity refund(@RequestAttribute String customerId) { - if ("anonymous".equals(customerId)) { - throw new InvocationException(FORBIDDEN, "No such customer with id " + customerId); - } - - balance += 800; - return ResponseEntity.ok(String.format("Payment refunded for customer %s and remaining balance is %d", - customerId, - balance)); - } -} diff --git a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/resources/microservice.yaml b/saga-demo/dependency-free-transaction-demo/payment-service/src/main/resources/microservice.yaml deleted file mode 100644 index e520f9af0..000000000 --- a/saga-demo/dependency-free-transaction-demo/payment-service/src/main/resources/microservice.yaml +++ /dev/null @@ -1,32 +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. -## --------------------------------------------------------------------------- -APPLICATION_ID: saga-crossapp -service_description: - name: payment-service - version: 0.0.1 - properties: - allowCrossApp: true -cse: - service: - registry: - address: http://sc.servicecomb.io:30100 - rest: - address: 0.0.0.0:8080 - handler: - chain: - Consumer: - default: loadbalance diff --git a/saga-demo/dependency-free-transaction-demo/pom.xml b/saga-demo/dependency-free-transaction-demo/pom.xml deleted file mode 100644 index abdbc6413..000000000 --- a/saga-demo/dependency-free-transaction-demo/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - saga-demo - org.apache.servicecomb.saga.demo - 0.3.0-SNAPSHOT - - 4.0.0 - - dependency-free-transaction-demo - Saga::Demo::Dependency Free Transaction - pom - - - - - org.apache.servicecomb - spring-boot-starter-provider - ${java.chassis.version} - - - com.google.code.findbugs - annotations - - - - - org.apache.servicecomb - java-chassis-dependencies - ${java.chassis.version} - pom - import - - - - - - car-rental-service - flight-booking-service - hotel-reservation-service - payment-service - demo-tests - - - diff --git a/saga-demo/tcc-spring-demo/ordering/src/main/resources/log4j2.xml b/saga-demo/tcc-spring-demo/ordering/src/main/resources/log4j2.xml deleted file mode 100644 index cae04cb93..000000000 --- a/saga-demo/tcc-spring-demo/ordering/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/saga-demo/tcc-spring-demo/payment/src/main/resources/log4j2.xml b/saga-demo/tcc-spring-demo/payment/src/main/resources/log4j2.xml deleted file mode 100644 index cae04cb93..000000000 --- a/saga-demo/tcc-spring-demo/payment/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/saga-discovery/pom.xml b/saga-discovery/pom.xml deleted file mode 100644 index d3238103c..000000000 --- a/saga-discovery/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - org.apache.servicecomb.saga.discovery - saga-discovery - Saga::Discovery - - pom - - saga-discovery-servicecenter - - - - diff --git a/saga-discovery/saga-discovery-servicecenter/pom.xml b/saga-discovery/saga-discovery-servicecenter/pom.xml deleted file mode 100644 index 595ef184c..000000000 --- a/saga-discovery/saga-discovery-servicecenter/pom.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - saga-discovery - org.apache.servicecomb.saga.discovery - 0.3.0-SNAPSHOT - - 4.0.0 - - saga-discovery-servicecenter - Saga::Discovery::ServiceCenter - - - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - - - org.json - json - - - test - - - org.apache.servicecomb - spring-boot-starter-provider - ${java.chassis.version} - - - com.google.code.findbugs - annotations - - - - - org.apache.servicecomb - java-chassis-dependencies - ${java.chassis.version} - pom - import - - - - - - - org.apache.servicecomb.saga - saga-core - - - org.apache.servicecomb.saga.transports - transport-httpclient-spring - - - org.apache.servicecomb.saga.transports - transport-resttemplate - - - org.apache.servicecomb - spring-boot-starter-provider - - - log4j - log4j - - - - - org.springframework.boot - spring-boot-starter - - - ch.qos.logback - * - - - - - - org.springframework.boot - spring-boot-starter-web - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.hibernate - hibernate-validator - 5.2.4.Final - test - - - junit - junit - - - com.github.seanyinx - unit-scaffolding - - - diff --git a/saga-discovery/saga-discovery-servicecenter/src/main/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryConfig.java b/saga-discovery/saga-discovery-servicecenter/src/main/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryConfig.java deleted file mode 100644 index dcb48cb87..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/main/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryConfig.java +++ /dev/null @@ -1,43 +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.discovery.service.center; - -import org.springframework.boot.autoconfigure.AutoConfigureBefore; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; -import org.apache.servicecomb.saga.transports.HttpClientTransportConfig; -import org.apache.servicecomb.saga.transports.RestTransport; -import org.apache.servicecomb.saga.transports.resttemplate.RestTemplateTransport; -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@EnableServiceComb -@Profile("servicecomb") -@Configuration -@AutoConfigureBefore(HttpClientTransportConfig.class) -public class ServiceCenterDiscoveryConfig { - - static final String PROTOCOL = "cse://"; - - @Bean - RestTransport restTransport() { - return new RestTemplateTransport(RestTemplateBuilder.create(), PROTOCOL); - } -} diff --git a/saga-discovery/saga-discovery-servicecenter/src/main/resources/META-INF/spring.factories b/saga-discovery/saga-discovery-servicecenter/src/main/resources/META-INF/spring.factories deleted file mode 100644 index b199c22a6..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,18 +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. -## --------------------------------------------------------------------------- -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.servicecomb.saga.discovery.service.center.ServiceCenterDiscoveryConfig diff --git a/saga-discovery/saga-discovery-servicecenter/src/main/resources/microservice.yaml b/saga-discovery/saga-discovery-servicecenter/src/main/resources/microservice.yaml deleted file mode 100644 index c183fc965..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/main/resources/microservice.yaml +++ /dev/null @@ -1,30 +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. -## --------------------------------------------------------------------------- -APPLICATION_ID: saga -service_description: - name: saga-service - version: 0.0.1 -cse: - service: - registry: - address: http://sc.servicecomb.io:30100 - rest: - address: 0.0.0.0:8080 - handler: - chain: - Consumer: - default: loadbalance diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/DummyController.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/DummyController.java deleted file mode 100644 index edde45d1b..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/DummyController.java +++ /dev/null @@ -1,56 +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.discovery.service.center; - -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.GET; -import static org.springframework.web.bind.annotation.RequestMethod.POST; -import static org.springframework.web.bind.annotation.RequestMethod.PUT; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import org.apache.servicecomb.provider.rest.common.RestSchema; - -@Controller -@RequestMapping("/rest") -@RestSchema(schemaId = "dummy-rest-endpoint") -public class DummyController { - - @RequestMapping(value = "/usableResource", method = GET) - public ResponseEntity getUseableResource( - @RequestParam(name = "foo") String foo, - @RequestParam(name = "hello") String who) { - - return ResponseEntity.ok("foo " + foo + ", hello " + who); - } - - @RequestMapping(value = "/usableResource", method = PUT) - public ResponseEntity putUseableResource(@RequestParam(name = "foo") String foo, @RequestBody String json) { - return ResponseEntity.ok("foo " + foo + ", hello world" + json); - } - - @RequestMapping(value = "/faultyResource", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE) - public ResponseEntity postFaultyResource(@RequestParam(name = "foo") String foo, @RequestAttribute(name = "hello") String hello) { - throw new RuntimeException("no such resource"); - } -} diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryApplication.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryApplication.java deleted file mode 100644 index 579335ff9..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryApplication.java +++ /dev/null @@ -1,32 +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.discovery.service.center; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import org.apache.servicecomb.springboot.starter.provider.EnableServiceComb; - -@SpringBootApplication -@EnableServiceComb -public class ServiceCenterDiscoveryApplication { - - public static void main(String[] args) { - SpringApplication.run(ServiceCenterDiscoveryApplication.class, args); - } -} diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java b/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java deleted file mode 100644 index 81434dc85..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/test/java/org/apache/servicecomb/saga/discovery/service/center/ServiceCenterDiscoveryRestTransportTest.java +++ /dev/null @@ -1,130 +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.discovery.service.center; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT; - -import java.net.URL; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.transports.RestTransport; -import org.apache.servicecomb.saga.transports.resttemplate.RestTemplateTransport; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -import org.apache.servicecomb.provider.springmvc.reference.RestTemplateBuilder; - -import org.apache.servicecomb.saga.core.TransportFailedException; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = ServiceCenterDiscoveryApplication.class, webEnvironment = RANDOM_PORT) -public class ServiceCenterDiscoveryRestTransportTest { - - private static final String usableResource = "/rest/usableResource"; - private static final String faultyResource = "/rest/faultyResource"; - private static final String usableResponse = "foo bar, hello world"; - private static final String json = "{\"hello\", \"world\"}"; - - private final RestTransport transport = new RestTemplateTransport(RestTemplateBuilder.create(), ServiceCenterDiscoveryConfig.PROTOCOL); - private final String serviceName = "saga-service"; - - @BeforeClass - public static void setUpClass() { - setUpLocalRegistry(); - } - - private static void setUpLocalRegistry() { - System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); - } - - @Test - public void sendsGetRequestToDiscoveredService() { - Map> requests = singletonMap("query", map("foo", "bar", "hello", "world")); - SagaResponse response = transport.with(serviceName, usableResource, "get", requests); - - assertThat(response.succeeded(), is(true)); - assertThat(response.body(), containsString(usableResponse)); - } - - @Test - public void putsRequestToDiscoveredService() { - Map> requests = new HashMap<>(); - requests.put("query", singletonMap("foo", "bar")); - requests.put("json", singletonMap("body", json)); - - SagaResponse response = transport.with(serviceName, usableResource, "PUT", requests); - - assertThat(response.succeeded(), is(true)); - assertThat(response.body(), containsString(usableResponse + json)); - } - - @Test - public void blowsUpWhenRemoteResponseIsNot2XX() { - Map> requests = new HashMap<>(); - requests.put("query", singletonMap("foo", "bar")); - requests.put("form", map("hello", "world")); - - try { - transport.with(serviceName, faultyResource, "POST", requests); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), containsString("The remote service " + serviceName + " failed to serve")); - } - } - - @Test - public void blowsUpWhenRemoteIsNotReachable() { - try { - transport.with("unknown-service", faultyResource, "DELETE", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), containsString("The remote service unknown-service failed to serve")); - } - } - - @Test - public void blowsUpWhenMethodIsUnknown() { - try { - transport.with(serviceName, usableResource, "Blah", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getCause().getMessage(), is("No such method Blah")); - } - } - - private Map map(String... pairs) { - return new LinkedHashMap() {{ - for (int i = 0; i < pairs.length; i += 2) { - put(pairs[i], pairs[i + 1]); - } - }}; - } -} diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/resources/log4j2-test.xml b/saga-discovery/saga-discovery-servicecenter/src/test/resources/log4j2-test.xml deleted file mode 100644 index 58924c686..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/saga-discovery/saga-discovery-servicecenter/src/test/resources/registry.yaml b/saga-discovery/saga-discovery-servicecenter/src/test/resources/registry.yaml deleted file mode 100644 index 82752b441..000000000 --- a/saga-discovery/saga-discovery-servicecenter/src/test/resources/registry.yaml +++ /dev/null @@ -1,23 +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. -## --------------------------------------------------------------------------- -saga-service: - - id: "001" - version: "0.0.1" - appid: saga - instances: - - endpoints: - - rest://127.0.0.1:8080?sslEnabled=false diff --git a/saga-format/pom.xml b/saga-format/pom.xml deleted file mode 100644 index b69473b7d..000000000 --- a/saga-format/pom.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - saga-format - Saga::Format - - - - org.apache.servicecomb.saga - saga-core - - - com.fasterxml.jackson.core - jackson-core - ${jackson.version} - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.version} - - - io.kamon - kamon-core_2.12 - - - io.kamon - kamon-annotation_2.12 - - - - org.hamcrest - hamcrest-all - - - org.mockito - mockito-core - - - junit - junit - test - - - com.github.seanyinx - unit-scaffolding - test - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - UTF-8 - 1.7 - 1.7 - - - - - - diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/core/FailedSagaRequestContext.java b/saga-format/src/main/java/org/apache/servicecomb/saga/core/FailedSagaRequestContext.java deleted file mode 100644 index 92d603927..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/core/FailedSagaRequestContext.java +++ /dev/null @@ -1,40 +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.core; - -import org.apache.servicecomb.saga.format.JsonFailedSagaResponse; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.format.JsonSagaRequest; - -public class FailedSagaRequestContext extends SagaRequestContext { - - private final JsonSagaRequest request; - - public FailedSagaRequestContext( - @JsonProperty("request") JsonSagaRequest request, - @JsonProperty("response") JsonFailedSagaResponse response) { - super(request, response); - this.request = request; - } - - public JsonSagaRequest request() { - return request; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/core/JacksonToJsonFormat.java b/saga-format/src/main/java/org/apache/servicecomb/saga/core/JacksonToJsonFormat.java deleted file mode 100644 index c00ce4a36..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/core/JacksonToJsonFormat.java +++ /dev/null @@ -1,65 +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.core; - -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class JacksonToJsonFormat implements ToJsonFormat { - - - private final ObjectMapper objectMapper = new ObjectMapper(); - - public JacksonToJsonFormat() { - objectMapper.setVisibility( - objectMapper.getSerializationConfig() - .getDefaultVisibilityChecker() - .withFieldVisibility(ANY) - .withGetterVisibility(NONE) - .withSetterVisibility(NONE) - .withCreatorVisibility(NONE)); - - } - - @Segment(name = "toJson", category = "application", library = "kamon") - @Override - public String toJson(SagaRequest request) { - try { - return objectMapper.writeValueAsString(request); - } catch (JsonProcessingException e) { - throw new SagaException("Failed to serialize request to JSON: " + request, e); - } - } - - @Segment(name = "toJson", category = "application", library = "kamon") - @Override - public String toJson(SagaRequest request, SagaResponse response) { - try { - return objectMapper.writeValueAsString(new SagaRequestContext(request, response)); - } catch (JsonProcessingException e) { - throw new SagaException("Failed to serialize request & response to JSON: " + request + ", " + response, e); - } - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/core/SagaRequestContext.java b/saga-format/src/main/java/org/apache/servicecomb/saga/core/SagaRequestContext.java deleted file mode 100644 index 2e3761721..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/core/SagaRequestContext.java +++ /dev/null @@ -1,37 +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.core; - -public class SagaRequestContext { - - private final SagaRequest request; - private final SagaResponse response; - - SagaRequestContext(SagaRequest request, SagaResponse response) { - this.request = request; - this.response = response; - } - - public SagaRequest request() { - return request; - } - - public SagaResponse response() { - return response; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaRequestContext.java b/saga-format/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaRequestContext.java deleted file mode 100644 index f794a91ec..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/core/SuccessfulSagaRequestContext.java +++ /dev/null @@ -1,41 +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.core; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.format.JsonSagaRequest; -import org.apache.servicecomb.saga.format.JsonSuccessfulSagaResponse; - -public class SuccessfulSagaRequestContext extends SagaRequestContext { - - private final JsonSagaRequest request; - - @JsonCreator - public SuccessfulSagaRequestContext( - @JsonProperty("request") JsonSagaRequest request, - @JsonProperty("response") JsonSuccessfulSagaResponse response) { - super(request, response); - this.request = request; - } - - public JsonSagaRequest request() { - return request; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/ChildrenExtractor.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/ChildrenExtractor.java deleted file mode 100644 index 58cb1eb15..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/ChildrenExtractor.java +++ /dev/null @@ -1,59 +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.format; - -import java.io.IOException; -import java.util.HashSet; -import java.util.Set; - -import com.fasterxml.jackson.databind.JsonNode; - -import org.apache.servicecomb.saga.core.SagaException; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; - -public class ChildrenExtractor implements FromJsonFormat> { - - private static final String SAGA_CHILDREN = "sagaChildren"; - - private final ObjectMapper objectMapper = new ObjectMapper(); - - @Override - public Set fromJson(String json) { - try { - return childrenOf(objectMapper.readValue(json, ObjectNode.class)); - } catch (IOException e) { - throw new SagaException("Failed to deserialize json " + json, e); - } - } - - private Set childrenOf(ObjectNode value) { - Set children = new HashSet<>(); - - if (value.has(SAGA_CHILDREN)) { - for (JsonNode node : value.get(SAGA_CHILDREN)) { - children.add(node.textValue()); - } - } - - return children; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFallback.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFallback.java deleted file mode 100644 index 5078ceb45..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFallback.java +++ /dev/null @@ -1,81 +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.format; - -import org.apache.servicecomb.saga.core.Fallback; -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.Transport; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -import org.apache.servicecomb.saga.format.JacksonFallback.NopJacksonFallback; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - visible = true, - property = "type") -@JsonSubTypes({ - @Type(value = JacksonRestFallback.class, name = Operation.TYPE_REST), - @Type(value = NopJacksonFallback.class, name = Operation.TYPE_NOP) -}) -public interface JacksonFallback extends Fallback, TransportAware { - - JacksonFallback NOP_TRANSPORT_AWARE_FALLBACK = new NopJacksonFallback(TYPE_NOP); - - class NopJacksonFallback implements JacksonFallback { - - private final String type; - - @JsonCreator - public NopJacksonFallback(@JsonProperty("type") String type) { - this.type = type; - } - - @Override - public String type() { - return type; - } - - @Override - public Operation with(TransportFactory transport) { - return this; - } - - @Override - public SagaResponse send(String address) { - return SUCCESSFUL_SAGA_RESPONSE; - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - return send(address); - } - - @Override - public int retries() { - return 0; - } - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormat.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormat.java deleted file mode 100644 index c26a82f28..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormat.java +++ /dev/null @@ -1,58 +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.format; - -import java.io.IOException; - -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class JacksonFromJsonFormat implements FromJsonFormat { - - private final ObjectMapper objectMapper = new ObjectMapper(); - private final TransportFactory transportFactory; - - public JacksonFromJsonFormat(TransportFactory transportFactory) { - this.transportFactory = transportFactory; - } - - @Segment(name = "fromJson", category = "application", library = "kamon") - @Override - public SagaDefinition fromJson(String requestJson) { - try { - JsonSagaDefinition definition = objectMapper.readValue(requestJson, JsonSagaDefinition.class); - - for (JsonSagaRequest request : definition.requests()) { - request.with(transportFactory); - } - - return definition; - } catch (IOException e) { - throw new SagaException("Failed to interpret JSON " + requestJson, e); - } - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestCompensation.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestCompensation.java deleted file mode 100644 index 2b08edbaf..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestCompensation.java +++ /dev/null @@ -1,44 +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.format; - -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.Compensation; - -public class JacksonRestCompensation extends JacksonRestOperation implements Compensation { - - public JacksonRestCompensation( - String path, - String method, - Map> params) { - this(DEFAULT_RETRIES, path, method, params); - } - - @JsonCreator - public JacksonRestCompensation( - @JsonProperty("retries") int retries, - @JsonProperty("path") String path, - @JsonProperty("method") String method, - @JsonProperty("params") Map> params) { - super(path, method, retries <= 0 ? DEFAULT_RETRIES : retries, params); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestFallback.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestFallback.java deleted file mode 100644 index b27be0a31..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestFallback.java +++ /dev/null @@ -1,55 +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.format; - -import java.util.Map; - -import org.apache.servicecomb.saga.transports.RestTransport; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -class JacksonRestFallback extends JacksonRestOperation implements JacksonFallback { - - private final String type; - - public JacksonRestFallback( - String type, - String path, - String method, - Map> params) { - super(path, method, params); - this.type = type; - } - - @JsonCreator - public JacksonRestFallback( - @JsonProperty("type") String type, - @JsonProperty("path") String path, - @JsonProperty("method") String method, - @JsonProperty("retries") int retries, - @JsonProperty("params") Map> params) { - super(path, method, params); - this.type = type; - } - - @Override - public String type() { - return type; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestOperation.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestOperation.java deleted file mode 100644 index 6c90389cb..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestOperation.java +++ /dev/null @@ -1,71 +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.format; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import org.apache.servicecomb.saga.core.RestOperation; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.transports.RestTransport; - -class JacksonRestOperation extends RestOperation implements TransportAware { - - @JsonIgnore - private RestTransport transport; - - JacksonRestOperation(String path, String method, Map> params) { - this(path, method, DEFAULT_RETRIES, params); - } - - JacksonRestOperation(String path, String method, int retries, Map> params) { - super(path, method, retries, params); - } - - - @Override - public JacksonRestOperation with(TransportFactory transport) { - this.transport = transport.getTransport(); - return this; - } - - @Override - public SagaResponse send(String address) { - return transport.with(address, path(), method(), params()); - } - - @Override - public SagaResponse send(String address, SagaResponse response) { - Map> updated = new HashMap<>(params()); - // This is not thread safe - if (updated.get("form") == null) { - updated.put("form", new HashMap()); - } - updated.get("form").put("response", response.body()); - - return transport.with( - address, - path(), - method(), - updated); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestTransaction.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestTransaction.java deleted file mode 100644 index 807ec0d78..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonRestTransaction.java +++ /dev/null @@ -1,44 +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.format; - -import java.util.Map; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.Transaction; - -public class JacksonRestTransaction extends JacksonRestOperation implements Transaction { - - public JacksonRestTransaction( - String path, - String method, - Map> params) { - this(INFINITE_RETRY, path, method, params); - } - - @JsonCreator - public JacksonRestTransaction( - @JsonProperty("retries") int retries, - @JsonProperty("path") String path, - @JsonProperty("method") String method, - @JsonProperty("params") Map> params) { - super(path, method, retries <= 0? INFINITE_RETRY : retries, params); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLCompensation.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLCompensation.java deleted file mode 100644 index 2adf01953..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLCompensation.java +++ /dev/null @@ -1,40 +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.format; - -import java.util.List; - -import org.apache.servicecomb.saga.core.Compensation; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class JacksonSQLCompensation extends JacksonSQLOperation implements Compensation { - - public JacksonSQLCompensation(String sql, List> params) { - this(sql, params, DEFAULT_RETRIES); - } - - @JsonCreator - public JacksonSQLCompensation( - @JsonProperty("sql") String sql, - @JsonProperty("params") List> params, - @JsonProperty("retries") int retries) { - super(sql, retries <= 0? DEFAULT_RETRIES : retries, params); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLOperation.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLOperation.java deleted file mode 100644 index 8431a9b0d..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLOperation.java +++ /dev/null @@ -1,49 +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.format; - -import java.util.List; - -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SQLOperation; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.transports.SQLTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -public class JacksonSQLOperation extends SQLOperation implements TransportAware { - - @JsonIgnore - private SQLTransport transport; - - public JacksonSQLOperation(String sql, int retries, List> params) { - super(sql, retries, params); - } - - @Override - public Operation with(TransportFactory transport) { - this.transport = transport.getTransport(); - return this; - } - - @Override - public SagaResponse send(String datasource) { - return transport.with(datasource, sql(), params()); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLTransaction.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLTransaction.java deleted file mode 100644 index 88c695601..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSQLTransaction.java +++ /dev/null @@ -1,40 +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.format; - -import java.util.List; - -import org.apache.servicecomb.saga.core.Transaction; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class JacksonSQLTransaction extends JacksonSQLOperation implements Transaction { - - public JacksonSQLTransaction(String sql, List> params) { - this(INFINITE_RETRY, sql, params); - } - - @JsonCreator - public JacksonSQLTransaction( - @JsonProperty("retries") int retries, - @JsonProperty("sql") String sql, - @JsonProperty("params") List> params) { - super(sql, retries <= 0? INFINITE_RETRY : retries, params); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSagaEventFormat.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSagaEventFormat.java deleted file mode 100644 index 8b365c67f..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JacksonSagaEventFormat.java +++ /dev/null @@ -1,147 +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.format; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import org.apache.servicecomb.saga.core.FailedSagaRequestContext; -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.SagaStartedEvent; -import org.apache.servicecomb.saga.core.SuccessfulSagaRequestContext; -import org.apache.servicecomb.saga.core.TransactionAbortedEvent; -import org.apache.servicecomb.saga.core.TransactionCompensatedEvent; -import org.apache.servicecomb.saga.core.TransactionStartedEvent; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.apache.servicecomb.saga.core.SagaEndedEvent; -import org.apache.servicecomb.saga.core.TransactionEndedEvent; - -public class JacksonSagaEventFormat implements SagaEventFormat { - private final Map> eventFactories = new HashMap>() {{ - put(SagaStartedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return sagaStartedEvent(sagaId, json); - } - }); - put(TransactionStartedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return transactionStartedEvent(sagaId, json); - } - }); - put(TransactionEndedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return transactionEndedEvent(sagaId, json); - } - }); - put(TransactionAbortedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return transactionAbortedEvent(sagaId, json); - } - }); - put(TransactionCompensatedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return compensationEndedEvent(sagaId, json); - } - }); - put(SagaEndedEvent.class.getSimpleName(), new BiFunction() { - @Override - public SagaEvent apply(String sagaId, String json) { - return sagaEndedEvent(sagaId); - } - }); - }}; - - private final ObjectMapper objectMapper = new ObjectMapper(); - private final TransportFactory transportFactory; - - public JacksonSagaEventFormat(TransportFactory transportFactory) { - this.transportFactory = transportFactory; - } - - @Override - public SagaEvent toSagaEvent(String sagaId, String eventType, String contentJson) { - return eventFactories.get(eventType).apply(sagaId, contentJson); - } - - private SagaEvent sagaStartedEvent(String sagaId, String json) { - return new SagaStartedEvent( - sagaId, - json, - NoOpSagaRequest.SAGA_START_REQUEST); - } - - private SagaEvent transactionStartedEvent(String sagaId, String json) { - try { - return new TransactionStartedEvent(sagaId, objectMapper.readValue(json, JsonSagaRequest.class).with(transportFactory)); - } catch (IOException e) { - throw new SagaException(cause(sagaId, json), e); - } - } - - private SagaEvent transactionEndedEvent(String sagaId, String json) { - try { - SuccessfulSagaRequestContext context = objectMapper.readValue(json, SuccessfulSagaRequestContext.class); - return new TransactionEndedEvent(sagaId, context.request().with(transportFactory), context.response()); - } catch (IOException e) { - throw new SagaException(cause(sagaId, json), e); - } - } - - private SagaEvent transactionAbortedEvent(String sagaId, String json) { - try { - FailedSagaRequestContext context = objectMapper.readValue(json, FailedSagaRequestContext.class); - return new TransactionAbortedEvent(sagaId, context.request().with(transportFactory), context.response()); - } catch (IOException e) { - throw new SagaException(cause(sagaId, json), e); - } - } - - private SagaEvent compensationEndedEvent(String sagaId, String json) { - try { - SuccessfulSagaRequestContext context = objectMapper.readValue(json, SuccessfulSagaRequestContext.class); - return new TransactionCompensatedEvent(sagaId, context.request().with(transportFactory), context.response()); - } catch (IOException e) { - throw new SagaException(cause(sagaId, json), e); - } - } - - private SagaEvent sagaEndedEvent(String sagaId) { - return new SagaEndedEvent( - sagaId, - NoOpSagaRequest.SAGA_END_REQUEST); - } - - private String cause(String sagaId, String json) { - return "Failed to deserialize saga event of sage id: " + sagaId + " from json: " + json; - } - - private interface BiFunction { - R apply(T t, U u); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonFailedSagaResponse.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonFailedSagaResponse.java deleted file mode 100644 index 16ada6ef6..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonFailedSagaResponse.java +++ /dev/null @@ -1,29 +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.format; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.FailedSagaResponse; - -public class JsonFailedSagaResponse extends FailedSagaResponse { - - public JsonFailedSagaResponse(@JsonProperty("body") String body) { - super(body); - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonRestSagaRequest.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonRestSagaRequest.java deleted file mode 100644 index f91d29b33..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonRestSagaRequest.java +++ /dev/null @@ -1,73 +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.format; - -import static org.apache.servicecomb.saga.format.JacksonFallback.NOP_TRANSPORT_AWARE_FALLBACK; - -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.apache.servicecomb.saga.transports.RestTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.Operation; - -public class JsonRestSagaRequest extends SagaRequestImpl implements JsonSagaRequest { - - private final JacksonRestTransaction transaction; - private final JacksonRestCompensation compensation; - private final JacksonFallback fallback; - - @JsonCreator - public JsonRestSagaRequest( - @JsonProperty("id") String id, - @JsonProperty("serviceName") String serviceName, - @JsonProperty("type") String type, - @JsonProperty("transaction") JacksonRestTransaction transaction, - @JsonProperty("compensation") JacksonRestCompensation compensation, - @JsonProperty("fallback") JacksonFallback fallback, - @JsonProperty("parents") String[] parents, - @JsonProperty("failRetryDelayMilliseconds") int failRetryDelayMilliseconds) { - - super(id, serviceName, type, transaction, compensation, - fallback == null ? NOP_TRANSPORT_AWARE_FALLBACK : fallback, - parents, failRetryDelayMilliseconds); - - checkNull(transaction, "transaction"); - checkNull(compensation, "compensation"); - - this.transaction = transaction; - this.compensation = compensation; - this.fallback = fallback == null ? NOP_TRANSPORT_AWARE_FALLBACK : fallback; - } - - @Override - public JsonSagaRequest with(TransportFactory transportFactory) { - transaction.with(transportFactory); - compensation.with(transportFactory); - fallback.with(transportFactory); - return this; - } - - private void checkNull(Operation operation, String operationName) { - if (operation == null) { - throw new IllegalArgumentException("Invalid request with NO " + operationName + " specified"); - } - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequest.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequest.java deleted file mode 100644 index e1d959965..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequest.java +++ /dev/null @@ -1,69 +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.format; - -import static org.apache.servicecomb.saga.format.JacksonFallback.NOP_TRANSPORT_AWARE_FALLBACK; - -import org.apache.servicecomb.saga.core.Fallback; -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.apache.servicecomb.saga.transports.SQLTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; - -public class JsonSQLSagaRequest extends SagaRequestImpl implements JsonSagaRequest { - - private JacksonSQLTransaction transaction; - private JacksonSQLCompensation compensation; - - @JsonCreator - public JsonSQLSagaRequest( - @JsonProperty("id") String id, - @JsonProperty("datasource") String datasource, - @JsonProperty("type") String type, - @JsonProperty("transaction") JacksonSQLTransaction transaction, - @JsonProperty("compensation") JacksonSQLCompensation compensation, - @JsonProperty("fallback") Fallback fallback, - @JsonProperty("parents") String[] parents, - @JsonProperty("failRetryDelayMilliseconds") int failRetryDelayMilliseconds) { - super(id, datasource, type, transaction, compensation, - fallback == null ? NOP_TRANSPORT_AWARE_FALLBACK : fallback, - parents, failRetryDelayMilliseconds); - - checkNull(transaction, "transaction"); - checkNull(compensation, "compensation"); - - this.transaction = transaction; - this.compensation = compensation; - } - - @Override - public JsonSagaRequest with(TransportFactory transportFactory) { - transaction.with(transportFactory); - compensation.with(transportFactory); - return this; - } - - private void checkNull(Operation operation, String operationName) { - if (operation == null) { - throw new IllegalArgumentException("Invalid request with NO " + operationName + " specified"); - } - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaDefinition.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaDefinition.java deleted file mode 100644 index 0cf3bc6c9..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaDefinition.java +++ /dev/null @@ -1,61 +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.format; - -import java.util.HashMap; -import java.util.Map; - -import org.apache.servicecomb.saga.core.ForwardRecovery; -import org.apache.servicecomb.saga.core.RecoveryPolicy; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.BackwardRecovery; -import org.apache.servicecomb.saga.core.SagaDefinition; - -class JsonSagaDefinition implements SagaDefinition { - - static final RecoveryPolicy backwardRecovery = new BackwardRecovery(); - - private static final Map policies = new HashMap() {{ - put(RecoveryPolicy.SAGA_BACKWARD_RECOVERY_POLICY, backwardRecovery); - put(RecoveryPolicy.SAGA_FORWARD_RECOVERY_POLICY, new ForwardRecovery()); - }}; - - private final JsonSagaRequest[] requests; - - private final RecoveryPolicy policy; - - public JsonSagaDefinition( - @JsonProperty("policy") String policy, - @JsonProperty("requests") JsonSagaRequest[] requests) { - - this.requests = requests; - this.policy = null == policies.get(policy) ? backwardRecovery : policies.get(policy); - } - - @Override - public RecoveryPolicy policy() { - return policy; - } - - @Override - public JsonSagaRequest[] requests() { - return requests; - } -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaRequest.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaRequest.java deleted file mode 100644 index ed6c6ce88..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSagaRequest.java +++ /dev/null @@ -1,41 +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.format; - -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.Transport; -import org.apache.servicecomb.saga.transports.TransportFactory; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - visible = true, - property = "type") -@JsonSubTypes({ - @Type(value = JsonRestSagaRequest.class, name = Operation.TYPE_REST), - @Type(value = JsonSQLSagaRequest.class, name = Operation.TYPE_SQL) -}) -public interface JsonSagaRequest extends SagaRequest { - - JsonSagaRequest with(TransportFactory transportFactory); -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSuccessfulSagaResponse.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSuccessfulSagaResponse.java deleted file mode 100644 index 273fc3d6c..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/JsonSuccessfulSagaResponse.java +++ /dev/null @@ -1,30 +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.format; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; - -public class JsonSuccessfulSagaResponse extends SuccessfulSagaResponse { - - public JsonSuccessfulSagaResponse(@JsonProperty("body") String body) { - super(body); - } - -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/SagaEventFormat.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/SagaEventFormat.java deleted file mode 100644 index d035e96df..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/SagaEventFormat.java +++ /dev/null @@ -1,25 +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.format; - -import org.apache.servicecomb.saga.core.SagaEvent; - -public interface SagaEventFormat { - - SagaEvent toSagaEvent(String sagaId, String eventType, String contentJson); -} diff --git a/saga-format/src/main/java/org/apache/servicecomb/saga/format/TransportAware.java b/saga-format/src/main/java/org/apache/servicecomb/saga/format/TransportAware.java deleted file mode 100644 index 10b353ab8..000000000 --- a/saga-format/src/main/java/org/apache/servicecomb/saga/format/TransportAware.java +++ /dev/null @@ -1,27 +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.format; - -import org.apache.servicecomb.saga.core.Transport; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.apache.servicecomb.saga.core.Operation; - -interface TransportAware { - - Operation with(TransportFactory transport); -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/ChildrenExtractorTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/ChildrenExtractorTest.java deleted file mode 100644 index 1dad3613b..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/ChildrenExtractorTest.java +++ /dev/null @@ -1,75 +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.format; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.util.Set; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.junit.Test; - -import org.apache.servicecomb.saga.core.SagaException; - -public class ChildrenExtractorTest { - - private static final String json = "{\n" - + " \"foo\": \"bar\",\n" - + " \"sagaChildren\": [\n" - + " \"id1\",\n" - + " \"id2\",\n" - + " \"id3\"\n" - + " ]\n" - + "}"; - - private final ChildrenExtractor extractor = new ChildrenExtractor(); - - @Test - public void extractsChildrenIdFromJson() throws Exception { - Set children = extractor.fromJson(json); - - assertThat(children, containsInAnyOrder("id1", "id2", "id3")); - } - - @Test - public void emptyChildrenIfNoSuchField() throws Exception { - Set children = extractor.fromJson("{}"); - - assertThat(children.isEmpty(), is(true)); - } - - @Test - public void emptyChildrenIfNoneResponse() throws Exception { - Set children = extractor.fromJson(SagaResponse.NONE_RESPONSE.body()); - - assertThat(children, containsInAnyOrder("none")); - } - - @Test - public void blowsUpWithInvalidJson() throws Exception { - try { - extractor.fromJson("blah"); - expectFailing(SagaException.class); - } catch (SagaException e) { - assertThat(e.getMessage(), is("Failed to deserialize json blah")); - } - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatForSQLTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatForSQLTest.java deleted file mode 100644 index a36b36043..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatForSQLTest.java +++ /dev/null @@ -1,232 +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.format; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertThat; - -import java.io.IOException; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.transports.SQLTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.junit.Test; - -import com.seanyinx.github.unit.scaffolding.AssertUtils; - -public class JacksonFromJsonFormatForSQLTest { - private static final String requestJson = "{\n" - + " \"requests\":[\n" - + " {\n" - + " \"id\":\"first-sql-sharding-1\",\n" - + " \"type\":\"sql\",\n" - + " \"datasource\":\"ds_0\",\n" - + " \"parents\":[],\n" - + " \"transaction\":{\n" - + " \"sql\":\"INSERT INTO TABLE ds_0.tb_0 (id, value) values (?, ?)\",\n" - + " \"params\":[[\"1\", \"xxx\"]]\n" - + " },\n" - + " \"compensation\":{\n" - + " \"sql\":\"DELETE FROM ds_0.tb_0 WHERE id=?\",\n" - + " \"params\":[[\"1\"]]\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\":\"first-sql-sharding-2\",\n" - + " \"type\":\"sql\",\n" - + " \"datasource\":\"ds_0\",\n" - + " \"parents\":[],\n" - + " \"transaction\":{\n" - + " \"sql\":\"INSERT INTO TABLE ds_0.tb_1 (id, value) values (?, ?)\",\n" - + " \"params\":[[\"2\", \"xxx\"]]\n" - + " },\n" - + " \"compensation\":{\n" - + " \"sql\":\"DELETE FROM ds_0.tb_1 WHERE id=?\",\n" - + " \"params\":[[\"2\"]]\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\":\"second-sql-sharding-1\",\n" - + " \"type\":\"sql\",\n" - + " \"datasource\":\"ds_1\",\n" - + " \"parents\":[\"first-sql-sharding-1\",\"first-sql-sharding-2\"],\n" - + " \"transaction\":{\n" - + " \"sql\":\"INSERT INTO TABLE ds_1.tb_2 (id, value) values (?, ?)\",\n" - + " \"params\":[[\"3\", \"xxx\"]]\n" - + " },\n" - + " \"compensation\":{\n" - + " \"sql\":\"DELETE FROM ds_1.tb_2 WHERE id=?\",\n" - + " \"params\":[[\"3\"]]\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\":\"second-sql-sharding-2\",\n" - + " \"type\":\"sql\",\n" - + " \"datasource\":\"ds_1\",\n" - + " \"parents\":[\"first-sql-sharding-1\",\"first-sql-sharding-2\"],\n" - + " \"transaction\":{\n" - + " \"sql\":\"INSERT INTO TABLE ds_1.tb_3 (id, value) values (?, ?)\",\n" - + " \"retries\":5,\n" - + " \"params\":[[\"4\", \"xxx\"]]\n" - + " },\n" - + " \"compensation\":{\n" - + " \"sql\":\"DELETE FROM ds_1.tb_3 WHERE id=?\",\n" - + " \"retries\":10,\n" - + " \"params\":[[\"4\"]]\n" - + " }\n" - + " }\n" - + " ]\n" - + "}\n"; - - private final SagaResponse responseDefault = new SuccessfulSagaResponse(uniquify("responseDefault")); - - private final SQLTransport sqlTransport = new SQLTransport() { - @Override - public SagaResponse with(String datasource, String sql, List> params) { - if (null == sql || sql.trim().length() == 0) { - return responseDefault; - } - - for (List each : params) { - for (String param : each) { - sql = sql.replaceFirst("\\?", param); - } - } - - return new SuccessfulSagaResponse(datasource + " execute sql : " + sql); - } - }; - - private final TransportFactory transportFactory = new TransportFactory() { - @Override - public SQLTransport getTransport() { - return sqlTransport; - } - }; - - private final FromJsonFormat format = new JacksonFromJsonFormat(transportFactory); - - private final Function getRequestId = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.id(); - } - }; - - private final Function getRequestServiceName = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.serviceName(); - } - }; - - private final Function getRequestType = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.type(); - } - }; - - private final Function getTransactionRetries = new Function() { - @Override - public Integer apply(SagaRequest sagaRequest) { - return sagaRequest.transaction().retries(); - } - }; - - private final Function getCompensationRetries = new Function() { - @Override - public Integer apply(SagaRequest sagaRequest) { - return sagaRequest.compensation().retries(); - } - }; - - @Test - public void addTransportToDeserializedRequests() { - SagaRequest[] requests = format.fromJson(requestJson).requests(); - - assertThat(collect(requests, getRequestId), - contains("first-sql-sharding-1", "first-sql-sharding-2", "second-sql-sharding-1", "second-sql-sharding-2")); - assertThat(collect(requests, getRequestServiceName), contains("ds_0", "ds_0", "ds_1", "ds_1")); - assertThat(collect(requests, getRequestType), - contains(Operation.TYPE_SQL, Operation.TYPE_SQL, Operation.TYPE_SQL, Operation.TYPE_SQL)); - assertThat(collect(requests, getTransactionRetries), contains(-1, -1, -1, 5)); - assertThat(collect(requests, getCompensationRetries), contains(3, 3 ,3 ,10)); - - SagaResponse sagaResponse = null; - - sagaResponse = requests[0].transaction().send(requests[0].serviceName()); - assertThat(sagaResponse.body(), is("ds_0 execute sql : INSERT INTO TABLE ds_0.tb_0 (id, value) values (1, xxx)")); - sagaResponse = requests[0].compensation().send(requests[0].serviceName()); - assertThat(sagaResponse.body(), is("ds_0 execute sql : DELETE FROM ds_0.tb_0 WHERE id=1")); - - sagaResponse = requests[1].transaction().send(requests[1].serviceName()); - assertThat(sagaResponse.body(), is("ds_0 execute sql : INSERT INTO TABLE ds_0.tb_1 (id, value) values (2, xxx)")); - sagaResponse = requests[1].compensation().send(requests[1].serviceName()); - assertThat(sagaResponse.body(), is("ds_0 execute sql : DELETE FROM ds_0.tb_1 WHERE id=2")); - - sagaResponse = requests[2].transaction().send(requests[2].serviceName()); - assertThat(sagaResponse.body(), is("ds_1 execute sql : INSERT INTO TABLE ds_1.tb_2 (id, value) values (3, xxx)")); - sagaResponse = requests[2].compensation().send(requests[2].serviceName()); - assertThat(sagaResponse.body(), is("ds_1 execute sql : DELETE FROM ds_1.tb_2 WHERE id=3")); - - sagaResponse = requests[3].transaction().send(requests[3].serviceName()); - assertThat(sagaResponse.body(), is("ds_1 execute sql : INSERT INTO TABLE ds_1.tb_3 (id, value) values (4, xxx)")); - sagaResponse = requests[3].compensation().send(requests[3].serviceName()); - assertThat(sagaResponse.body(), is("ds_1 execute sql : DELETE FROM ds_1.tb_3 WHERE id=4")); - - assertArrayEquals(new String[] {"first-sql-sharding-1", "first-sql-sharding-2"}, requests[2].parents()); - assertArrayEquals(new String[] {"first-sql-sharding-1", "first-sql-sharding-2"}, requests[3].parents()); - } - - @Test - public void blowsUpWhenJsonIsInvalid() throws IOException { - String invalidRequest = "invalid-json"; - - try { - format.fromJson(invalidRequest); - AssertUtils.expectFailing(SagaException.class); - } catch (SagaException e) { - assertThat(e.getMessage(), is("Failed to interpret JSON invalid-json")); - } - } - - private Collection collect(SagaRequest[] requests, Function mapper) { - List result = new LinkedList(); - for (SagaRequest request : requests) { - result.add(mapper.apply(request)); - } - return result; - } - - private interface Function { - R apply(T t); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatTest.java deleted file mode 100644 index aafe10512..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonFromJsonFormatTest.java +++ /dev/null @@ -1,299 +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.format; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static java.util.Collections.singletonMap; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.util.*; - -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.transports.RestTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.hamcrest.Matchers; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import com.seanyinx.github.unit.scaffolding.AssertUtils; - -import org.apache.servicecomb.saga.core.SagaDefinition; - -public class JacksonFromJsonFormatTest { - - private static final String requests = "{\n" - + " \"requests\": [\n" - + " {\n" - + " \"id\": \"request-aaa\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"aaa\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"foo\": \"as\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"bar\": \"as\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"fallback\": {\n" - + " \"type\": \"rest\",\n" - + " \"method\":\"put\",\n" - + " \"path\": \"/rest/as\"\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-bbb\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"bbb\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/bs\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"foo\": \"bs\"\n" - + " },\n" - + " \"json\": {\n" - + " \"body\": \"{ \\\"bar\\\": \\\"bs\\\" }\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"retries\": 4,\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/bs\"\n" - + " },\n" - + " \"fallback\": {\n" - + " \"type\": \"rest\",\n" - + " \"method\":\"put\",\n" - + " \"path\": \"/rest/bs\"\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-ccc\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"ccc\",\n" - + " \"parents\": [\n" - + " \"request-aaa\",\n" - + " \"request-bbb\"\n" - + " ],\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/cs\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"foo\": \"cs\"\n" - + " },\n" - + " \"form\": {\n" - + " \"bar\": \"cs\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"retries\": 5,\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/cs\"\n" - + " },\n" - + " \"fallback\": {\n" - + " \"type\": \"rest\",\n" - + " \"method\":\"put\",\n" - + " \"path\": \"/rest/cs\"\n" - + " }\n" - + " }\n" - + " ]\n" - + "}\n"; - - private final SagaResponse response11 = new SuccessfulSagaResponse(uniquify("response11")); - private final SagaResponse response12 = new SuccessfulSagaResponse(uniquify("response12")); - private final SagaResponse response13 = new SuccessfulSagaResponse(uniquify("response13")); - private final SagaResponse response21 = new SuccessfulSagaResponse(uniquify("response21")); - private final SagaResponse response22 = new SuccessfulSagaResponse(uniquify("response22")); - private final SagaResponse response23 = new SuccessfulSagaResponse(uniquify("response23")); - private final SagaResponse response31 = new SuccessfulSagaResponse(uniquify("response31")); - private final SagaResponse response32 = new SuccessfulSagaResponse(uniquify("response32")); - private final SagaResponse response33 = new SuccessfulSagaResponse(uniquify("response33")); - - private final RestTransport restTransport = Mockito.mock(RestTransport.class); - private final TransportFactory transportFactory = Mockito.mock(TransportFactory.class); - private final FromJsonFormat format = new JacksonFromJsonFormat(transportFactory); - - private final Map> EMPTY_MAP = Collections.>emptyMap(); - - private final Function getRequestId = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.id(); - } - }; - - private final Function getRequestServiceName = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.serviceName(); - } - }; - - private final Function getRequestType = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.type(); - } - }; - - private final Function getCompensationRetries = new Function() { - @Override - public Integer apply(SagaRequest sagaRequest) { - return sagaRequest.compensation().retries(); - } - }; - - private final Function getFallbackType = new Function() { - @Override - public String apply(SagaRequest sagaRequest) { - return sagaRequest.fallback().type(); - } - }; - - @Before - public void setUp() throws Exception { - when(transportFactory.getTransport()).thenReturn(restTransport); - - when(restTransport.with("aaa", "/rest/as", "post", singletonMap("form", singletonMap("foo", "as")))) - .thenReturn(response11); - when(restTransport.with("aaa", "/rest/as", "delete", singletonMap("query", singletonMap("bar", "as")))) - .thenReturn(response12); - when(restTransport.with("aaa", "/rest/as", "put", EMPTY_MAP)) - .thenReturn(response13); - - when(restTransport - .with("bbb", "/rest/bs", "post", - mapOf("query", singletonMap("foo", "bs"), "json", singletonMap("body", "{ \"bar\": \"bs\" }")))) - .thenReturn(response21); - when(restTransport.with("bbb", "/rest/bs", "delete", EMPTY_MAP)) - .thenReturn(response22); - when(restTransport.with("bbb", "/rest/bs", "put", EMPTY_MAP)) - .thenReturn(response23); - - when(restTransport - .with("ccc", "/rest/cs", "post", mapOf("query", singletonMap("foo", "cs"), "form", singletonMap("bar", "cs")))) - .thenReturn(response31); - when(restTransport.with("ccc", "/rest/cs", "delete", EMPTY_MAP)) - .thenReturn(response32); - when(restTransport.with("ccc", "/rest/cs", "put", EMPTY_MAP)) - .thenReturn(response33); - } - - @Test - public void addTransportToDeserializedRequests() throws IOException { - SagaRequest[] sagaRequests = format.fromJson(requests).requests(); - - assertThat(collect(sagaRequests, getRequestId), contains("request-aaa", "request-bbb", "request-ccc")); - assertThat(collect(sagaRequests, getRequestServiceName), contains("aaa", "bbb", "ccc")); - assertThat(collect(sagaRequests, getRequestType), Matchers - .contains(Operation.TYPE_REST, Operation.TYPE_REST, Operation.TYPE_REST)); - assertThat(collect(sagaRequests, getCompensationRetries), contains(3, 4, 5)); - assertThat(collect(sagaRequests, getFallbackType), Matchers - .contains(Operation.TYPE_REST, Operation.TYPE_REST, Operation.TYPE_REST)); - - SagaResponse response = sagaRequests[0].transaction().send("aaa"); - assertThat(response, is(response11)); - - response = sagaRequests[0].compensation().send("aaa"); - assertThat(response, is(response12)); - - response = sagaRequests[0].fallback().send("aaa"); - assertThat(response, is(response13)); - assertThat(sagaRequests[0].parents().length, is(0)); - - response = sagaRequests[1].transaction().send("bbb"); - assertThat(response, is(response21)); - - response = sagaRequests[1].compensation().send("bbb"); - assertThat(response, is(response22)); - - response = sagaRequests[1].fallback().send("bbb"); - assertThat(response, is(response23)); - assertThat(sagaRequests[1].parents().length, is(0)); - - response = sagaRequests[2].transaction().send("ccc"); - assertThat(response, is(response31)); - - response = sagaRequests[2].compensation().send("ccc"); - assertThat(response, is(response32)); - - response = sagaRequests[2].fallback().send("ccc"); - assertThat(response, is(response33)); - assertArrayEquals(new String[] {"request-aaa", "request-bbb"}, sagaRequests[2].parents()); - } - - @Test - public void blowsUpWhenJsonIsInvalid() throws IOException { - String invalidRequest = "invalid-json"; - - try { - format.fromJson(invalidRequest); - AssertUtils.expectFailing(SagaException.class); - } catch (SagaException e) { - assertThat(e.getMessage(), is("Failed to interpret JSON invalid-json")); - } - } - - private Collection collect(SagaRequest[] requests, Function mapper) { - List result = new LinkedList(); - for (SagaRequest request : requests) { - result.add(mapper.apply(request)); - } - return result; - } - - private Map> mapOf( - String key1, - Map value1, - String key2, - Map value2) { - - Map> map = new HashMap<>(); - map.put(key1, value1); - map.put(key2, value2); - return map; - } - - private interface Function { - R apply(T t); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonRestOperationTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonRestOperationTest.java deleted file mode 100644 index 91f380d7b..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JacksonRestOperationTest.java +++ /dev/null @@ -1,73 +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.format; - -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; - -import org.apache.servicecomb.saga.core.Operation; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.transports.RestTransport; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.hamcrest.core.Is; -import org.junit.Before; -import org.junit.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; - -public class JacksonRestOperationTest { - - private final String address = uniquify("address"); - private final String path = uniquify("path"); - private final String method = "PUT"; - private final Map> params = new HashMap<>(); - - private final RestTransport transport = Mockito.mock(RestTransport.class); - private final TransportFactory transportFactory = Mockito.mock(TransportFactory.class); - private final JacksonRestOperation restOperation = new JacksonRestOperation(path, method, params); - - @Before - public void setUp() throws Exception { - when(transportFactory.getTransport()).thenReturn(transport); - restOperation.with(transportFactory); - } - - @Test - public void appendsResponseToForm() throws Exception { - ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Map.class); - when(transport.with(eq(address), eq(path), eq(method), argumentCaptor.capture())).thenReturn( - SagaResponse.EMPTY_RESPONSE); - - SagaResponse response = restOperation.send(address, Operation.SUCCESSFUL_SAGA_RESPONSE); - - assertThat(response, Is.is(SagaResponse.EMPTY_RESPONSE)); - - Map> updatedParams = argumentCaptor.getValue(); - assertThat(null == updatedParams.get("form") ? Collections.emptyMap().get("response") - : updatedParams.get("form").get("response") - , Is.is(Operation.SUCCESSFUL_SAGA_RESPONSE.body())); - assertThat(params.isEmpty(), is(true)); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonRestSagaRequestTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonRestSagaRequestTest.java deleted file mode 100644 index fe105555c..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonRestSagaRequestTest.java +++ /dev/null @@ -1,101 +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.format; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static org.apache.servicecomb.saga.format.JacksonFallback.NOP_TRANSPORT_AWARE_FALLBACK; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.mockito.ArgumentMatchers.anyMap; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Map; - -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.junit.Test; -import org.mockito.Mockito; - -import org.apache.servicecomb.saga.transports.RestTransport; - -public class JsonRestSagaRequestTest { - - private final RestTransport restTransport = Mockito.mock(RestTransport.class); - private final TransportFactory transportFactory = Mockito.mock(TransportFactory.class); - private final JacksonRestTransaction transaction = Mockito.mock(JacksonRestTransaction.class); - private final JacksonRestCompensation compensation = Mockito.mock(JacksonRestCompensation.class); - - @Test - public void blowsUpIfTransactionIsNotSpecified() { - try { - newSagaRequest(null, compensation, NOP_TRANSPORT_AWARE_FALLBACK); - - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Invalid request with NO transaction specified")); - } - } - - @Test - public void blowsUpIfCompensationIsNotSpecified() { - try { - newSagaRequest(transaction, null, NOP_TRANSPORT_AWARE_FALLBACK); - - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Invalid request with NO compensation specified")); - } - } - - @SuppressWarnings("unchecked") - @Test - public void defaultToNopFallbackIfNotSpecified() { - when(transportFactory.getTransport()).thenReturn(restTransport); - JsonRestSagaRequest request = newSagaRequest(transaction, compensation, null); - - request.with(transportFactory); - - request.fallback().send(uniquify("blah")); - - verify(restTransport, never()).with(anyString(), anyString(), anyString(), anyStringMap()); - } - - private Map> anyStringMap() { - return anyMap(); - } - - private JsonRestSagaRequest newSagaRequest( - JacksonRestTransaction transaction, - JacksonRestCompensation compensation, - JacksonFallback fallback) { - - return new JsonRestSagaRequest( - uniquify("id"), - uniquify("serviceName"), - TYPE_REST, - transaction, - compensation, - fallback, - null, - 0); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequestTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequestTest.java deleted file mode 100644 index 15336c959..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSQLSagaRequestTest.java +++ /dev/null @@ -1,72 +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.format; - -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static com.seanyinx.github.unit.scaffolding.Randomness.uniquify; -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static org.apache.servicecomb.saga.format.JacksonFallback.NOP_TRANSPORT_AWARE_FALLBACK; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.junit.Test; -import org.mockito.Mockito; - -public class JsonSQLSagaRequestTest { - - private final JacksonSQLTransaction transaction = Mockito.mock(JacksonSQLTransaction.class); - private final JacksonSQLCompensation compensation = Mockito.mock(JacksonSQLCompensation.class); - - @Test - public void blowsUpIfTransactionIsNotSpecified() { - try { - newSagaRequest(null, compensation, NOP_TRANSPORT_AWARE_FALLBACK); - - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Invalid request with NO transaction specified")); - } - } - - @Test - public void blowsUpIfCompensationIsNotSpecified() { - try { - newSagaRequest(transaction, null, NOP_TRANSPORT_AWARE_FALLBACK); - - expectFailing(IllegalArgumentException.class); - } catch (IllegalArgumentException e) { - assertThat(e.getMessage(), is("Invalid request with NO compensation specified")); - } - } - - private JsonSQLSagaRequest newSagaRequest( - JacksonSQLTransaction transaction, - JacksonSQLCompensation compensation, - JacksonFallback fallback) { - - return new JsonSQLSagaRequest( - uniquify("id"), - uniquify("serviceName"), - TYPE_REST, - transaction, - compensation, - fallback, - null, - 0); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSagaDefinitionTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSagaDefinitionTest.java deleted file mode 100644 index 6228b662b..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/JsonSagaDefinitionTest.java +++ /dev/null @@ -1,34 +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.format; - -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import org.hamcrest.core.Is; -import org.junit.Test; - -public class JsonSagaDefinitionTest { - - @Test - public void backwardRecoveryIfNoPolicyProvided() { - JsonSagaDefinition definition = new JsonSagaDefinition(null, new JsonSagaRequest[0]); - - assertThat(definition.policy(), Is.is(JsonSagaDefinition.backwardRecovery)); - } -} diff --git a/saga-format/src/test/java/org/apache/servicecomb/saga/format/SagaEventFormatTest.java b/saga-format/src/test/java/org/apache/servicecomb/saga/format/SagaEventFormatTest.java deleted file mode 100644 index ad6fb6250..000000000 --- a/saga-format/src/test/java/org/apache/servicecomb/saga/format/SagaEventFormatTest.java +++ /dev/null @@ -1,184 +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.format; - -import static org.apache.servicecomb.saga.core.Operation.TYPE_REST; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Collections; -import java.util.Map; - -import org.apache.servicecomb.saga.core.JacksonToJsonFormat; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.apache.servicecomb.saga.core.ToJsonFormat; -import org.apache.servicecomb.saga.core.TransactionCompensatedEvent; -import org.apache.servicecomb.saga.core.TransactionFailedException; -import org.apache.servicecomb.saga.core.TransactionStartedEvent; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.seanyinx.github.unit.scaffolding.Randomness; - -import org.apache.servicecomb.saga.core.FailedSagaResponse; -import org.apache.servicecomb.saga.core.RestOperation; -import org.apache.servicecomb.saga.core.SagaEvent; -import org.apache.servicecomb.saga.core.TransactionAbortedEvent; -import org.apache.servicecomb.saga.core.TransactionEndedEvent; -import org.apache.servicecomb.saga.transports.RestTransport; - -public class SagaEventFormatTest { - - private final String sagaId = Randomness.uniquify("sagaId"); - private final Map> EMPTY_MAP = Collections.>emptyMap(); - private final SagaRequest request = new SagaRequestImpl( - sagaId, - Randomness.uniquify("serviceName"), - TYPE_REST, - new JacksonRestTransaction("/rest/xxx", "POST", singletonMap("query", singletonMap("foo", "xxx"))), - new JacksonRestCompensation("/rest/xxx", "DELETE", singletonMap("query", singletonMap("bar", "xxx"))), - new JacksonRestFallback(TYPE_REST, "/rest/xxx", "PUT", EMPTY_MAP) - ); - - private final RestTransport restTransport = Mockito.mock(RestTransport.class); - private final TransportFactory transportFactory = Mockito.mock(TransportFactory.class); - private final SagaEventFormat toEventFormat = new JacksonSagaEventFormat(transportFactory); - private final ToJsonFormat toJsonFormat = new JacksonToJsonFormat(); - private final SuccessfulSagaResponse response = new SuccessfulSagaResponse("a wonderful day"); - - @Before - public void setUp() throws Exception { - when(transportFactory.getTransport()).thenReturn(restTransport); - } - - @After - public void tearDown() throws Exception { - verify(transportFactory, times(3)).getTransport(); - } - - @Test - public void transactionStartedEventCanBeSerializedAndDeserialized() throws JsonProcessingException { - TransactionStartedEvent event = new TransactionStartedEvent(sagaId, request); - String json = event.json(toJsonFormat); - - SagaEvent sagaEvent = toEventFormat - .toSagaEvent(sagaId, event.getClass().getSimpleName(), json); - - assertThat(sagaEvent, instanceOf(TransactionStartedEvent.class)); - assertThat(sagaEvent.sagaId, is(sagaId)); - assertThat(sagaEvent.payload(), eqToRequest(request)); - } - - @Test - public void transactionEndedEventCanBeSerializedAndDeserialized() throws JsonProcessingException { - TransactionEndedEvent event = new TransactionEndedEvent(sagaId, request, response); - String json = event.json(toJsonFormat); - - SagaEvent sagaEvent = toEventFormat - .toSagaEvent(sagaId, event.getClass().getSimpleName(), json); - - assertThat(sagaEvent, instanceOf(TransactionEndedEvent.class)); - assertThat(sagaEvent.sagaId, is(sagaId)); - assertThat(sagaEvent.payload(), eqToRequest(request)); - assertThat(((TransactionEndedEvent) sagaEvent).response(), eqToResponse(response)); - } - - @Test - public void TransactionAbortedEventCanBeSerializedAndDeserialized() throws JsonProcessingException { - TransactionFailedException exception = new TransactionFailedException("oops"); - SagaEvent event = new TransactionAbortedEvent(sagaId, request, exception); - String json = event.json(toJsonFormat); - - SagaEvent sagaEvent = toEventFormat - .toSagaEvent(sagaId, event.getClass().getSimpleName(), json); - - assertThat(sagaEvent, instanceOf(TransactionAbortedEvent.class)); - assertThat(sagaEvent.sagaId, is(sagaId)); - assertThat(sagaEvent.payload(), eqToRequest(request)); - assertThat(((TransactionAbortedEvent) sagaEvent).response(), eqToResponse(new FailedSagaResponse(exception))); - } - - @Test - public void compensationEndedEventCanBeSerializedAndDeserialized() throws JsonProcessingException { - TransactionCompensatedEvent event = new TransactionCompensatedEvent(sagaId, request, response); - String json = event.json(toJsonFormat); - - SagaEvent sagaEvent = toEventFormat - .toSagaEvent(sagaId, event.getClass().getSimpleName(), json); - - assertThat(sagaEvent, instanceOf(TransactionCompensatedEvent.class)); - assertThat(sagaEvent.sagaId, is(sagaId)); - assertThat(sagaEvent.payload(), eqToRequest(request)); - assertThat(((TransactionCompensatedEvent) sagaEvent).response(), eqToResponse(response)); - } - - private static Matcher eqToRequest(final SagaRequest expected) { - return new TypeSafeMatcher() { - @Override - protected boolean matchesSafely(SagaRequest request) { - return expected.id().equals(request.id()) - && request.serviceName().equals(expected.serviceName()) - && request.task().equals(expected.task()) - && request.type().equals(expected.type()) - && ((RestOperation) request.transaction()).path().equals(((RestOperation) expected.transaction()).path()) - && ((RestOperation) request.transaction()).method().equals(((RestOperation) expected.transaction()).method()) - && ((RestOperation) request.compensation()).path().equals(((RestOperation) expected.compensation()).path()) - && ((RestOperation) request.compensation()).method().equals(((RestOperation) expected.compensation()).method()); - } - - @Override - public void describeTo(Description description) { - description.appendText(expected.toString()); - } - }; - - } - - private static Matcher eqToResponse(final SagaResponse expected) { - return new TypeSafeMatcher() { - @Override - protected boolean matchesSafely(SagaResponse response) { - return expected.body().equals(response.body()) - && response.succeeded() == expected.succeeded(); - } - - @Override - public void describeTo(Description description) { - description.appendText(expected.toString()); - } - }; - } - -} diff --git a/saga-spring/pom.xml b/saga-spring/pom.xml deleted file mode 100755 index 12a26fcb0..000000000 --- a/saga-spring/pom.xml +++ /dev/null @@ -1,261 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - saga-spring - Saga::Spring - - - - - - org.springframework - spring-jdbc - ${spring.version} - - - org.springframework.boot - spring-boot-starter-test - ${spring.boot.version} - - - org.json - json - - - test - - - org.apache.servicecomb - spring-boot-starter-provider - ${java.chassis.version} - - - com.google.code.findbugs - annotations - - - - - org.apache.servicecomb - java-chassis-dependencies - ${java.chassis.version} - pom - import - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.apache.servicecomb.saga - saga-core - - - org.apache.servicecomb.saga - saga-core-akka - - - org.apache.servicecomb.saga - saga-format - - - com.fasterxml.jackson.core - * - - - - - org.apache.servicecomb.saga.transports - transport-httpclient-spring - - - org.apache.servicecomb.saga.discovery - saga-discovery-servicecenter - - - commons-io - commons-io - - - org.springframework.boot - spring-boot-starter - - - ch.qos.logback - * - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-actuator - - - javax.persistence - javax.persistence-api - - - org.apache.servicecomb.saga - saga-persistence-jpa - - - org.postgresql - postgresql - runtime - - - io.kamon - kamon-core_2.12 - - - io.kamon - kamon-annotation_2.12 - - - com.lmax - disruptor - - - - com.h2database - h2 - test - - - org.springframework.boot - spring-boot-starter-test - test - - - com.github.tomakehurst - wiremock-standalone - - - com.github.seanyinx - unit-scaffolding - - - io.rest-assured - rest-assured - test - - - - - - - - com.github.odavid.maven.plugins - mixin-maven-plugin - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - docker - - - /var/run/docker.sock - - - - - - io.fabric8 - docker-maven-plugin - - - org.commonjava.maven.plugins - directory-maven-plugin - - - - - - perf - - - io.kamon - kamon-log-reporter_2.12 - - - io.kamon - kamon-statsd_2.12 - - - org.aspectj - aspectjweaver - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - aspectj.copy - process-test-resources - - copy - - - - - org.aspectj - aspectjweaver - - - ${project.build.directory}/saga - true - - - - - - - - - - diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/JpaPersistentStore.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/JpaPersistentStore.java deleted file mode 100644 index 4c6e5f07d..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/JpaPersistentStore.java +++ /dev/null @@ -1,69 +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.spring; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.apache.servicecomb.saga.core.EventEnvelope; -import org.apache.servicecomb.saga.core.ToJsonFormat; -import org.apache.servicecomb.saga.format.SagaEventFormat; -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaEvent; - -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -class JpaPersistentStore implements PersistentStore { - - private final SagaEventRepo repo; - private final SagaEventFormat sagaEventFormat; - private final ToJsonFormat toJsonFormat; - - JpaPersistentStore(SagaEventRepo repo, ToJsonFormat toJsonFormat, SagaEventFormat sagaEventFormat) { - this.repo = repo; - this.sagaEventFormat = sagaEventFormat; - this.toJsonFormat = toJsonFormat; - } - - @Override - public Map> findPendingSagaEvents() { - List events = repo.findIncompleteSagaEventsGroupBySagaId(); - - Map> pendingEvents = new HashMap<>(); - for (SagaEventEntity event : events) { - pendingEvents.computeIfAbsent(event.sagaId(), id -> new LinkedList<>()); - pendingEvents.get(event.sagaId()).add( - new EventEnvelope( - event.id(), - event.creationTime(), - sagaEventFormat.toSagaEvent(event.sagaId(), event.type(), event.contentJson()))); - } - - return pendingEvents; - } - - @Segment(name = "save", category = "database", library = "kamon") - @Override - public void offer(SagaEvent event) { - repo.save(new SagaEventEntity(event.sagaId, event.getClass().getSimpleName(), event.json(toJsonFormat))); - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java deleted file mode 100644 index 5271f95f7..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaController.java +++ /dev/null @@ -1,222 +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.spring; - -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY; -import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE; -import static javax.ws.rs.core.Response.Status.BAD_REQUEST; -import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.GET; -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; - -import com.fasterxml.jackson.annotation.JsonAutoDetect; - -import org.apache.servicecomb.provider.rest.common.RestSchema; -import org.apache.servicecomb.saga.core.SagaException; -import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import kamon.annotation.EnableKamon; -import kamon.annotation.Trace; - -@EnableKamon -@Controller -@RequestMapping("/") -@RestSchema(schemaId = "saga-endpoint") -public class SagaController { - - private final SagaExecutionComponent sagaExecutionComponent; - private final SagaEventRepo repo; - private final SagaExecutionQueryService queryService; - private final SimpleDateFormat dateFormat; - - @Autowired - public SagaController(SagaExecutionComponent sagaExecutionComponent, SagaEventRepo repo, - SagaExecutionQueryService queryService) { - this.sagaExecutionComponent = sagaExecutionComponent; - this.repo = repo; - this.queryService = queryService; - this.dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - } - - @Trace("processRequests") - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "success"), - @ApiResponse(code = 400, response = String.class, message = "illegal request content"), - @ApiResponse(code = 500, response = String.class, message = "transaction failed") - }) - @CrossOrigin - @RequestMapping(value = "requests", method = POST, consumes = TEXT_PLAIN_VALUE, produces = TEXT_PLAIN_VALUE) - public ResponseEntity processRequests(@RequestBody String request) { - try { - SagaResponse response = sagaExecutionComponent.run(request); - if (response.succeeded()) { - return ResponseEntity.ok("success"); - } else { - throw new InvocationException(INTERNAL_SERVER_ERROR, response.body()); - } - } catch (SagaException se) { - throw new InvocationException(BAD_REQUEST, se); - } - } - - @RequestMapping(value = "events", method = GET) - public ResponseEntity>> allEvents() { - Iterable entities = repo.findAll(); - - Map> events = new LinkedHashMap<>(); - entities.forEach(e -> { - events.computeIfAbsent(e.sagaId(), id -> new LinkedList<>()); - events.get(e.sagaId()).add(new SagaEventVo(e.id(), e.sagaId(), e.creationTime(), e.type(), e.contentJson())); - }); - - return ResponseEntity.ok(events); - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "success"), - @ApiResponse(code = 400, response = String.class, message = "illegal request content"), - }) - @CrossOrigin - @RequestMapping(value = "requests", method = GET) - public ResponseEntity queryExecutions( - @RequestParam(name = "pageIndex") String pageIndex, - @RequestParam(name = "pageSize") String pageSize, - @RequestParam(name = "startTime") String startTime, - @RequestParam(name = "endTime") String endTime) { - if (isRequestParamValid(pageIndex, pageSize, startTime, endTime)) { - try { - return ResponseEntity.ok(queryService.querySagaExecution(pageIndex, pageSize, startTime, endTime)); - } catch (ParseException ignored) { - throw new InvocationException(BAD_REQUEST, "illegal request content"); - } - } else { - throw new InvocationException(BAD_REQUEST, "illegal request content"); - } - } - - private boolean isRequestParamValid(String pageIndex, String pageSize, String startTime, String endTime) { - try { - if (Integer.parseInt(pageIndex) >= 0 && Integer.parseInt(pageSize) > 0) { - Date start = "NaN-NaN-NaN NaN:NaN:NaN".equals(startTime) ? new Date(0) : this.dateFormat.parse(startTime); - Date end = - "NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date(Long.MAX_VALUE) : this.dateFormat.parse(endTime); - return start.getTime() <= end.getTime(); - } - } catch (NumberFormatException | ParseException ignored) { - } - return false; - } - - @ApiResponses({ - @ApiResponse(code = 200, response = String.class, message = "success"), - }) - @CrossOrigin - @RequestMapping(value = "requests/{sagaId}", method = GET) - public ResponseEntity queryExecutionDetail(@PathVariable String sagaId) { - return ResponseEntity.ok(queryService.querySagaExecutionDetail(sagaId)); - } - - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - private static class SagaEventVo extends SagaEventEntity { - - private SagaEventVo(long id, String sagaId, long creationTime, String type, String contentJson) { - super(id, sagaId, creationTime, type, contentJson); - } - } - - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - static class SagaExecutionQueryResult { - public int pageIndex; - public int pageSize; - public int totalPages; - - public List requests; - - public SagaExecutionQueryResult() { - } - - public SagaExecutionQueryResult(int pageIndex, int pageSize, int totalPages, List requests) { - this(); - this.pageIndex = pageIndex; - this.pageSize = pageSize; - this.totalPages = totalPages; - this.requests = requests; - } - } - - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - static class SagaExecution { - public long id; - public String sagaId; - public long startTime; - public String status; - public long completedTime; - - public SagaExecution() { - } - - public SagaExecution(long id, String sagaId, long startTime, long completedTime, String status) { - this(); - this.id = id; - this.sagaId = sagaId; - this.startTime = startTime; - this.completedTime = completedTime; - this.status = status; - } - } - - @JsonAutoDetect(fieldVisibility = ANY, getterVisibility = NONE, setterVisibility = NONE) - static class SagaExecutionDetail { - public Map> router; - public Map status; - public Map error; - - public SagaExecutionDetail() { - } - - public SagaExecutionDetail(Map> router, Map status, - Map error) { - this(); - this.router = router; - this.status = status; - this.error = error; - } - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java deleted file mode 100644 index 6be35013d..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventEntity.java +++ /dev/null @@ -1,85 +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.spring; - -import java.util.Date; - -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class SagaEventEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - private String sagaId; - private Date creationTime; - private String type; - private String contentJson; - - public SagaEventEntity() { - } - - public SagaEventEntity(String sagaId, String type, String contentJson) { - this.sagaId = sagaId; - this.type = type; - this.contentJson = contentJson; - this.creationTime = new Date(); - } - - public SagaEventEntity(long id, String sagaId, long timestamp, String type, String contentJson) { - this.id = id; - this.sagaId = sagaId; - this.creationTime = new Date(timestamp); - this.type = type; - this.contentJson = contentJson; - } - - public long id() { - return id; - } - - public String sagaId() { - return sagaId; - } - - public long creationTime() { - return creationTime.getTime(); - } - - public String type() { - return type; - } - - public String contentJson() { - return contentJson; - } - - @Override - public String toString() { - return "SagaEventEntity{" + - "id=" + id + - ", sagaId='" + sagaId + '\'' + - ", creationTime=" + creationTime + - ", type='" + type + '\'' + - ", contentJson='" + contentJson + '\'' + - '}'; - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java deleted file mode 100644 index 1f1132b35..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaEventRepo.java +++ /dev/null @@ -1,44 +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.spring; - -import java.util.Date; -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; - -interface SagaEventRepo extends PagingAndSortingRepository { - - // TODO: 8/21/2017 replace with hql? - @Query(value = "SELECT * FROM SagaEventEntity " - + "WHERE sagaId NOT IN (" - + " SELECT DISTINCT sagaId FROM SagaEventEntity" - + " WHERE type = 'SagaEndedEvent'" - + ")", nativeQuery = true) - List findIncompleteSagaEventsGroupBySagaId(); - - Page findByTypeAndCreationTimeBetweenOrderByIdDesc(String type, Date startTime, Date endTime, - Pageable pageable); - - SagaEventEntity findFirstByTypeAndSagaId(String type, String sagaId); - - List findBySagaId(String sagaId); -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java deleted file mode 100644 index 356131b8f..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaExecutionQueryService.java +++ /dev/null @@ -1,160 +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.spring; - -import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.stream.Collectors; - -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaStartedEvent; -import org.apache.servicecomb.saga.core.dag.GraphCycleDetectorImpl; -import org.apache.servicecomb.saga.core.dag.Node; -import org.apache.servicecomb.saga.core.dag.SingleLeafDirectedAcyclicGraph; -import org.apache.servicecomb.saga.spring.SagaController.SagaExecution; -import org.apache.servicecomb.saga.spring.SagaController.SagaExecutionDetail; -import org.apache.servicecomb.saga.spring.SagaController.SagaExecutionQueryResult; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.stereotype.Service; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.SagaEndedEvent; -import org.apache.servicecomb.saga.core.TransactionAbortedEvent; -import org.apache.servicecomb.saga.core.TransactionEndedEvent; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.core.dag.GraphBuilder; - -import org.apache.servicecomb.swagger.invocation.exception.InvocationException; - -@Service -public class SagaExecutionQueryService { - private final SagaEventRepo repo; - private final FromJsonFormat fromJsonFormat; - private final SimpleDateFormat dateFormat; - - private final ObjectMapper mapper = new ObjectMapper(); - private final GraphBuilder graphBuilder = new GraphBuilder(new GraphCycleDetectorImpl<>()); - - @Autowired - public SagaExecutionQueryService(SagaEventRepo repo, FromJsonFormat fromJsonFormat) { - this.repo = repo; - this.fromJsonFormat = fromJsonFormat; - this.dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - } - - public SagaExecutionQueryResult querySagaExecution(String pageIndex, String pageSize, - String startTime, String endTime) throws ParseException { - - Date start = "NaN-NaN-NaN NaN:NaN:NaN".equals(startTime) ? new Date(0) : this.dateFormat.parse(startTime); - Date end = "NaN-NaN-NaN NaN:NaN:NaN".equals(endTime) ? new Date() : this.dateFormat.parse(endTime); - - List requests = new ArrayList<>(); - Page startEvents = repo.findByTypeAndCreationTimeBetweenOrderByIdDesc( - SagaStartedEvent.class.getSimpleName(), start, end, - new PageRequest(Integer.parseInt(pageIndex), Integer.parseInt(pageSize))); - for (SagaEventEntity event : startEvents) { - SagaEventEntity endEvent = repo - .findFirstByTypeAndSagaId(SagaEndedEvent.class.getSimpleName(), event.sagaId()); - SagaEventEntity abortedEvent = repo - .findFirstByTypeAndSagaId(TransactionAbortedEvent.class.getSimpleName(), event.sagaId()); - - requests.add(new SagaExecution( - event.id(), - event.sagaId(), - event.creationTime(), - endEvent == null ? 0 : endEvent.creationTime(), - endEvent == null ? "Running" : abortedEvent == null ? "OK" : "Failed")); - } - - return new SagaExecutionQueryResult(Integer.parseInt(pageIndex), Integer.parseInt(pageSize), - startEvents.getTotalPages(), requests); - } - - public SagaExecutionDetail querySagaExecutionDetail(String sagaId) { - SagaEventEntity[] entities = repo.findBySagaId(sagaId).toArray(new SagaEventEntity[0]); - Optional sagaStartEvent = Arrays.stream(entities) - .filter(entity -> SagaStartedEvent.class.getSimpleName().equals(entity.type())).findFirst(); - Map> router = new HashMap<>(); - Map status = new HashMap<>(); - Map error = new HashMap<>(); - if (sagaStartEvent.isPresent()) { - SagaDefinition definition = fromJsonFormat.fromJson(sagaStartEvent.get().contentJson()); - SingleLeafDirectedAcyclicGraph graph = graphBuilder - .build(definition.requests()); - loopLoadGraphNodes(router, graph.root()); - - Collection transactionAbortEvents = Arrays.stream(entities) - .filter(entity -> TransactionAbortedEvent.class.getSimpleName().equals(entity.type())).collect( - Collectors.toList()); - for (SagaEventEntity transactionAbortEvent : transactionAbortEvents) { - try { - JsonNode root = mapper.readTree(transactionAbortEvent.contentJson()); - String id = root.at("/request/id").asText(); - status.put(id, "Failed"); - error.put(id, root.at("/response/body").asText()); - } catch (IOException ex) { - throw new InvocationException(INTERNAL_SERVER_ERROR, "illegal json content"); - } - } - - Collection transactionEndEvents = Arrays.stream(entities) - .filter(entity -> TransactionEndedEvent.class.getSimpleName().equals(entity.type())).collect( - Collectors.toList()); - for (SagaEventEntity transactionEndEvent : transactionEndEvents) { - try { - JsonNode root = mapper.readTree(transactionEndEvent.contentJson()); - status.put(root.at("/request/id").asText(), "OK"); - } catch (IOException ex) { - throw new InvocationException(INTERNAL_SERVER_ERROR, "illegal json content"); - } - } - } - return new SagaExecutionDetail(router, status, error); - } - - private void loopLoadGraphNodes(Map> router, Node node) { - if (isNodeValid(node)) { - HashSet point = router.computeIfAbsent(node.value().id(), key -> new HashSet<>()); - for (Node child : node.children()) { - point.add(child.value().id()); - loopLoadGraphNodes(router, child); - } - } - } - - private boolean isNodeValid(Node node) { - return !node.children().isEmpty(); - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaRecoveryListener.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaRecoveryListener.java deleted file mode 100644 index 6b6e31d3f..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaRecoveryListener.java +++ /dev/null @@ -1,37 +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.spring; - -import java.lang.invoke.MethodHandles; - -import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.context.event.ApplicationReadyEvent; -import org.springframework.context.ApplicationListener; - -class SagaRecoveryListener implements ApplicationListener { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Override - public void onApplicationEvent(ApplicationReadyEvent applicationReadyEvent) { - log.info("Recovering pending sagas from saga log"); - applicationReadyEvent.getApplicationContext().getBean(SagaExecutionComponent.class).reanimate(); - log.info("Recovered pending sagas from saga log successfully"); - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaShutdownListener.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaShutdownListener.java deleted file mode 100644 index 8ec862ec8..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaShutdownListener.java +++ /dev/null @@ -1,42 +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.spring; - - -import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationListener; -import org.springframework.context.event.ContextClosedEvent; - -import java.lang.invoke.MethodHandles; - -public class SagaShutdownListener implements ApplicationListener { - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Override - public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { - try { - log.info("Stopping sagas"); - contextClosedEvent.getApplicationContext().getBean(SagaExecutionComponent.class).terminate(); - log.info("Stopped sagas successfully."); - } catch (Exception ex) { - log.error("Stopped sagas failed.", ex); - } - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringApplication.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringApplication.java deleted file mode 100644 index 3e17c14b5..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringApplication.java +++ /dev/null @@ -1,39 +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.spring; - -import javax.annotation.PreDestroy; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import kamon.Kamon; - -@SpringBootApplication -public class SagaSpringApplication { - - public static void main(String[] args) { - Kamon.start(); - SpringApplication.run(SagaSpringApplication.class, args); - } - - @PreDestroy - void shutdown() { - Kamon.shutdown(); - } -} diff --git a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringConfig.java b/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringConfig.java deleted file mode 100644 index d40f724f1..000000000 --- a/saga-spring/src/main/java/org/apache/servicecomb/saga/spring/SagaSpringConfig.java +++ /dev/null @@ -1,136 +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.spring; - -import java.util.Set; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.servicecomb.saga.core.JacksonToJsonFormat; -import org.apache.servicecomb.saga.core.ToJsonFormat; -import org.apache.servicecomb.saga.core.actors.ActorBasedSagaFactory; -import org.apache.servicecomb.saga.core.application.SagaExecutionComponent; -import org.apache.servicecomb.saga.core.application.SagaFactory; -import org.apache.servicecomb.saga.core.dag.GraphBasedSagaFactory; -import org.apache.servicecomb.saga.format.ChildrenExtractor; -import org.apache.servicecomb.saga.format.JacksonFromJsonFormat; -import org.apache.servicecomb.saga.format.SagaEventFormat; -import org.apache.servicecomb.saga.transports.TransportFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaDefinition; -import org.apache.servicecomb.saga.core.application.interpreter.FromJsonFormat; -import org.apache.servicecomb.saga.format.JacksonSagaEventFormat; -import org.apache.servicecomb.saga.transports.RestTransport; - -@Configuration -class SagaSpringConfig { - - @Bean - TransportFactory transportFactory(RestTransport restTransport) { - return () -> restTransport; - } - - @Bean - FromJsonFormat fromJsonFormat(TransportFactory transportFactory) { - return new JacksonFromJsonFormat(transportFactory); - } - - @Bean - ToJsonFormat toJsonFormat() { - return new JacksonToJsonFormat(); - } - - @Bean - SagaEventFormat sagaEventFormat(TransportFactory transportFactory) { - return new JacksonSagaEventFormat(transportFactory); - } - - @Bean - PersistentStore persistentStore(SagaEventRepo repo, ToJsonFormat toJsonFormat, SagaEventFormat eventFormat) { - return new JpaPersistentStore(repo, toJsonFormat, eventFormat); - } - - @Bean - SagaExecutionQueryService queryService(SagaEventRepo repo, FromJsonFormat fromJsonFormat) { - return new SagaExecutionQueryService(repo, fromJsonFormat); - } - - @Bean - SagaExecutionComponent sagaExecutionComponent( - PersistentStore persistentStore, - ToJsonFormat format, - FromJsonFormat fromJsonFormat, - SagaFactory sagaFactory) { - - return new SagaExecutionComponent( - persistentStore, - fromJsonFormat, - format, - sagaFactory); - } - - @Bean - FromJsonFormat> childrenExtractor() { - return new ChildrenExtractor(); - } - - @ConditionalOnProperty(value = "saga.runningMode", havingValue = "graph", matchIfMissing = true) - @Bean - SagaFactory graphBasedSagaFactory( - @Value("${saga.thread.count:5}") int numberOfThreads, - @Value("${saga.retry.delay:3000}") int retryDelay, - PersistentStore persistentStore, - FromJsonFormat> childrenExtractor) { - - return new GraphBasedSagaFactory( - retryDelay, - persistentStore, - childrenExtractor, - Executors.newFixedThreadPool(numberOfThreads, sagaThreadFactory())); - } - - @ConditionalOnProperty(value = "saga.runningMode", havingValue = "actor") - @Bean - SagaFactory actorBasedSagaFactory( - @Value("${saga.retry.delay:3000}") int retryDelay, - PersistentStore persistentStore, - FromJsonFormat> childrenExtractor) { - - return new ActorBasedSagaFactory( - retryDelay, - persistentStore, - childrenExtractor); - } - - private ThreadFactory sagaThreadFactory() { - return new ThreadFactory() { - private final AtomicInteger threadCount = new AtomicInteger(); - - @Override - public Thread newThread(Runnable r) { - return new Thread(r, "saga-pool-thread-" + threadCount.incrementAndGet()); - } - }; - } -} diff --git a/saga-spring/src/main/resources/META-INF/aop.xml b/saga-spring/src/main/resources/META-INF/aop.xml deleted file mode 100644 index c48103637..000000000 --- a/saga-spring/src/main/resources/META-INF/aop.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - diff --git a/saga-spring/src/main/resources/META-INF/spring.factories b/saga-spring/src/main/resources/META-INF/spring.factories deleted file mode 100644 index ff5b14fd6..000000000 --- a/saga-spring/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,20 +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. -## --------------------------------------------------------------------------- - -org.springframework.context.ApplicationListener=\ - org.apache.servicecomb.saga.spring.SagaRecoveryListener,\ - org.apache.servicecomb.saga.spring.SagaShutdownListener diff --git a/saga-spring/src/main/resources/application.conf b/saga-spring/src/main/resources/application.conf deleted file mode 100644 index d50e5916c..000000000 --- a/saga-spring/src/main/resources/application.conf +++ /dev/null @@ -1,88 +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. -## --------------------------------------------------------------------------- - -############################### -# Kamon related configuration # -############################### - -kamon { - - metric { - filters { - trace.includes = ["**"] - trace-segment.includes = ["**"] - trace-segment.excludes = [] - akka-actor.includes = [] - akka-actor.excludes = ["**"] - akka-dispatcher.includes = [] - akka-dispatcher.excludes = ["**"] - } - } - - show-aspectj-missing-warning = no - - modules { - kamon-annotation { - auto-start = no - requires-aspectj = yes - } - - kamon-log-reporter { - auto-start = no - requires-aspectj = no - } - - kamon-statsd { - auto-start = no - requires-aspectj = no - } - } - - statsd { - # Hostname and port in which your StatsD is running. Remember that StatsD packets are sent using UDP and - # setting unreachable hosts and/or not open ports wont be warned by the Kamon, your data wont go anywhere. - hostname = "localhost" - port = 8125 - - # Interval between metrics data flushes to StatsD. It's value must be equal or greater than the - # kamon.metrics.tick-interval setting. - flush-interval = 10 second - - # Subscription patterns used to select which metrics will be pushed to StatsD. Note that first, metrics - # collection for your desired entities must be activated under the kamon.metrics.filters settings. - includes { - actor = [] - trace = ["*"] - trace-segment = ["*"] - dispatcher = [] - } - - subscriptions { - histogram = ["**"] - min-max-counter = ["**"] - gauge = ["**"] - counter = ["**"] - trace = ["**"] - trace-segment = ["**"] - akka-actor = [] - akka-dispatcher = [] - akka-router = [] - system-metric = [] - http-server = [] - } - } -} diff --git a/saga-spring/src/main/resources/application.yaml b/saga-spring/src/main/resources/application.yaml deleted file mode 100644 index 6ed0d9d5b..000000000 --- a/saga-spring/src/main/resources/application.yaml +++ /dev/null @@ -1,30 +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. -## --------------------------------------------------------------------------- -spring: - profiles: prd - datasource: - username: saga - password: password - url: jdbc:postgresql://postgres.servicecomb.io:5432/saga?useSSL=false - platform: postgresql -# continue-on-error: true - -saga: - thread: - count: 32 - retry: - delay: 3000 diff --git a/saga-spring/src/main/resources/log4j2.xml b/saga-spring/src/main/resources/log4j2.xml deleted file mode 100644 index cae04cb93..000000000 --- a/saga-spring/src/main/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/saga-spring/src/main/resources/schema-postgresql.sql b/saga-spring/src/main/resources/schema-postgresql.sql deleted file mode 100644 index 7a2cd1fe0..000000000 --- a/saga-spring/src/main/resources/schema-postgresql.sql +++ /dev/null @@ -1,26 +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. - */ - -CREATE TABLE IF NOT EXISTS SagaEventEntity ( - id BIGSERIAL PRIMARY KEY, - sagaId varchar(36) NOT NULL, - creationTime timestamp(6) NOT NULL DEFAULT CURRENT_DATE, - type varchar(50) NOT NULL, - contentJson TEXT NOT NULL -); - -CREATE INDEX IF NOT EXISTS running_sagas_index ON SagaEventEntity (sagaId, type); diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/ActorBasedSagaSpringApplicationTest.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/ActorBasedSagaSpringApplicationTest.java deleted file mode 100644 index f88267237..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/ActorBasedSagaSpringApplicationTest.java +++ /dev/null @@ -1,25 +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.spring; - -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = SagaSpringApplication.class, properties = "saga.runningMode=actor") -public class ActorBasedSagaSpringApplicationTest extends SagaSpringApplicationTestBase { - -} diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GraphBasedSagaSpringApplicationTest.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GraphBasedSagaSpringApplicationTest.java deleted file mode 100644 index f5fddcb85..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GraphBasedSagaSpringApplicationTest.java +++ /dev/null @@ -1,25 +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.spring; - -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest(classes = SagaSpringApplication.class) -public class GraphBasedSagaSpringApplicationTest extends SagaSpringApplicationTestBase { - -} diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java deleted file mode 100644 index 4d9cab006..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/GreetingController.java +++ /dev/null @@ -1,42 +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.spring; - -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE; -import static org.springframework.web.bind.annotation.RequestMethod.POST; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RequestMapping; - -import org.apache.servicecomb.provider.rest.common.RestSchema; - -@Controller -@RequestMapping("/rest") -@RestSchema(schemaId = "greeting-rest-endpoint") -public class GreetingController { - - @RequestMapping(value = "/usableResource", method = POST, consumes = APPLICATION_FORM_URLENCODED_VALUE) - public ResponseEntity postUsableResource( - @RequestAttribute(name = "hello") String who, - @RequestAttribute(name = "response") String response) { - - return ResponseEntity.ok("hello " + who + ", with response " + response); - } -} diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaRecoveryTest.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaRecoveryTest.java deleted file mode 100644 index 0d1e9c5ad..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaRecoveryTest.java +++ /dev/null @@ -1,181 +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.spring; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.deleteRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.exactly; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static java.util.Collections.singletonMap; - -import org.apache.servicecomb.saga.core.NoOpSagaRequest; -import org.apache.servicecomb.saga.core.SagaRequestImpl; -import org.apache.servicecomb.saga.core.SagaStartedEvent; -import org.apache.servicecomb.saga.core.ToJsonFormat; -import org.apache.servicecomb.saga.format.JacksonRestCompensation; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; -import org.springframework.context.annotation.Profile; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import org.apache.servicecomb.saga.core.PersistentStore; -import org.apache.servicecomb.saga.core.SagaEndedEvent; -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.apache.servicecomb.saga.core.TransactionAbortedEvent; -import org.apache.servicecomb.saga.core.TransactionCompensatedEvent; -import org.apache.servicecomb.saga.core.TransactionEndedEvent; -import org.apache.servicecomb.saga.core.TransactionStartedEvent; -import org.apache.servicecomb.saga.format.JacksonFallback; -import org.apache.servicecomb.saga.format.JacksonRestTransaction; -import org.apache.servicecomb.saga.format.SagaEventFormat; -import org.apache.servicecomb.saga.spring.SagaRecoveryTest.EventPopulatingConfig; -import wiremock.org.apache.http.HttpStatus; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = {SagaSpringApplication.class, EventPopulatingConfig.class}) -@ActiveProfiles("recovery-test") -public class SagaRecoveryTest { - - @ClassRule - public static final WireMockRule wireMockRule = new WireMockRule(8090); - - private static String request(final String name) { - return " {\n" - + " \"id\": \"request-" + name + "\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"localhost:8090\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/" + name + "\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"foo\": \"" + name + "\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/" + name + "\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"bar\": \"" + name + "\"\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n"; - } - - private static final String requestY = "[\n" - + request("yyy1") - + "," - + request("yyy2") - + "," - + request("yyy3") - + "]\n"; - - private static final String sagaY = "{\"policy\": \"ForwardRecovery\",\"requests\": " + requestY + "}"; - - @BeforeClass - public static void setUp() throws Exception { - stubFor(delete(urlPathEqualTo("/rest/yyy1")) - .withQueryParam("bar", containing("yyy1")) - .willReturn( - aResponse() - .withStatus(HttpStatus.SC_OK) - .withBody("success"))); - } - - @Test - public void recoverIncompleteSagasFromSagaLog() throws Exception { - verify(exactly(0), postRequestedFor(urlPathEqualTo("/rest/xxx"))); - - verify(exactly(0), postRequestedFor(urlPathEqualTo("/rest/yyy1"))); - verify(exactly(1), deleteRequestedFor(urlPathEqualTo("/rest/yyy1"))); - - verify(exactly(0), postRequestedFor(urlPathEqualTo("/rest/yyy2"))); - verify(exactly(0), deleteRequestedFor(urlPathEqualTo("/rest/yyy2"))); - - verify(exactly(0), postRequestedFor(urlPathEqualTo("/rest/yyy3"))); - verify(exactly(0), deleteRequestedFor(urlPathEqualTo("/rest/yyy3"))); - } - - @Profile("recovery-test") - @Configuration - static class EventPopulatingConfig { - - private static final String DONT_CARE = "{}"; - - private final SagaRequest request1 = sagaRequest("yyy1"); - private final SagaRequest request2 = sagaRequest("yyy2"); - private final SagaRequest request3 = sagaRequest("yyy3"); - - private final SagaResponse response1 = new SuccessfulSagaResponse("succeeded, yyy1"); - private final SagaResponse response2 = new SuccessfulSagaResponse("succeeded, yyy2"); - - @Primary - @Bean - PersistentStore persistentStore(SagaEventRepo repo, ToJsonFormat toJsonFormat, SagaEventFormat sagaEventFormat) { - repo.save(new SagaEventEntity("xxx", SagaStartedEvent.class.getSimpleName(), DONT_CARE)); - repo.save(new SagaEventEntity("xxx", TransactionStartedEvent.class.getSimpleName(), DONT_CARE)); - repo.save(new SagaEventEntity("xxx", TransactionEndedEvent.class.getSimpleName(), DONT_CARE)); - repo.save(new SagaEventEntity("xxx", SagaEndedEvent.class.getSimpleName(), DONT_CARE)); - - PersistentStore store = new JpaPersistentStore(repo, toJsonFormat, sagaEventFormat); - - store.offer(new SagaStartedEvent("yyy", sagaY, NoOpSagaRequest.SAGA_START_REQUEST)); - store.offer(new TransactionStartedEvent("yyy", request1)); - store.offer(new TransactionEndedEvent("yyy", request1, response1)); - - store.offer(new TransactionStartedEvent("yyy", request2)); - store.offer(new TransactionEndedEvent("yyy", request2, response2)); - - store.offer(new TransactionStartedEvent("yyy", request3)); - store.offer(new TransactionAbortedEvent("yyy", request3, new RuntimeException("oops"))); - - store.offer(new TransactionCompensatedEvent("yyy", request2, response2)); - - return store; - } - - private SagaRequestImpl sagaRequest(final String name) { - return new SagaRequestImpl( - "request-" + name, - "localhost:8080", - "rest", - new JacksonRestTransaction("/rest/" + name, "post", singletonMap("query", singletonMap("foo", name))), - new JacksonRestCompensation("rest/" + name, "delete", singletonMap("query", singletonMap("bar", name))), - JacksonFallback.NOP_TRANSPORT_AWARE_FALLBACK); - } - } -} diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java deleted file mode 100644 index 7c7a10323..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaServiceDiscoveryTest.java +++ /dev/null @@ -1,110 +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.spring; - -import static io.restassured.RestAssured.given; -import static io.restassured.http.ContentType.TEXT; -import static org.apache.servicecomb.serviceregistry.client.LocalServiceRegistryClientImpl.LOCAL_REGISTRY_FILE_KEY; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -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.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import org.apache.servicecomb.saga.core.TransactionEndedEvent; - -@SuppressWarnings("unchecked") -@RunWith(SpringRunner.class) -@SpringBootTest(classes = SagaSpringApplication.class) -@ActiveProfiles("servicecomb") -public class SagaServiceDiscoveryTest { - - private static final String requests = "[\n" - + " {\n" - + " \"id\": \"request-aaa\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"saga-service\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/usableResource\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"hello\": \"world\"\n" - + " }" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/usableResource\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"foo\": \"bar\"\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "]\n"; - - private static final String sagaDefinition = "{\"policy\": \"ForwardRecovery\",\"requests\": " + requests + "}"; - - @Autowired - private SagaEventRepo sagaEventRepo; - - - @BeforeClass - public static void setUpClass() { - setUpLocalRegistry(); - } - - private static void setUpLocalRegistry() { - System.setProperty(LOCAL_REGISTRY_FILE_KEY,"notExistJustForceLocal"); - } - - @Test - public void processRequestByServiceDiscovery() throws Exception { - given() - .contentType(TEXT) - .body(sagaDefinition) - .when() - .post("http://localhost:8080/requests") - .then() - .statusCode(200) - .body(is("success")); - - List events = new ArrayList<>(); - sagaEventRepo.findAll().forEach(events::add); - - Optional eventEntity = events.stream() - .filter(entity -> entity.type().equals(TransactionEndedEvent.class.getSimpleName())) - .findFirst(); - - assertThat(eventEntity.isPresent(), is(true)); - assertThat(eventEntity.get().contentJson(), containsString("hello world, with response {}")); - } - -} diff --git a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaSpringApplicationTestBase.java b/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaSpringApplicationTestBase.java deleted file mode 100644 index 655446958..000000000 --- a/saga-spring/src/test/java/org/apache/servicecomb/saga/spring/SagaSpringApplicationTestBase.java +++ /dev/null @@ -1,390 +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.spring; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.exactly; -import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; -import static com.github.tomakehurst.wiremock.client.WireMock.resetAllRequests; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.verify; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertThat; -import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -import java.net.URLEncoder; - -import org.apache.servicecomb.saga.spring.SagaController.SagaExecutionDetail; -import org.apache.servicecomb.saga.spring.SagaController.SagaExecutionQueryResult; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import wiremock.org.apache.http.HttpStatus; - -@SuppressWarnings("unchecked") -@RunWith(SpringRunner.class) -@AutoConfigureMockMvc -public class SagaSpringApplicationTestBase { - - private static final ObjectMapper mapper = new ObjectMapper(); - - @ClassRule - public static final WireMockRule wireMockRule = new WireMockRule(8090); - - private static final String requests = "[\n" - + " {\n" - + " \"id\": \"request-aaa\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"localhost:8090\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"foo\": \"as\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"bar\": \"as\"\n" - + " }\n" - + " }\n" - + " }\n" - + " },\n" - + " {\n" - + " \"id\": \"request-bbb\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"localhost:8090\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"foo\": \"as\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/as\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"bar\": \"as\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"parents\": [\"request-aaa\"]\n" - + " }\n" - + "]\n"; - - private static final String failRequests = "[\n" - + " {\n" - + " \"id\": \"request-aaa\",\n" - + " \"type\": \"rest\",\n" - + " \"serviceName\": \"localhost:8090\",\n" - + " \"transaction\": {\n" - + " \"method\": \"post\",\n" - + " \"path\": \"/rest/bs\",\n" - + " \"params\": {\n" - + " \"form\": {\n" - + " \"foo\": \"bs\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"compensation\": {\n" - + " \"method\": \"delete\",\n" - + " \"path\": \"/rest/bs\",\n" - + " \"params\": {\n" - + " \"query\": {\n" - + " \"bar\": \"bs\"\n" - + " }\n" - + " }\n" - + " }\n" - + " }\n" - + "]\n"; - - private static final String sagaDefinition = "{\"policy\": \"ForwardRecovery\",\"requests\": " + requests + "}"; - private static final String sagaFailDefinition = - "{\"policy\": \"BackwardRecovery\",\"requests\": " + failRequests + "}"; - - @Autowired - private MockMvc mockMvc; - - @Autowired - private SagaEventRepo sagaEventRepo; - - @BeforeClass - public static void setUp() throws Exception { - stubFor(WireMock.post(urlPathEqualTo("/rest/as")) - .withRequestBody(containing("foo=as&response=" + URLEncoder.encode("{}", "UTF-8"))) - .willReturn( - aResponse() - .withStatus(HttpStatus.SC_OK) - .withBody("{\n" - + " \"body\": \"success\",\n" - + " \"sagaChildren\": [\"none\"]\n" - + "}"))); - - stubFor(WireMock.post(urlPathEqualTo("/rest/bs")) - .withRequestBody(containing("foo=bs")) - .willReturn( - aResponse() - .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .withBody("process failed"))); - } - - @Before - public void tearUp() { - resetAllRequests(); - sagaEventRepo.deleteAll(); - } - - @Test - public void testBadFormatRequest() throws Exception { - try { - mockMvc.perform( - post("/requests/") - .contentType(TEXT_PLAIN) - .content("xxxx")) - .andExpect(status().is(HttpStatus.SC_BAD_REQUEST)) - .andExpect(content().string(containsString("illegal request content"))); - } catch (org.springframework.web.util.NestedServletException ex) { - assertThat(ex.getMessage(), containsString("Failed to interpret JSON xxxx")); - } - } - - @Test - public void testFailedRequest() throws Exception { - try { - mockMvc.perform( - post("/requests/") - .contentType(TEXT_PLAIN) - .content(sagaFailDefinition)) - .andExpect(status().is(HttpStatus.SC_INTERNAL_SERVER_ERROR)) - .andExpect(content().string(containsString("transaction failed"))); - } catch (org.springframework.web.util.NestedServletException ex) { - assertThat(ex.getMessage(), containsString( - "The remote service returned with status code 500, reason Server Error")); - } - - MvcResult resultJson = mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "NaN-NaN-NaN NaN:NaN:NaN") - .param("endTime", "NaN-NaN-NaN NaN:NaN:NaN")) - .andExpect(status().isOk()).andReturn(); - SagaExecutionQueryResult result = mapper - .readValue(resultJson.getResponse().getContentAsString(), SagaExecutionQueryResult.class); - assertThat(result.requests.size(), is(1)); - - String sagaId = result.requests.get(0).sagaId; - - MvcResult detailJson = mockMvc.perform(get("/requests/" + sagaId)).andExpect(status().isOk()) - .andReturn(); - SagaExecutionDetail executionDetail = mapper - .readValue(detailJson.getResponse().getContentAsString(), SagaExecutionDetail.class); - - assertThat(executionDetail.router.keySet(), containsInAnyOrder("saga-start", "request-aaa")); - assertThat(executionDetail.status.get("request-aaa"), is("Failed")); - assertThat(executionDetail.error.size(), is(1)); - } - - @Test - public void processRequestByRest() throws Exception { - mockMvc.perform( - post("/requests/") - .contentType(TEXT_PLAIN) - .content(sagaDefinition)) - .andExpect(status().isOk()); - - verify(exactly(1), postRequestedFor(urlPathEqualTo("/rest/as"))); - - Iterable events = sagaEventRepo.findAll(); - - assertThat(events, contains( - eventWith(1L, "SagaStartedEvent"), - eventWith(2L, "TransactionStartedEvent"), - eventWith(3L, "TransactionEndedEvent"), - eventWith(4L, "SagaEndedEvent") - )); - - MvcResult resultJson = mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "NaN-NaN-NaN NaN:NaN:NaN") - .param("endTime", "NaN-NaN-NaN NaN:NaN:NaN")) - .andExpect(status().isOk()).andReturn(); - SagaExecutionQueryResult result = mapper - .readValue(resultJson.getResponse().getContentAsString(), SagaExecutionQueryResult.class); - assertThat(result.requests.size(), is(1)); - - String sagaId = result.requests.get(0).sagaId; - - MvcResult detailJson = mockMvc.perform(get("/requests/" + sagaId)).andExpect(status().isOk()) - .andReturn(); - SagaExecutionDetail executionDetail = mapper - .readValue(detailJson.getResponse().getContentAsString(), SagaExecutionDetail.class); - - assertThat(executionDetail.router.keySet(), containsInAnyOrder("saga-start", "request-bbb", "request-aaa")); - assertThat(executionDetail.status.get("request-aaa"), is("OK")); - assertThat(executionDetail.error.size(), is(0)); - } - - @Test - public void queryRequestsWithBadParameter() throws Exception { - try { - mockMvc.perform(get("/requests") - .param("pageIndex", "xxx") - .param("pageSize", "xxx") - .param("startTime", "NaN-NaN-NaN NaN:NaN:NaN") - .param("endTime", "NaN-NaN-NaN NaN:NaN:NaN")) - .andExpect(status().is(HttpStatus.SC_BAD_REQUEST)); - } catch (org.springframework.web.util.NestedServletException ex) { - assertThat(ex.getMessage(), containsString("illegal request content")); - } - - try { - mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "x0") - .param("endTime", "x1")) - .andExpect(status().is(HttpStatus.SC_BAD_REQUEST)); - } catch (org.springframework.web.util.NestedServletException ex) { - assertThat(ex.getMessage(), containsString("illegal request content")); - } - } - - @Test - public void queryRequestsWithNANParameter() throws Exception { - mockMvc.perform( - post("/requests/") - .contentType(TEXT_PLAIN) - .content(sagaDefinition)) - .andExpect(status().isOk()); - - MvcResult resultJson = mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "NaN-NaN-NaN NaN:NaN:NaN") - .param("endTime", "NaN-NaN-NaN NaN:NaN:NaN")) - .andExpect(status().is(HttpStatus.SC_OK)).andReturn(); - SagaExecutionQueryResult result = mapper - .readValue(resultJson.getResponse().getContentAsString(), SagaExecutionQueryResult.class); - assertThat(result.requests.size(), is(1)); - - resultJson = mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "2000-1-1 00:00:00") - .param("endTime", "NaN-NaN-NaN NaN:NaN:NaN")) - .andExpect(status().is(HttpStatus.SC_OK)).andReturn(); - result = mapper - .readValue(resultJson.getResponse().getContentAsString(), SagaExecutionQueryResult.class); - assertThat(result.requests.size(), is(1)); - - resultJson = mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "NaN-NaN-NaN NaN:NaN:NaN") - .param("endTime", "9999-12-31 12:59:59")) - .andExpect(status().is(HttpStatus.SC_OK)).andReturn(); - result = mapper - .readValue(resultJson.getResponse().getContentAsString(), SagaExecutionQueryResult.class); - assertThat(result.requests.size(), is(1)); - - try { - mockMvc.perform(get("/requests") - .param("pageIndex", "0") - .param("pageSize", "10") - .param("startTime", "9999-12-31 12:59:59") - .param("endTime", "2000-1-1 00:00:00")) - .andExpect(status().is(HttpStatus.SC_BAD_REQUEST)); - } catch (org.springframework.web.util.NestedServletException ex) { - assertThat(ex.getMessage(), containsString("illegal request content")); - } - } - - @Test - public void allEvents() throws Exception { - mockMvc.perform( - post("/requests/") - .contentType(TEXT_PLAIN) - .content(sagaDefinition)) - .andExpect(status().isOk()); - mockMvc.perform(get("/events")).andExpect(status().isOk()) - .andExpect(content().string(containsString("SagaStartedEvent"))) - .andExpect(content().string(containsString("request-aaa"))) - .andExpect(content().string(containsString("request-bbb"))) - .andExpect(content().string(containsString("SagaEndedEvent"))); - } - - - private Matcher eventWith( - long eventId, - String type) { - - return new TypeSafeMatcher() { - @Override - protected boolean matchesSafely(SagaEventEntity event) { - return eventId == event.id() && event.type().equals(type); - } - - @Override - protected void describeMismatchSafely(SagaEventEntity item, Description mismatchDescription) { - mismatchDescription.appendText(item.toString()); - } - - @Override - public void describeTo(Description description) { - description.appendText( - "SagaEventEntity {" - + "id=" + eventId - + ", type=" + type); - } - }; - } -} diff --git a/saga-spring/src/test/resources/data.sql b/saga-spring/src/test/resources/data.sql deleted file mode 100644 index 5cdb7d92f..000000000 --- a/saga-spring/src/test/resources/data.sql +++ /dev/null @@ -1,29 +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. - */ - -DROP TABLE IF EXISTS SagaEventEntity; - -CREATE TABLE `SagaEventEntity` ( - `id` bigint NOT NULL AUTO_INCREMENT, - `sagaId` varchar(36) NOT NULL, - `creationTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `type` varchar(50) NOT NULL, - `contentJson` clob NOT NULL DEFAULT '{}', - PRIMARY KEY (`id`) -) DEFAULT CHARSET=utf8; - - CREATE INDEX running_sagas_index ON sagaEventEntity(sagaId, type); diff --git a/saga-spring/src/test/resources/log4j2-test.xml b/saga-spring/src/test/resources/log4j2-test.xml deleted file mode 100644 index 58924c686..000000000 --- a/saga-spring/src/test/resources/log4j2-test.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/saga-spring/src/test/resources/registry.yaml b/saga-spring/src/test/resources/registry.yaml deleted file mode 100644 index 82752b441..000000000 --- a/saga-spring/src/test/resources/registry.yaml +++ /dev/null @@ -1,23 +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. -## --------------------------------------------------------------------------- -saga-service: - - id: "001" - version: "0.0.1" - appid: saga - instances: - - endpoints: - - rest://127.0.0.1:8080?sslEnabled=false diff --git a/scripts/test.sh b/scripts/test.sh index 19498916c..46fe4f928 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -23,6 +23,6 @@ then else echo "Running the unit tests and integration tests here!" mvn clean install -Pjacoco -Pdocker -P${SPRING_BOOT_PROFILE} coveralls:report - mvn clean verify -f saga-demo -Pdemo -Pdocker -P${SPRING_BOOT_PROFILE} -Ddocker.useColor=false -Ddocker.showLogs + mvn clean verify -f demo -Pdemo -Pdocker -P${SPRING_BOOT_PROFILE} -Ddocker.useColor=false -Ddocker.showLogs mvn clean verify -f acceptance-tests -Pdemo -Pdocker -P${SPRING_BOOT_PROFILE} -Ddocker.useColor=false -Ddocker.showLogs fi diff --git a/transports/pom.xml b/transports/pom.xml deleted file mode 100644 index dde8580bb..000000000 --- a/transports/pom.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - saga - org.apache.servicecomb.saga - 0.3.0-SNAPSHOT - - 4.0.0 - - org.apache.servicecomb.saga.transports - transports - Saga::Transports - - pom - - transport-httpclient - transport-httpclient-spring - transport-resttemplate - - - - diff --git a/transports/transport-httpclient-spring/pom.xml b/transports/transport-httpclient-spring/pom.xml deleted file mode 100644 index 0b1e00ca2..000000000 --- a/transports/transport-httpclient-spring/pom.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - transports - org.apache.servicecomb.saga.transports - 0.3.0-SNAPSHOT - - 4.0.0 - - transport-httpclient-spring - Saga::Transports::HttpClient Spring - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.apache.servicecomb.saga - saga-core - - - org.apache.servicecomb.saga.transports - transport-httpclient - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - - junit - junit - - - com.github.tomakehurst - wiremock-standalone - - - com.github.seanyinx - unit-scaffolding - - - org.springframework - spring-test - - - - diff --git a/transports/transport-httpclient-spring/src/main/java/org/apache/servicecomb/saga/transports/HttpClientTransportConfig.java b/transports/transport-httpclient-spring/src/main/java/org/apache/servicecomb/saga/transports/HttpClientTransportConfig.java deleted file mode 100644 index a10b5c623..000000000 --- a/transports/transport-httpclient-spring/src/main/java/org/apache/servicecomb/saga/transports/HttpClientTransportConfig.java +++ /dev/null @@ -1,40 +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.transports; - -import org.apache.servicecomb.saga.transports.httpclient.HttpClientTransport; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class HttpClientTransportConfig { - - private final int requestTimeout; - - public HttpClientTransportConfig(@Value("${saga.request.timeout:30000}") int requestTimeout) { - this.requestTimeout = requestTimeout; - } - - @Bean - @ConditionalOnMissingBean(RestTransport.class) - RestTransport transport() { - return new HttpClientTransport(requestTimeout); - } -} diff --git a/transports/transport-httpclient-spring/src/main/resources/META-INF/spring.factories b/transports/transport-httpclient-spring/src/main/resources/META-INF/spring.factories deleted file mode 100644 index 6265ce1f9..000000000 --- a/transports/transport-httpclient-spring/src/main/resources/META-INF/spring.factories +++ /dev/null @@ -1,19 +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. -## --------------------------------------------------------------------------- - -org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ - org.apache.servicecomb.saga.transports.HttpClientTransportConfig diff --git a/transports/transport-httpclient-spring/src/test/java/org/apache/servicecomb/saga/transports/RestTransportTest.java b/transports/transport-httpclient-spring/src/test/java/org/apache/servicecomb/saga/transports/RestTransportTest.java deleted file mode 100644 index 2fa105d27..000000000 --- a/transports/transport-httpclient-spring/src/test/java/org/apache/servicecomb/saga/transports/RestTransportTest.java +++ /dev/null @@ -1,123 +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.transports; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static java.util.Collections.emptyMap; -import static org.apache.http.HttpStatus.SC_OK; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.net.SocketTimeoutException; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringRunner; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import org.apache.servicecomb.saga.core.TransportFailedException; - -@RunWith(SpringRunner.class) -@ContextConfiguration(classes = RestTransportTest.Config.class) -public class RestTransportTest { - - @Autowired - RestTransport transport; - - @ClassRule - public static final WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - private static final String normalResource = "/rest/normalResource"; - private static final String slowResource = "/rest/slowResource"; - - private String address; - - @BeforeClass - public static void init() throws Exception { - System.setProperty("saga.request.timeout", "1000"); - - stubFor(get(urlPathEqualTo(normalResource)) - .willReturn( - aResponse() - .withStatus(SC_OK))); - - stubFor(get(urlPathEqualTo(slowResource)) - .willReturn( - aResponse() - .withStatus(SC_OK) - .withFixedDelay(2000))); - } - - @AfterClass - public static void shutdown() throws Exception { - System.clearProperty("saga.request.timeout"); - } - - @Before - public void setUp() throws Exception { - address = "localhost" + ":" + wireMockRule.port(); - } - - @Test - public void ensureNormalRequestWorksFineWithRequestTimeout() throws Exception { - SagaResponse response = null; - try { - response = transport.with(address, normalResource, "GET", emptyMap()); - } catch (Exception e) { - fail("unexpected exception throw: " + e); - } - assertThat(response.succeeded(), is(true)); - } - - @Test - public void ensureSlowRequestFailsWithRequestTimeout() throws Exception { - try { - transport.with(address, slowResource, "GET", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(SocketTimeoutException.class.isInstance(e.getCause()), is(true)); - } - } - - @Configuration - @ComponentScan - static class Config { - @Bean - public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { - return new PropertySourcesPlaceholderConfigurer(); - } - } -} diff --git a/transports/transport-httpclient-spring/src/test/resources/log4j2.xml b/transports/transport-httpclient-spring/src/test/resources/log4j2.xml deleted file mode 100644 index 58924c686..000000000 --- a/transports/transport-httpclient-spring/src/test/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/transports/transport-httpclient/pom.xml b/transports/transport-httpclient/pom.xml deleted file mode 100644 index ee4a1747e..000000000 --- a/transports/transport-httpclient/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - transports - org.apache.servicecomb.saga.transports - 0.3.0-SNAPSHOT - - 4.0.0 - - transport-httpclient - Saga::Transports::HttpClient - - - - org.apache.servicecomb.saga - saga-core - - - org.apache.httpcomponents - fluent-hc - 4.5.3 - - - io.kamon - kamon-core_2.12 - - - io.kamon - kamon-annotation_2.12 - - - - junit - junit - - - com.github.tomakehurst - wiremock-standalone - - - com.github.seanyinx - unit-scaffolding - - - - diff --git a/transports/transport-httpclient/src/main/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransport.java b/transports/transport-httpclient/src/main/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransport.java deleted file mode 100644 index 0a9e16045..000000000 --- a/transports/transport-httpclient/src/main/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransport.java +++ /dev/null @@ -1,121 +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.transports.httpclient; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.function.Function; - -import org.apache.http.HttpResponse; -import org.apache.http.client.fluent.Form; -import org.apache.http.client.fluent.Request; -import org.apache.http.client.utils.URIBuilder; -import org.apache.http.entity.ContentType; -import org.apache.logging.log4j.core.util.IOUtils; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; - -import org.apache.servicecomb.saga.core.TransportFailedException; -import org.apache.servicecomb.saga.transports.RestTransport; -import kamon.annotation.EnableKamon; -import kamon.annotation.Segment; - -@EnableKamon -public class HttpClientTransport implements RestTransport { - - private final int requestTimeout; - private static final int DEFAULT_REQUEST_TIMEOUT = 30000; - - private static final Map> requestFactories = new HashMap>() {{ - put("GET", Request::Get); - put("POST", Request::Post); - put("PUT", Request::Put); - put("DELETE", Request::Delete); - }}; - - public HttpClientTransport() { - this(DEFAULT_REQUEST_TIMEOUT); - } - - public HttpClientTransport(int requestTimeout) { - this.requestTimeout = requestTimeout; - } - - @Segment(name = "transport", category = "network", library = "kamon") - @Override - public SagaResponse with(String address, String path, String method, Map> params) { - URIBuilder builder = new URIBuilder().setScheme("http").setHost(address).setPath(path); - - if (params.containsKey("query")) { - for (Entry entry : params.get("query").entrySet()) { - builder.addParameter(entry.getKey(), entry.getValue()); - } - } - - try { - URI uri = builder.build(); - Request request = requestFactories.getOrDefault( - method.toUpperCase(), - exceptionThrowingFunction(method)).apply(uri); - - request.socketTimeout(requestTimeout); - if (params.containsKey("json")) { - request.bodyString(params.get("json").get("body"), ContentType.APPLICATION_JSON); - } - - if (params.containsKey("form")) { - Form form = Form.form(); - for (Entry entry : params.get("form").entrySet()) { - form.add(entry.getKey(), entry.getValue()).build(); - } - request.bodyForm(form.build()); - } - - return this.on(request); - } catch (URISyntaxException e) { - throw new TransportFailedException("Wrong request URI", e); - } - } - - private Function exceptionThrowingFunction(String method) { - return u -> { - throw new TransportFailedException("No such method " + method); - }; - } - - private SagaResponse on(Request request) { - try { - HttpResponse httpResponse = request.execute().returnResponse(); - int statusCode = httpResponse.getStatusLine().getStatusCode(); - String content = IOUtils.toString(new InputStreamReader(httpResponse.getEntity().getContent())); - if (statusCode >= 200 && statusCode < 300) { - return new SuccessfulSagaResponse(content); - } - throw new TransportFailedException("The remote service returned with status code " + statusCode - + ", reason " + httpResponse.getStatusLine().getReasonPhrase() - + ", and content " + content); - } catch (IOException e) { - throw new TransportFailedException("Network Error", e); - } - } -} diff --git a/transports/transport-httpclient/src/test/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransportTest.java b/transports/transport-httpclient/src/test/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransportTest.java deleted file mode 100644 index 1c32d3eb0..000000000 --- a/transports/transport-httpclient/src/test/java/org/apache/servicecomb/saga/transports/httpclient/HttpClientTransportTest.java +++ /dev/null @@ -1,192 +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.transports.httpclient; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; -import static com.seanyinx.github.unit.scaffolding.AssertUtils.expectFailing; -import static java.util.Collections.emptyMap; -import static java.util.Collections.singletonMap; -import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR; -import static org.apache.http.HttpStatus.SC_OK; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; - -import java.net.SocketTimeoutException; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.ClassRule; -import org.junit.Test; - -import com.github.tomakehurst.wiremock.junit.WireMockRule; - -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.TransportFailedException; -import org.apache.servicecomb.saga.transports.RestTransport; - -public class HttpClientTransportTest { - - @ClassRule - public static final WireMockRule wireMockRule = new WireMockRule(wireMockConfig().dynamicPort()); - - private static final String usableResource = "/rest/usableResource"; - private static final String faultyResource = "/rest/faultyResource"; - private static final String slowResource = "/rest/slowResource"; - private static final String usableResponse = "hello world"; - private static final String faultyResponse = "no such resource"; - private static final String json = "{\"hello\", \"world\"}"; - - private String address; - - private final RestTransport transport = new HttpClientTransport(); - - @BeforeClass - public static void setUpClass() throws Exception { - stubFor(get(urlPathEqualTo(usableResource)) - .withQueryParam("foo", equalTo("bar")) - .withQueryParam("hello", equalTo("world")) - .willReturn( - aResponse() - .withStatus(SC_OK) - .withBody(usableResponse))); - - stubFor(post(urlPathEqualTo(faultyResource)) - .withQueryParam("foo", equalTo("bar")) - .withRequestBody(containing("hello=world&jesus=christ")) - .willReturn( - aResponse() - .withStatus(SC_INTERNAL_SERVER_ERROR) - .withBody(faultyResponse))); - - stubFor(put(urlPathEqualTo(usableResource)) - .withQueryParam("foo", equalTo("bar")) - .withRequestBody(equalTo(json)) - .willReturn( - aResponse() - .withStatus(SC_OK) - .withBody(usableResponse))); - - stubFor(get(urlPathEqualTo(slowResource)) - .willReturn( - aResponse() - .withStatus(SC_OK) - .withFixedDelay(2000))); - } - - @Before - public void setUp() throws Exception { - address = "localhost" + ":" + wireMockRule.port(); - } - - @Test - public void getsRequestFromRemote() { - Map> requests = singletonMap("query", map("foo", "bar", "hello", "world")); - - SagaResponse response = transport.with(address, usableResource, "GET", requests); - - assertThat(response.succeeded(), is(true)); - assertThat(response.body(), containsString(usableResponse)); - } - - @Test - public void putsRequestToRemote() { - Map> requests = new HashMap<>(); - requests.put("query", singletonMap("foo", "bar")); - requests.put("json", singletonMap("body", json)); - - SagaResponse response = transport.with(address, usableResource, "PUT", requests); - - assertThat(response.succeeded(), is(true)); - assertThat(response.body(), containsString(usableResponse)); - } - - @Test - public void blowsUpWhenRemoteResponseIsNot2XX() { - Map> requests = new HashMap<>(); - requests.put("query", singletonMap("foo", "bar")); - requests.put("form", map("hello", "world", "jesus", "christ")); - - try { - transport.with(address, faultyResource, "POST", requests); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), containsString("The remote service returned with status code 500")); - } - } - - @Test - public void blowsUpWhenRemoteIsNotReachable() { - try { - transport.with("http://somewhere:9090", faultyResource, "DELETE", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), is("Network Error")); - } - } - - @Test - public void blowsUpWhenMethodIsUnknown() { - try { - transport.with(address, usableResource, "Blah", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), is("No such method Blah")); - } - } - - @Test - public void blowsUpWhenUriIsMalformed() { - try { - transport.with("\\", usableResource, "GET", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(e.getMessage(), is("Wrong request URI")); - } - } - - @Test - public void blowsUpWhenRequestTimeout() { - HttpClientTransport transportWithShortTimeout = new HttpClientTransport(1000); - try { - transportWithShortTimeout.with(address, slowResource, "GET", emptyMap()); - expectFailing(TransportFailedException.class); - } catch (TransportFailedException e) { - assertThat(SocketTimeoutException.class.isInstance(e.getCause()), is(true)); - } - } - - private Map map(String... pairs) { - return new LinkedHashMap(){{ - for (int i = 0; i < pairs.length; i+=2) { - put(pairs[i], pairs[i + 1]); - } - }}; - } -} diff --git a/transports/transport-httpclient/src/test/resources/log4j2.xml b/transports/transport-httpclient/src/test/resources/log4j2.xml deleted file mode 100644 index 58924c686..000000000 --- a/transports/transport-httpclient/src/test/resources/log4j2.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/transports/transport-resttemplate/pom.xml b/transports/transport-resttemplate/pom.xml deleted file mode 100644 index c03ecb59a..000000000 --- a/transports/transport-resttemplate/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - transports - org.apache.servicecomb.saga.transports - 0.3.0-SNAPSHOT - - 4.0.0 - - transport-resttemplate - Saga::Transports::RestTemplate - - - - - org.springframework.boot - spring-boot-dependencies - ${spring.boot.version} - pom - import - - - - - - - org.apache.servicecomb.saga - saga-core - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-logging - - - - - - diff --git a/transports/transport-resttemplate/src/main/java/org/apache/servicecomb/saga/transports/resttemplate/RestTemplateTransport.java b/transports/transport-resttemplate/src/main/java/org/apache/servicecomb/saga/transports/resttemplate/RestTemplateTransport.java deleted file mode 100644 index 86f7ec798..000000000 --- a/transports/transport-resttemplate/src/main/java/org/apache/servicecomb/saga/transports/resttemplate/RestTemplateTransport.java +++ /dev/null @@ -1,121 +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.transports.resttemplate; - -import static java.util.Collections.emptyMap; -import static org.springframework.http.HttpMethod.DELETE; -import static org.springframework.http.HttpMethod.GET; -import static org.springframework.http.HttpMethod.POST; -import static org.springframework.http.HttpMethod.PUT; -import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED; -import static org.springframework.http.MediaType.APPLICATION_JSON; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.function.BiFunction; - -import org.apache.servicecomb.saga.core.SagaRequest; -import org.apache.servicecomb.saga.core.SagaResponse; -import org.apache.servicecomb.saga.core.SuccessfulSagaResponse; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.ClientHttpResponse; -import org.springframework.web.client.ResponseErrorHandler; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import org.apache.servicecomb.saga.core.TransportFailedException; -import org.apache.servicecomb.saga.transports.RestTransport; - -public class RestTemplateTransport implements RestTransport { - - private final String protocol; - private final RestTemplate restTemplate; - private final Map>, ResponseEntity>> methodMapping = new HashMap<>(); - - public RestTemplateTransport(RestTemplate restTemplate, String protocol) { - this.protocol = protocol; - this.restTemplate = restTemplate; - this.restTemplate.setErrorHandler(new ResponseErrorHandler() { - @Override - public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException { - return false; - } - - @Override - public void handleError(ClientHttpResponse clientHttpResponse) throws IOException { - } - }); - - methodMapping.put(GET.name(), exchange(GET)); - methodMapping.put(PUT.name(), exchange(PUT)); - methodMapping.put(POST.name(), exchange(POST)); - methodMapping.put(DELETE.name(), exchange(DELETE)); - } - - @Override - public SagaResponse with(String address, String path, String method, Map> params) { - String url = buildUrl(address, path, params); - - try { - ResponseEntity responseEntity = methodHandler(method).apply(url, params); - return new SuccessfulSagaResponse(responseEntity.getBody()); - } catch (Throwable e) { - throw new TransportFailedException( - String.format("The remote service %s failed to serve the %s request to %s ", address, method, path), - e); - } - } - - private String buildUrl(String address, String path, Map> params) { - UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath(path); - params.getOrDefault(SagaRequest.PARAM_QUERY, emptyMap()) - .forEach(uriComponentsBuilder::queryParam); - - return protocol + address + uriComponentsBuilder.build().toString(); - } - - private BiFunction>, ResponseEntity> methodHandler(String method) { - return methodMapping.getOrDefault(method.toUpperCase(), (url, params) -> { - throw new TransportFailedException("No such method " + method); - }); - } - - private BiFunction>, ResponseEntity> exchange(HttpMethod method) { - return (url, params) -> restTemplate.exchange(url, method, request(params), String.class); - } - - private HttpEntity request(Map> params) { - HttpHeaders headers = new HttpHeaders(); - - if (params.containsKey(SagaRequest.PARAM_JSON)) { - headers.setContentType(APPLICATION_JSON); - return new HttpEntity<>(params.get(SagaRequest.PARAM_JSON).get(SagaRequest.PARAM_JSON_BODY), headers); - } - - if (params.containsKey(SagaRequest.PARAM_FORM)) { - headers.setContentType(APPLICATION_FORM_URLENCODED); - return new HttpEntity<>(params.get(SagaRequest.PARAM_FORM), headers); - } - - return null; - } -} diff --git a/saga-web/pom.xml b/web/pom.xml similarity index 97% rename from saga-web/pom.xml rename to web/pom.xml index 007e6d0e8..83d39b58a 100644 --- a/saga-web/pom.xml +++ b/web/pom.xml @@ -21,13 +21,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> saga - org.apache.servicecomb.saga + org.apache.servicecomb.pack 0.3.0-SNAPSHOT 4.0.0 - saga-web - Saga::Web + pack-web + Pack::Web diff --git a/saga-web/src/main/java/org/apache/servicecomb/saga/web/SagaWebApplication.java b/web/src/main/java/org/apache/servicecomb/saga/web/SagaWebApplication.java similarity index 100% rename from saga-web/src/main/java/org/apache/servicecomb/saga/web/SagaWebApplication.java rename to web/src/main/java/org/apache/servicecomb/saga/web/SagaWebApplication.java diff --git a/saga-web/src/main/resources/application.yaml b/web/src/main/resources/application.yaml similarity index 100% rename from saga-web/src/main/resources/application.yaml rename to web/src/main/resources/application.yaml diff --git a/saga-web/src/main/resources/microservice.yaml b/web/src/main/resources/microservice.yaml similarity index 100% rename from saga-web/src/main/resources/microservice.yaml rename to web/src/main/resources/microservice.yaml diff --git a/saga-web/src/main/resources/saga-frontend/README.md b/web/src/main/resources/saga-frontend/README.md similarity index 100% rename from saga-web/src/main/resources/saga-frontend/README.md rename to web/src/main/resources/saga-frontend/README.md diff --git a/saga-web/src/main/resources/saga-frontend/angular.json b/web/src/main/resources/saga-frontend/angular.json similarity index 100% rename from saga-web/src/main/resources/saga-frontend/angular.json rename to web/src/main/resources/saga-frontend/angular.json diff --git a/saga-web/src/main/resources/saga-frontend/package.json b/web/src/main/resources/saga-frontend/package.json similarity index 100% rename from saga-web/src/main/resources/saga-frontend/package.json rename to web/src/main/resources/saga-frontend/package.json diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/core.module.ts b/web/src/main/resources/saga-frontend/src/app/@core/core.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/core.module.ts rename to web/src/main/resources/saga-frontend/src/app/@core/core.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/data/data.module.ts b/web/src/main/resources/saga-frontend/src/app/@core/data/data.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/data/data.module.ts rename to web/src/main/resources/saga-frontend/src/app/@core/data/data.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/data/saga-events.service.ts b/web/src/main/resources/saga-frontend/src/app/@core/data/saga-events.service.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/data/saga-events.service.ts rename to web/src/main/resources/saga-frontend/src/app/@core/data/saga-events.service.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/data/state.service.ts b/web/src/main/resources/saga-frontend/src/app/@core/data/state.service.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/data/state.service.ts rename to web/src/main/resources/saga-frontend/src/app/@core/data/state.service.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/module-import-guard.ts b/web/src/main/resources/saga-frontend/src/app/@core/module-import-guard.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/module-import-guard.ts rename to web/src/main/resources/saga-frontend/src/app/@core/module-import-guard.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/utils/analytics.service.ts b/web/src/main/resources/saga-frontend/src/app/@core/utils/analytics.service.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/utils/analytics.service.ts rename to web/src/main/resources/saga-frontend/src/app/@core/utils/analytics.service.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@core/utils/util.service.ts b/web/src/main/resources/saga-frontend/src/app/@core/utils/util.service.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@core/utils/util.service.ts rename to web/src/main/resources/saga-frontend/src/app/@core/utils/util.service.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/footer/footer.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.html b/web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.html rename to web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/header/header.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/index.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/index.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/index.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/index.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/switcher/switcher.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-settings/theme-settings.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.html b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.html rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/theme-switcher.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/theme-switcher-list.component.scss b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/theme-switcher-list.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/theme-switcher-list.component.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/theme-switcher-list.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts b/web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/components/theme-switcher/themes-switcher-list/themes-switcher-list.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.scss b/web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.ts b/web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/layouts/default/default.layout.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/index.ts b/web/src/main/resources/saga-frontend/src/app/@theme/layouts/index.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/index.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/layouts/index.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.scss b/web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.ts b/web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/layouts/one-column/one-column.layout.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/capitalize.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/capitalize.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/capitalize.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/capitalize.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/index.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/index.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/index.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/index.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/no-sanitize.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/no-sanitize.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/no-sanitize.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/no-sanitize.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/number-with-commas.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/number-with-commas.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/number-with-commas.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/number-with-commas.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/plural.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/plural.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/plural.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/plural.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/round.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/round.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/round.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/round.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/timing.pipe.ts b/web/src/main/resources/saga-frontend/src/app/@theme/pipes/timing.pipe.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/pipes/timing.pipe.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/pipes/timing.pipe.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/bootstrap-rtl.scss b/web/src/main/resources/saga-frontend/src/app/@theme/styles/bootstrap-rtl.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/bootstrap-rtl.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/bootstrap-rtl.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/font-size.scss b/web/src/main/resources/saga-frontend/src/app/@theme/styles/font-size.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/font-size.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/font-size.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/pace.theme.scss b/web/src/main/resources/saga-frontend/src/app/@theme/styles/pace.theme.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/pace.theme.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/pace.theme.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/styles.scss b/web/src/main/resources/saga-frontend/src/app/@theme/styles/styles.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/styles.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/styles.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.corporate.ts b/web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.corporate.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.corporate.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.corporate.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.cosmic.ts b/web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.cosmic.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.cosmic.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.cosmic.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.default.ts b/web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.default.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.default.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/theme.default.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/themes.scss b/web/src/main/resources/saga-frontend/src/app/@theme/styles/themes.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/styles/themes.scss rename to web/src/main/resources/saga-frontend/src/app/@theme/styles/themes.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/@theme/theme.module.ts b/web/src/main/resources/saga-frontend/src/app/@theme/theme.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/@theme/theme.module.ts rename to web/src/main/resources/saga-frontend/src/app/@theme/theme.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/app-routing.module.ts b/web/src/main/resources/saga-frontend/src/app/app-routing.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/app-routing.module.ts rename to web/src/main/resources/saga-frontend/src/app/app-routing.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/app.component.ts b/web/src/main/resources/saga-frontend/src/app/app.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/app.component.ts rename to web/src/main/resources/saga-frontend/src/app/app.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/app.module.ts b/web/src/main/resources/saga-frontend/src/app/app.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/app.module.ts rename to web/src/main/resources/saga-frontend/src/app/app.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.html b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.scss b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.scss rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/count-cards/count-cards.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.html b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.scss b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.scss rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/dashboard.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.html b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.scss b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.scss rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/dashboard/recent-table/recent-table.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous-routing.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous-routing.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous-routing.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous-routing.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/miscellaneous.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.html b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.scss b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.scss rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/miscellaneous/not-found/not-found.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/pages-menu.ts b/web/src/main/resources/saga-frontend/src/app/pages/pages-menu.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/pages-menu.ts rename to web/src/main/resources/saga-frontend/src/app/pages/pages-menu.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/pages-routing.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/pages-routing.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/pages-routing.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/pages-routing.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/pages.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/pages.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/pages.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/pages.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/pages.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/pages.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/pages.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/pages.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/customRender.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/transactions/customRender.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/customRender.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/customRender.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.html b/web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/findTransaction.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.html b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.module.ts b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.module.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.module.ts rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactions.module.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.html b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.html rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.html diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.scss b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.scss similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.scss rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.scss diff --git a/saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.ts b/web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.ts rename to web/src/main/resources/saga-frontend/src/app/pages/transactions/transactionsTable.component.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/assets/images/square_pattern.svg b/web/src/main/resources/saga-frontend/src/assets/images/square_pattern.svg similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/assets/images/square_pattern.svg rename to web/src/main/resources/saga-frontend/src/assets/images/square_pattern.svg diff --git a/saga-web/src/main/resources/saga-frontend/src/assets/images/square_pattern_cosmic.svg b/web/src/main/resources/saga-frontend/src/assets/images/square_pattern_cosmic.svg similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/assets/images/square_pattern_cosmic.svg rename to web/src/main/resources/saga-frontend/src/assets/images/square_pattern_cosmic.svg diff --git a/saga-web/src/main/resources/saga-frontend/src/environments/environment.prod.ts b/web/src/main/resources/saga-frontend/src/environments/environment.prod.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/environments/environment.prod.ts rename to web/src/main/resources/saga-frontend/src/environments/environment.prod.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/environments/environment.ts b/web/src/main/resources/saga-frontend/src/environments/environment.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/environments/environment.ts rename to web/src/main/resources/saga-frontend/src/environments/environment.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/favicon.ico b/web/src/main/resources/saga-frontend/src/favicon.ico similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/favicon.ico rename to web/src/main/resources/saga-frontend/src/favicon.ico diff --git a/saga-web/src/main/resources/saga-frontend/src/favicon.png b/web/src/main/resources/saga-frontend/src/favicon.png similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/favicon.png rename to web/src/main/resources/saga-frontend/src/favicon.png diff --git a/saga-web/src/main/resources/saga-frontend/src/index.html b/web/src/main/resources/saga-frontend/src/index.html similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/index.html rename to web/src/main/resources/saga-frontend/src/index.html diff --git a/saga-web/src/main/resources/saga-frontend/src/main.ts b/web/src/main/resources/saga-frontend/src/main.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/main.ts rename to web/src/main/resources/saga-frontend/src/main.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/polyfills.ts b/web/src/main/resources/saga-frontend/src/polyfills.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/polyfills.ts rename to web/src/main/resources/saga-frontend/src/polyfills.ts diff --git a/saga-web/src/main/resources/saga-frontend/src/tsconfig.app.json b/web/src/main/resources/saga-frontend/src/tsconfig.app.json similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/tsconfig.app.json rename to web/src/main/resources/saga-frontend/src/tsconfig.app.json diff --git a/saga-web/src/main/resources/saga-frontend/src/typings.d.ts b/web/src/main/resources/saga-frontend/src/typings.d.ts similarity index 100% rename from saga-web/src/main/resources/saga-frontend/src/typings.d.ts rename to web/src/main/resources/saga-frontend/src/typings.d.ts diff --git a/saga-web/src/main/resources/saga-frontend/tsconfig.json b/web/src/main/resources/saga-frontend/tsconfig.json similarity index 100% rename from saga-web/src/main/resources/saga-frontend/tsconfig.json rename to web/src/main/resources/saga-frontend/tsconfig.json diff --git a/saga-web/src/main/resources/static/css/request.css b/web/src/main/resources/static/css/request.css similarity index 100% rename from saga-web/src/main/resources/static/css/request.css rename to web/src/main/resources/static/css/request.css diff --git a/saga-web/src/main/resources/static/css/style.css b/web/src/main/resources/static/css/style.css similarity index 100% rename from saga-web/src/main/resources/static/css/style.css rename to web/src/main/resources/static/css/style.css diff --git a/saga-web/src/main/resources/static/detail.html b/web/src/main/resources/static/detail.html similarity index 100% rename from saga-web/src/main/resources/static/detail.html rename to web/src/main/resources/static/detail.html diff --git a/saga-web/src/main/resources/static/index.html b/web/src/main/resources/static/index.html similarity index 100% rename from saga-web/src/main/resources/static/index.html rename to web/src/main/resources/static/index.html diff --git a/saga-web/src/main/resources/static/js/date.js b/web/src/main/resources/static/js/date.js similarity index 100% rename from saga-web/src/main/resources/static/js/date.js rename to web/src/main/resources/static/js/date.js diff --git a/saga-web/src/main/resources/static/js/request.js b/web/src/main/resources/static/js/request.js similarity index 100% rename from saga-web/src/main/resources/static/js/request.js rename to web/src/main/resources/static/js/request.js diff --git a/saga-web/src/main/resources/static/js/table.js b/web/src/main/resources/static/js/table.js similarity index 100% rename from saga-web/src/main/resources/static/js/table.js rename to web/src/main/resources/static/js/table.js diff --git a/saga-web/src/main/resources/static/request.html b/web/src/main/resources/static/request.html similarity index 100% rename from saga-web/src/main/resources/static/request.html rename to web/src/main/resources/static/request.html diff --git a/saga-web/src/main/resources/static/result.html b/web/src/main/resources/static/result.html similarity index 100% rename from saga-web/src/main/resources/static/result.html rename to web/src/main/resources/static/result.html