From e534200f9ad94003a5864ee56968f29d53e0b20d Mon Sep 17 00:00:00 2001 From: Mikhail Petrov <32207922+ololo3000@users.noreply.github.com> Date: Thu, 27 Jan 2022 10:20:24 +0300 Subject: [PATCH] IGNITE-15753 Adds Spring version compatibility tests for cache and tx integrations. (#80) --- modules/spring-cache-ext/pom.xml | 36 +++ .../test/java/config/ignite-client-node.xml | 59 ++++ .../IgniteSpringCacheCompatibilityTest.java | 277 ++++++++++++++++++ .../IgniteSpringCacheTestSuite.java | 4 +- modules/spring-tx-ext/pom.xml | 43 +++ .../test/java/config/ignite-client-node.xml | 53 ++++ .../IgniteSpringTransactionsTestSuite.java | 4 +- ...teSpringTransactionsCompatibilityTest.java | 265 +++++++++++++++++ 8 files changed, 739 insertions(+), 2 deletions(-) create mode 100644 modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml create mode 100644 modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java create mode 100644 modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml create mode 100644 modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java diff --git a/modules/spring-cache-ext/pom.xml b/modules/spring-cache-ext/pom.xml index c7c399ed..37a1441a 100644 --- a/modules/spring-cache-ext/pom.xml +++ b/modules/spring-cache-ext/pom.xml @@ -68,6 +68,14 @@ provided + + org.apache.ignite + ignite-compatibility + ${ignite.version} + test-jar + test + + org.apache.ignite ignite-log4j @@ -91,7 +99,35 @@ + + + + maven-redhat-repo-id + maven-redhat-repo-name + https://origin-maven.repository.redhat.com/ga + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + 1 + + + + src/test/java diff --git a/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml b/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml new file mode 100644 index 00000000..58198812 --- /dev/null +++ b/modules/spring-cache-ext/src/test/java/config/ignite-client-node.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 127.0.0.1:47500..47509 + + + + + + + + diff --git a/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java b/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java new file mode 100644 index 00000000..81f08290 --- /dev/null +++ b/modules/spring-cache-ext/src/test/java/org/apache/ignite/cache/spring/IgniteSpringCacheCompatibilityTest.java @@ -0,0 +1,277 @@ +/* + * 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.ignite.cache.spring; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.Ignition; +import org.apache.ignite.client.ClientCache; +import org.apache.ignite.client.IgniteClient; +import org.apache.ignite.compatibility.testframework.junits.Dependency; +import org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest; +import org.apache.ignite.configuration.BinaryConfiguration; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.GridJavaProcess; +import org.apache.ignite.internal.util.typedef.F; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_11_0; +import static org.apache.ignite.compatibility.IgniteReleasedVersion.since; +import static org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT; +import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR; +import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; + +/** */ +@RunWith(Parameterized.class) +public class IgniteSpringCacheCompatibilityTest extends IgniteCompatibilityAbstractTest { + /** */ + private static final Collection TEST_SPRING_VERSIONS = Arrays.asList( + "4.3.0.RELEASE", + "5.0.0.RELEASE", + "5.1.0.RELEASE", + "5.2.0.RELEASE", + "5.3.0" + ); + + /** */ + private static final String TEST_CACHE_NAME = "testCache"; + + /** */ + @Parameterized.Parameters(name = "Ignite Version {0}, Spring Version {1}") + public static Iterable versions() { + return cartesianProduct(F.concat(true, VER_STR, since(VER_2_11_0)), TEST_SPRING_VERSIONS); + } + + /** */ + @Parameterized.Parameter + public String igniteVer; + + /** */ + @Parameterized.Parameter(1) + public String springVer; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected @NotNull Collection getDependencies(String ver) { + if (!F.isEmpty(ver)) + return super.getDependencies(ver); + + Collection res = new ArrayList<>(); + + res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, false)); + res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, true)); + res.add(new Dependency("spring", "org.apache.ignite", "ignite-spring", igniteVer, false)); + + res.add(new Dependency("spring-context", "org.springframework", "spring-context", springVer, false)); + res.add(new Dependency("spring-beans", "org.springframework", "spring-beans", springVer, false)); + res.add(new Dependency("spring-core", "org.springframework", "spring-core", springVer, false)); + res.add(new Dependency("spring-aop", "org.springframework", "spring-aop", springVer, false)); + res.add(new Dependency("spring-expression", "org.springframework", "spring-expression", springVer, false)); + + if (VER_2_11_0.toString().equals(igniteVer)) { + res.add(new Dependency("spring-tx", "org.springframework", "spring-tx", springVer, false)); + res.add(new Dependency("spring-jdbc", "org.springframework", "spring-jdbc", springVer, false)); + } + + return res; + } + + /** */ + protected void processNodeConfiguration(IgniteConfiguration cfg) { + cfg.setCacheConfiguration(new CacheConfiguration<>(TEST_CACHE_NAME)) + .setBinaryConfiguration(new BinaryConfiguration() + .setCompactFooter(true)); + } + + /** */ + @Test + public void testCompatibility() throws Exception { + startGrid(1, igniteVer, this::processNodeConfiguration, ignite -> {}); + + GridJavaProcess proc = GridJavaProcess.exec( + TestRunner.class.getName(), + "", + log, + log::info, + null, + null, + getProcessProxyJvmArgs(""), + null + ); + + try { + assertTrue(waitForCondition(() -> !proc.getProcess().isAlive(), getTestTimeout())); + + assertEquals(0, proc.getProcess().exitValue()); + } + finally { + if (proc.getProcess().isAlive()) + proc.kill(); + } + } + + /** */ + public static class TestRunner { + /** */ + private static void doIgniteClientConnectionTest() { + try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) { + ctx.register(ClientInstanceApplicationContext.class); + ctx.refresh(); + + GridSpringCacheTestService svc = ctx.getBean(GridSpringCacheTestService.class); + + IgniteClient cli = ctx.getBean(IgniteClient.class); + + ClientCache cache = cli.cache(TEST_CACHE_NAME); + + cache.clear(); + svc.reset(); + + for (int i = 0; i < 3; i++) { + assertEquals("value" + i, svc.simpleKey(i)); + assertEquals("value" + i, svc.simpleKey(i)); + } + + assertEquals(3, svc.called()); + assertEquals(3, cache.size()); + + for (int i = 0; i < 3; i++) + assertEquals("value" + i, cache.get(i)); + } + } + + /** */ + private static void doIgniteNodeConnectionTest() { + try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) { + ctx.register(IgniteNodeApplicationContext.class); + ctx.refresh(); + + GridSpringCacheTestService svc = ctx.getBean(GridSpringCacheTestService.class); + + Ignite cli = ctx.getBean(Ignite.class); + + IgniteCache cache = cli.cache(TEST_CACHE_NAME); + + cache.clear(); + svc.reset(); + + for (int i = 0; i < 3; i++) { + assertEquals("value" + i, svc.simpleKey(i)); + assertEquals("value" + i, svc.simpleKey(i)); + } + + assertEquals(3, svc.called()); + assertEquals(3, cache.size()); + + for (int i = 0; i < 3; i++) + assertEquals("value" + i, cache.get(i)); + } + } + + /** */ + public static void main(String[] args) { + doIgniteNodeConnectionTest(); + + doIgniteClientConnectionTest(); + } + + /** */ + @Configuration + @EnableCaching + public static class ClientInstanceApplicationContext extends CachingConfigurerSupport { + /** */ + @Bean + public GridSpringCacheTestService cacheService() { + return new GridSpringCacheTestService(); + } + + /** */ + @Bean + public IgniteClient igniteClient() { + return Ignition.startClient(new ClientConfiguration() + .setAddresses("127.0.0.1:" + DFLT_PORT) + .setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(true))); + } + + /** */ + @Bean + public AbstractCacheManager cacheManager(IgniteClient cli) { + return new IgniteClientSpringCacheManager().setClientInstance(cli); + } + + /** {@inheritDoc} */ + @Override public KeyGenerator keyGenerator() { + return new GridSpringCacheTestKeyGenerator(); + } + } + + /** */ + @Configuration + @EnableCaching + public static class IgniteNodeApplicationContext extends CachingConfigurerSupport { + /** */ + @Bean + public GridSpringCacheTestService cacheService() { + return new GridSpringCacheTestService(); + } + + /** */ + @Bean + public Ignite igniteInstance() { + return Ignition.start("config/ignite-client-node.xml"); + } + + /** */ + @Bean + @Override public AbstractCacheManager cacheManager() { + SpringCacheManager mgr = new SpringCacheManager(); + + mgr.setIgniteInstanceName("ignite-client-node"); + + return mgr; + } + + /** {@inheritDoc} */ + @Override public KeyGenerator keyGenerator() { + return new GridSpringCacheTestKeyGenerator(); + } + } + } +} + diff --git a/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java b/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java index 0c5dc9ed..560df16e 100644 --- a/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java +++ b/modules/spring-cache-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringCacheTestSuite.java @@ -21,6 +21,7 @@ import org.apache.ignite.cache.spring.GridSpringCacheManagerSelfTest; import org.apache.ignite.cache.spring.GridSpringCacheManagerSpringBeanSelfTest; import org.apache.ignite.cache.spring.IgniteClientSpringCacheManagerTest; +import org.apache.ignite.cache.spring.IgniteSpringCacheCompatibilityTest; import org.apache.ignite.cache.spring.SpringCacheManagerContextInjectionTest; import org.apache.ignite.cache.spring.SpringCacheTest; import org.junit.runner.RunWith; @@ -36,7 +37,8 @@ SpringCacheManagerContextInjectionTest.class, SpringCacheTest.class, GridSpringCacheManagerMultiJvmSelfTest.class, - IgniteClientSpringCacheManagerTest.class + IgniteClientSpringCacheManagerTest.class, + IgniteSpringCacheCompatibilityTest.class }) public class IgniteSpringCacheTestSuite { } diff --git a/modules/spring-tx-ext/pom.xml b/modules/spring-tx-ext/pom.xml index 268c6a10..530d3f8f 100644 --- a/modules/spring-tx-ext/pom.xml +++ b/modules/spring-tx-ext/pom.xml @@ -91,6 +91,21 @@ test + + com.thoughtworks.xstream + xstream + ${xstream.version} + test + + + + org.apache.ignite + ignite-compatibility + ${ignite.version} + test-jar + test + + org.apache.ignite ignite-spring-data-commons @@ -99,7 +114,35 @@ + + + + maven-redhat-repo-id + maven-redhat-repo-name + https://origin-maven.repository.redhat.com/ga + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + false + 1 + + + + src/test/java diff --git a/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml b/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml new file mode 100644 index 00000000..6bc9587d --- /dev/null +++ b/modules/spring-tx-ext/src/test/java/config/ignite-client-node.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + 127.0.0.1:47500..47509 + + + + + + + + diff --git a/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java b/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java index 40341112..643d71ee 100644 --- a/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java +++ b/modules/spring-tx-ext/src/test/java/org/apache/ignite/testsuites/IgniteSpringTransactionsTestSuite.java @@ -21,6 +21,7 @@ import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSelfTest; import org.apache.ignite.transactions.spring.GridSpringTransactionManagerSpringBeanSelfTest; import org.apache.ignite.transactions.spring.IgniteClientSpringTransactionManagerTest; +import org.apache.ignite.transactions.spring.IgniteSpringTransactionsCompatibilityTest; import org.apache.ignite.transactions.spring.SpringTransactionManagerContextInjectionTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @@ -34,7 +35,8 @@ GridSpringTransactionManagerSpringBeanSelfTest.class, IgniteClientSpringTransactionManagerTest.class, SpringTransactionManagerContextInjectionTest.class, - CacheSpringStoreSessionListenerSelfTest.class + CacheSpringStoreSessionListenerSelfTest.class, + IgniteSpringTransactionsCompatibilityTest.class }) public class IgniteSpringTransactionsTestSuite { } diff --git a/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java b/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java new file mode 100644 index 00000000..3ca27335 --- /dev/null +++ b/modules/spring-tx-ext/src/test/java/org/apache/ignite/transactions/spring/IgniteSpringTransactionsCompatibilityTest.java @@ -0,0 +1,265 @@ +/* + * 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.ignite.transactions.spring; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.Ignition; +import org.apache.ignite.client.ClientCache; +import org.apache.ignite.client.IgniteClient; +import org.apache.ignite.compatibility.testframework.junits.Dependency; +import org.apache.ignite.compatibility.testframework.junits.IgniteCompatibilityAbstractTest; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.ClientConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.GridJavaProcess; +import org.apache.ignite.internal.util.typedef.F; +import org.apache.ignite.lang.IgniteProductVersion; +import org.apache.ignite.springdata.proxy.IgniteCacheProxy; +import org.apache.ignite.springdata.proxy.IgniteClientCacheProxy; +import org.apache.ignite.springdata.proxy.IgniteNodeCacheProxy; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.springframework.context.annotation.AnnotationConfigApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.annotation.EnableTransactionManagement; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_11_0; +import static org.apache.ignite.compatibility.IgniteReleasedVersion.VER_2_8_0; +import static org.apache.ignite.compatibility.IgniteReleasedVersion.since; +import static org.apache.ignite.configuration.ClientConnectorConfiguration.DFLT_PORT; +import static org.apache.ignite.internal.IgniteVersionUtils.VER_STR; +import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; +import static org.apache.ignite.testframework.GridTestUtils.cartesianProduct; +import static org.apache.ignite.testframework.GridTestUtils.waitForCondition; + +/** */ +@RunWith(Parameterized.class) +public class IgniteSpringTransactionsCompatibilityTest extends IgniteCompatibilityAbstractTest { + /** */ + private static final Collection TEST_SPRING_VERSIONS = Arrays.asList( + "4.3.0.RELEASE", + "5.0.0.RELEASE", + "5.1.0.RELEASE", + "5.2.0.RELEASE", + "5.3.0" + ); + + /** */ + private static final String TEST_CACHE_NAME = "testCache"; + + /** */ + @Parameterized.Parameters(name = "IgniteVersion={0}, SpringVersion={1}") + public static Iterable versions() { + return cartesianProduct(F.concat(true, VER_STR, since(VER_2_8_0)), TEST_SPRING_VERSIONS); + + } + + /** */ + @Parameterized.Parameter + public String igniteVer; + + /** */ + @Parameterized.Parameter(1) + public String springVer; + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** {@inheritDoc} */ + @Override protected @NotNull Collection getDependencies(String ver) { + if (!F.isEmpty(ver)) + return super.getDependencies(ver); + + Collection res = new ArrayList<>(); + + res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, false)); + res.add(new Dependency("core", "org.apache.ignite", "ignite-core", igniteVer, true)); + res.add(new Dependency("spring", "org.apache.ignite", "ignite-spring", igniteVer, false)); + + res.add(new Dependency("spring-tx", "org.springframework", "spring-tx", springVer, false)); + res.add(new Dependency("spring-context", "org.springframework", "spring-context", springVer, false)); + res.add(new Dependency("spring-beans", "org.springframework", "spring-beans", springVer, false)); + res.add(new Dependency("spring-core", "org.springframework", "spring-core", springVer, false)); + res.add(new Dependency("spring-aop", "org.springframework", "spring-aop", springVer, false)); + res.add(new Dependency("spring-expression", "org.springframework", "spring-expression", springVer, false)); + + if (IgniteProductVersion.fromString(igniteVer).compareTo(VER_2_11_0.version()) <= 0) + res.add(new Dependency("spring-jdbc", "org.springframework", "spring-jdbc", springVer, false)); + + return res; + } + + /** */ + protected void processNodeConfiguration(IgniteConfiguration cfg) { + cfg.setCacheConfiguration(new CacheConfiguration<>(TEST_CACHE_NAME) + .setAtomicityMode(TRANSACTIONAL)); + } + + /** */ + @Test + public void testCompatibility() throws Exception { + startGrid(1, igniteVer, this::processNodeConfiguration, ignite -> {}); + + GridJavaProcess proc = GridJavaProcess.exec( + TestRunner.class.getName(), + "", + log, + log::info, + null, + null, + getProcessProxyJvmArgs(""), + null + ); + + try { + assertTrue(waitForCondition(() -> !proc.getProcess().isAlive(), getTestTimeout())); + + assertEquals(0, proc.getProcess().exitValue()); + } + finally { + if (proc.getProcess().isAlive()) + proc.kill(); + } + } + + /** */ + public static class TestRunner { + /** */ + private static void doIgniteClientConnectionTest() { + try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) { + ctx.register(IgniteClientSpringTransactionManagerApplicationContext.class); + ctx.refresh(); + + GridSpringTransactionService svc = ctx.getBean(GridSpringTransactionService.class); + + IgniteClient cli = ctx.getBean(IgniteClient.class); + + ClientCache cache = cli.cache(TEST_CACHE_NAME); + + cache.clear(); + + IgniteCacheProxy cacheProxy = new IgniteClientCacheProxy<>(cache); + + svc.put(cacheProxy, 1); + + assertThrowsWithCause(() -> svc.putWithError(cacheProxy, 1), NumberFormatException.class); + + assertEquals(1, cache.size()); + } + } + + /** */ + private static void doIgniteNodeConnectionTest() { + try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) { + ctx.register(IgniteNodeSpringTransactionManagerApplicationContext.class); + ctx.refresh(); + + GridSpringTransactionService svc = ctx.getBean(GridSpringTransactionService.class); + + Ignite cli = ctx.getBean(Ignite.class); + + IgniteCache cache = cli.cache(TEST_CACHE_NAME); + + cache.clear(); + + IgniteCacheProxy cacheProxy = new IgniteNodeCacheProxy<>(cache); + + svc.put(cacheProxy, 1); + + assertThrowsWithCause(() -> svc.putWithError(cacheProxy, 1), NumberFormatException.class); + + assertEquals(1, cache.size()); + } + } + + /** */ + public static void main(String[] args) { + doIgniteNodeConnectionTest(); + + doIgniteClientConnectionTest(); + } + + /** */ + @Configuration + @EnableTransactionManagement + public static class IgniteNodeSpringTransactionManagerApplicationContext { + /** */ + @Bean + public GridSpringTransactionService transactionService() { + return new GridSpringTransactionService(); + } + + /** */ + @Bean + public Ignite ignite() { + return Ignition.start("config/ignite-client-node.xml"); + } + + /** */ + @Bean + public AbstractSpringTransactionManager transactionManager() { + SpringTransactionManager mgr = new SpringTransactionManager(); + + mgr.setIgniteInstanceName("ignite-client-node"); + + return mgr; + } + } + + /** */ + @Configuration + @EnableTransactionManagement + public static class IgniteClientSpringTransactionManagerApplicationContext { + /** */ + @Bean + public GridSpringTransactionService transactionService() { + return new GridSpringTransactionService(); + } + + /** */ + @Bean + public IgniteClient igniteClient() { + return Ignition.startClient(new ClientConfiguration() + .setAddresses("127.0.0.1:" + DFLT_PORT)); + } + + /** */ + @Bean + public AbstractSpringTransactionManager transactionManager(IgniteClient cli) { + IgniteClientSpringTransactionManager mgr = new IgniteClientSpringTransactionManager(); + + mgr.setClientInstance(cli); + + return mgr; + } + } + } +} +