diff --git a/.github/scripts/quickstart.sh b/.github/scripts/quickstart.sh index 18fdf96d84..cb35952622 100755 --- a/.github/scripts/quickstart.sh +++ b/.github/scripts/quickstart.sh @@ -95,35 +95,29 @@ function build_narayana_lra { # INITIALIZE LRA ENV export MAVEN_OPTS="-Xmx1024m -XX:MaxMetaspaceSize=512m" - LRA_BRANCH=main + LRA_REPO=${LRA_REPO:-jbosstm} + LRA_BRANCH=${LRA_BRANCH:-main} #rm -rf ~/.m2/repository/ rm -rf lra - git clone https://github.com/${NARAYANA_REPO}/lra.git -b ${LRA_BRANCH} - [ $? = 0 ] || fatal "git clone https://github.com/${NARAYANA_REPO}/lra.git failed" + git clone https://github.com/${LRA_REPO}/lra.git + [ $? = 0 ] || fatal "git clone https://github.com/${LRA_REPO}/lra.git failed" echo "Checking if need Narayana LRA PR" - if [ -n "$NY_BRANCH" ]; then - echo "Building NY PR" - cd lra - git fetch origin +refs/pull/*/head:refs/remotes/jbosstm/pull/*/head - [ $? = 0 ] || fatal "git fetch of pulls failed" - git checkout $NY_BRANCH - [ $? = 0 ] || fatal "git fetch of pull branch failed" - cd ../ - fi - - if [ $? != 0 ]; then - echo "Checkout failed: $BUILD_URL"; - exit -1 - fi + echo "Building LRA PR ${LRA_BRANCH}" cd lra + git fetch origin +refs/pull/*/head:refs/remotes/jbosstm/pull/*/head + [ $? = 0 ] || fatal "git fetch of pulls failed" + git checkout $LRA_BRANCH + [ $? = 0 ] || fatal "Checkout failed: $BUILD_URL"; + ./build.sh clean install -B -DskipTests [ $LRA_CURRENT_VERSION ] || export LRA_CURRENT_VERSION=`grep "" pom.xml | head -n 2 | tail -n 1 | sed "s/ *//" | sed "s###"` - cd .. if [ $? != 0 ]; then echo "Narayana LRA build failed: $BUILD_URL"; exit -1 fi + + cd .. } function download_and_update_as { diff --git a/.github/workflows/parser.yml b/.github/workflows/parser.yml index 90750c0793..cae9099a66 100644 --- a/.github/workflows/parser.yml +++ b/.github/workflows/parser.yml @@ -101,7 +101,12 @@ jobs: core.setOutput('jdk_versions', JSON.stringify(jdk_versions)); const possibleEnvVars = [ - 'WILDFLY_RELEASE_VERSION' + 'WILDFLY_RELEASE_VERSION', + 'NARAYANA_REPO', + 'NARAYANA_BRANCH', + 'NY_BRANCH', + 'LRA_REPO', + 'LRA_BRANCH' ]; const extractedEnvVars = {}; @@ -152,4 +157,4 @@ jobs: jdk_version: ${{ matrix.jdk_version }} pull_request_ref: ${{ needs.parser.outputs.pr_ref }} pull_request_repo: ${{ needs.parser.outputs.pr_repo }} - environment_variables: ${{ needs.parser.outputs.environment_variables }} \ No newline at end of file + environment_variables: ${{ needs.parser.outputs.environment_variables }} diff --git a/ArjunaJTA/object_store/README.md b/ArjunaJTA/object_store/README.md index 2b765efe9c..55cad7044a 100644 --- a/ArjunaJTA/object_store/README.md +++ b/ArjunaJTA/object_store/README.md @@ -11,6 +11,11 @@ to cater for various application requirements. 3. VolatileStoreExample shows how to use an unsafe (because it does not persist logs in the event of failures and therefore does not support recovery) in-memory log store implementation. 4. JDBCStoreExample shows how to use a database for persisting transaction logs. This example uses [H2](https://www.h2database.com/). +5. InfinispanSlotStore shows how to use the Infinispan backed slot store. Two examples are provided, + one showing how to configure the store programmatically and the other uses a jbossts properties file. + +> **Warning** +> The InfinispanSlotStore store is an experimental feature. It is not recommended for production systems and may contain breaking changes in future releases. The ARJUNA012419 warning message is printed in the logs when the feature is used. ## Usage @@ -25,6 +30,8 @@ mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.Vol mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.HornetqStoreExample mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.FileStoreExample mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.JDBCStoreExample +mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanStoreExample +mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanStoreConfigExample ``` The JDBCStore can be configured programmatically or via a properties file. To use the properties file pass the argument `-DUSE_JBOSSTS_PROPERTIES=true` on the command line. @@ -33,6 +40,13 @@ The JDBCStore can be configured programmatically or via a properties file. To us When running examples one at a time look for the output +``` +DummyXAResource commit() called +DummyXAResource commit() called +``` + +which indicates that bother resources were asked to commit, followed by + ``` [INFO] BUILD SUCCESS ``` diff --git a/ArjunaJTA/object_store/run.bat b/ArjunaJTA/object_store/run.bat index 453fef0438..7328e26f3b 100755 --- a/ArjunaJTA/object_store/run.bat +++ b/ArjunaJTA/object_store/run.bat @@ -15,3 +15,9 @@ IF %ERRORLEVEL% NEQ 0 exit -1 mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.JDBCStoreExample %NARAYANA_VERSION_PARAM% IF %ERRORLEVEL% NEQ 0 exit -1 + +mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanSlotStoreExample %NARAYANA_VERSION_PARAM% +IF %ERRORLEVEL% NEQ 0 exit -1 + +mvn -e compile exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanSlotStoreConfigExample %NARAYANA_VERSION_PARAM% +IF %ERRORLEVEL% NEQ 0 exit -1 diff --git a/ArjunaJTA/object_store/run.sh b/ArjunaJTA/object_store/run.sh index a12e61a111..9cdf32248b 100755 --- a/ArjunaJTA/object_store/run.sh +++ b/ArjunaJTA/object_store/run.sh @@ -27,3 +27,13 @@ mvn -e exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.JDBCStoreEx if [ "$?" != "0" ]; then exit -1 fi + +mvn -e exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanSlotStoreConfigExample $NARAYANA_VERSION_PARAM +if [ "$?" != "0" ]; then + exit -1 +fi + +mvn -e exec:java -Dexec.mainClass=org.jboss.narayana.jta.quickstarts.InfinispanSlotStoreExample $NARAYANA_VERSION_PARAM +if [ "$?" != "0" ]; then + exit -1 +fi diff --git a/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreConfigExample.java b/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreConfigExample.java new file mode 100644 index 0000000000..ac56e27931 --- /dev/null +++ b/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreConfigExample.java @@ -0,0 +1,28 @@ +package org.jboss.narayana.jta.quickstarts; + +import jakarta.transaction.UserTransaction; + +import java.io.IOException; + +public class InfinispanSlotStoreConfigExample { + + public static void main(String[] args) throws Exception { + setupStore(); + + UserTransaction utx = com.arjuna.ats.jta.UserTransaction.userTransaction(); + + utx.begin(); + Util.enlistResources(); + utx.commit(); + + System.exit(0); // exit immediately + } + + public static void setupStore() throws IOException { + // expose the jbossts properties file containing the config for an infinispan based slot store + String infinispanConfigFile = "infinispan-jbossts-properties.xml"; + + System.setProperty("com.arjuna.ats.arjuna.common.propertiesFile", infinispanConfigFile); + System.setProperty("nodeName", "node1"); // infinispan-jbossts-properties.xml "reads" the nodeName + } +} \ No newline at end of file diff --git a/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreExample.java b/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreExample.java new file mode 100644 index 0000000000..df0d1ab35f --- /dev/null +++ b/ArjunaJTA/object_store/src/main/java/org/jboss/narayana/jta/quickstarts/InfinispanSlotStoreExample.java @@ -0,0 +1,84 @@ +package org.jboss.narayana.jta.quickstarts; + +import com.arjuna.ats.arjuna.common.ObjectStoreEnvironmentBean; +import com.arjuna.ats.arjuna.coordinator.TransactionReaper; +import com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor; +import com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreEnvironmentBean; +import com.arjuna.ats.internal.arjuna.objectstore.slot.infinispan.InfinispanSlots; +import com.arjuna.ats.internal.arjuna.objectstore.slot.infinispan.InfinispanStoreEnvironmentBean; +import com.arjuna.common.internal.util.propertyservice.BeanPopulator; +import jakarta.transaction.UserTransaction; +import org.infinispan.manager.DefaultCacheManager; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public class InfinispanSlotStoreExample { + private final static String CACHE_CONFIG_FILE = "/infinispan-config.xml"; + private static final String CACHE_NAME = "sharedCache"; + + private static List cacheManagers; // the cluster of infinispan cache managers + + public static void main(String[] args) throws Exception { + setupStore(); + + UserTransaction utx = com.arjuna.ats.jta.UserTransaction.userTransaction(); + + utx.begin(); + Util.enlistResources(); + utx.commit(); + + shutdownStore(); + + System.exit(0); // exit immediately + } + + public static void setupStore() throws IOException { + // common config for each slot store + SlotStoreEnvironmentBean slotStoreConfig = BeanPopulator.getDefaultInstance(SlotStoreEnvironmentBean.class); + InfinispanStoreEnvironmentBean config = BeanPopulator.getDefaultInstance(InfinispanStoreEnvironmentBean.class); + + cacheManagers = new ArrayList<>(); + + var manager = createCacheManager(); + var slots = new InfinispanSlots(); // slot store backed by an infinispan cache + + config.setNumberOfSlots(slotStoreConfig.getNumberOfSlots()); + config.setBytesPerSlot(slotStoreConfig.getBytesPerSlot()); + config.setStoreDir(slotStoreConfig.getStoreDir()); + config.setSyncWrites(true); + config.setSyncDeletes(true); + config.setBackingSlots(slots); + + config.setNodeAddress(manager.getNodeAddress()); + config.setIgnoreReturnValues(true); + + config.setCacheName(CACHE_NAME); + + config.setBackingSlots(slots); + config.setCache(manager.getCache(CACHE_NAME)); + + slots.init(config); // can throw IOException + + cacheManagers.add(manager); + + // tell the recovery manager that we are using the slot store + BeanPopulator.getDefaultInstance(ObjectStoreEnvironmentBean.class). + setObjectStoreType(SlotStoreAdaptor.class.getName()); + } + + public static void shutdownStore() { + for (DefaultCacheManager manager: cacheManagers) { + manager.shutdownAllCaches(); + manager.stop(); + } + + TransactionReaper.terminate(true); + } + + private static DefaultCacheManager createCacheManager() throws IOException { + return new DefaultCacheManager( + InfinispanSlotStoreExample.class.getResourceAsStream(CACHE_CONFIG_FILE)); + } +} \ No newline at end of file diff --git a/ArjunaJTA/object_store/src/main/resources/infinispan-config.xml b/ArjunaJTA/object_store/src/main/resources/infinispan-config.xml new file mode 100644 index 0000000000..d5e64f44e3 --- /dev/null +++ b/ArjunaJTA/object_store/src/main/resources/infinispan-config.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ArjunaJTA/object_store/src/main/resources/infinispan-jbossts-properties.xml b/ArjunaJTA/object_store/src/main/resources/infinispan-jbossts-properties.xml new file mode 100644 index 0000000000..c3dd228c10 --- /dev/null +++ b/ArjunaJTA/object_store/src/main/resources/infinispan-jbossts-properties.xml @@ -0,0 +1,22 @@ + + + 1 + com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor + com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor + com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor + + 256 + 4096 + com.arjuna.ats.internal.arjuna.objectstore.slot.infinispan.InfinispanSlots + infinispan-caches + + true + node1 + + + + + /infinispan-config.xml + + sharedCache + \ No newline at end of file diff --git a/ArjunaJTA/object_store/src/main/resources/jgroups.xml b/ArjunaJTA/object_store/src/main/resources/jgroups.xml new file mode 100644 index 0000000000..d2edf45ccc --- /dev/null +++ b/ArjunaJTA/object_store/src/main/resources/jgroups.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ArjunaJTA/pom.xml b/ArjunaJTA/pom.xml index c73e6bc993..a5ff15fe45 100644 --- a/ArjunaJTA/pom.xml +++ b/ArjunaJTA/pom.xml @@ -76,8 +76,7 @@ maven-compiler-plugin 3.15.0 - 17 - 17 + 17