-
Notifications
You must be signed in to change notification settings - Fork 109
JBTM-845 include infinispan store in the store quickstart #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep having $NY_BRANCH here
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I see, that would cause to override the lra branch with the narayana branch. So that makes sense. However the change means that we will test the quickstart with lra main branch by default instead of a fixed version
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specifically in this case the quickstart clones and builds lra from mmusgrov/lra.git main branch which is outdated: in fact I can see an error that we used to have with lra some months ago. cc @mmusgrov
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NY_BRANCH is the branch being tested for the narayana repo (in my case JBTM-845). I am not testing an LRA branch of the narayana repo so I need the LRA quickstarts to run against main so I introduced a new env variable for that - the problem is that the quickstarts make use of two repos (narayana and lra) and the script was not originally written to cope with that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to fix this we could add and then replace 'git clone https://github.com/${NARAYANA_REPO}/lra.git -b ${LRA_BRANCH}'
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'll give it a go
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks |
||
| 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}" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that I removed the check I also removed the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed another change, I had forgotten to update the GH Action with the new LRA_REPO and LRA_BRANCH var.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's also a script/action somewhere that populates new PR descriptions with a definition of what vars are processed - I'll look for that and add these two new vars to it.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made similar changes to the perf repo PR: jbosstm/performance#204 |
||
| 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 "<version>" pom.xml | head -n 2 | tail -n 1 | sed "s/ *<version>//" | sed "s#</version>##"` | ||
| cd .. | ||
|
|
||
| if [ $? != 0 ]; then | ||
| echo "Narayana LRA build failed: $BUILD_URL"; | ||
| exit -1 | ||
| fi | ||
|
|
||
| cd .. | ||
| } | ||
|
|
||
| function download_and_update_as { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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<DefaultCacheManager> 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)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
|
|
||
| <infinispan | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="urn:infinispan:config:16.0 http://www.infinispan.org/schemas/infinispan-config-16.0.xsd" | ||
| xmlns="urn:infinispan:config:16.0"> | ||
|
|
||
| <jgroups> | ||
| <stack-file name="udp-stack" path="jgroups.xml" /> | ||
| </jgroups> | ||
|
|
||
| <cache-container default-cache="sharedCache"> | ||
| <transport stack="udp-stack" node-name="${nodeName}" /> | ||
| <distributed-cache name="sharedCache"> | ||
| <!-- file-based store to the cache that implicitly uses write-through mode --> | ||
| <persistence> | ||
| <file-store> | ||
| <data path="infinispan-caches/data"/> | ||
| <index path="infinispan-caches/index"/> | ||
| </file-store> | ||
| </persistence> | ||
| </distributed-cache> | ||
| </cache-container> | ||
| </infinispan> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> | ||
| <properties> | ||
| <entry key="CoreEnvironmentBean.nodeIdentifier">1</entry> <!-- must be set --> | ||
| <entry key="ObjectStoreEnvironmentBean.objectStoreType">com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor</entry> | ||
| <entry key="ObjectStoreEnvironmentBean.stateStore.objectStoreType">com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor</entry> | ||
| <entry key="ObjectStoreEnvironmentBean.communicationStore.objectStoreType">com.arjuna.ats.internal.arjuna.objectstore.slot.SlotStoreAdaptor</entry> | ||
|
|
||
| <entry key="SlotStoreEnvironmentBean.numberOfSlots">256</entry> | ||
| <entry key="SlotStoreEnvironmentBean.bytesPerSlot">4096</entry> | ||
| <entry key="SlotStoreEnvironmentBean.backingSlotsClassName">com.arjuna.ats.internal.arjuna.objectstore.slot.infinispan.InfinispanSlots</entry> | ||
| <entry key="SlotStoreEnvironmentBean.storeDir">infinispan-caches</entry> | ||
|
|
||
| <entry key="InfinispanStoreEnvironmentBean.ignoreReturnValues">true</entry> | ||
| <entry key="InfinispanStoreEnvironmentBean.nodeAddress">node1</entry> | ||
| <entry key="InfinispanStoreEnvironmentBean.groupName"/> | ||
| <entry key="InfinispanStoreEnvironmentBean.slotKeyGeneratorClassName"/> | ||
|
|
||
| <!-- infinispan cluster config file name relative to the resource directory so begins with a slash char: --> | ||
| <entry key="InfinispanStoreEnvironmentBean.infinispanConfigFileName">/infinispan-config.xml</entry> | ||
| <!-- the cache name as configured in infinispan-config.xml --> | ||
| <entry key="InfinispanStoreEnvironmentBean.cacheName">sharedCache</entry> | ||
| </properties> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <config xmlns="urn:org:jgroups" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd"> | ||
| <SHARED_LOOPBACK/> | ||
| <SHARED_LOOPBACK_PING/> | ||
| <MERGE3 min_interval="1000" max_interval="5000"/> | ||
| <FD_ALL3 timeout="3000" interval="1000"/> | ||
| <VERIFY_SUSPECT2 timeout="1000"/> | ||
| <pbcast.NAKACK2 use_mcast_xmit="false"/> | ||
| <UNICAST3/> | ||
| <pbcast.STABLE desired_avg_gossip="5000" max_bytes="1M"/> | ||
| <pbcast.GMS print_local_addr="false" join_timeout="500"/> | ||
| <UFC max_credits="4M" min_threshold="0.4"/> | ||
| <MFC max_credits="4M" min_threshold="0.4"/> | ||
| <FRAG4/> | ||
| </config> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1