第19章 The Cluster App Quickstart
19.1. EAP Cluster App Overview リンクのコピーリンクがクリップボードにコピーされました!
The EAP Cluster App quickstart demonstrates how to use a JBoss Data Grid cache in library mode.
There are three different applications which show:
- How to create and use a JBoss Data Grid clustered cache without having a JBoss EAP cluster.
- A configuration where the JBoss EAP cluster is independent of an Infinispan cluster.
- A JBoss EAP instance using a JBoss Data Grid cache that is a member of a different JBoss Data Grid cluster.
- Programmatic cache configuration using the JBoss Data Grid API.
- File based configuration, seen in administration application App1Cache.
- CDI being used to inject the cache managers.
Overview of the EAP Cluster App Quickstart
Each application contains an embedded JBoss Data Grid cache which is accessed by stateless EJB’s in the same application. Different JBoss EAP servers, with the exception of AppTwo, are not clustered to demonstrate that an unclustered application can share the JBoss Data Grid cache; in addition, there are two cache managers, neither of which are members of the same JBoss Data Grid cluster. The AdminApp accesses and modified caches from both clusters. AppOne can only read the App1Cache, but it uses a clustered EJB invocation to AppTwo to read from App2Cache; AppTwo is deployed as a clustered EJB application and can only read App2Cache.
19.2. EAP Cluster App Prerequisites リンクのコピーリンクがクリップボードにコピーされました!
The prerequisites for the EAP Cluster App are as follows:
- Java 8.0 (Java SDK 1.8) or better
- JBoss Enterprise Application Platform 7.0 or later
- Maven 3.0 or better
- Configure the Maven repository. For details, see Install and Use the Maven Repositories.
- JBoss Data Grid modules installed in the JBoss EAP server.
19.3. Start the Application Server Instances リンクのコピーリンクがクリップボードにコピーされました!
Configure and Start the Servers in standalone mode
Prepare an instance of JBoss EAP for copying:
-
Unzip
jboss-datagrid-${version}-eap-modules-library.zip
. Copy the modules to the server modules directory:
For Linux:
cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add a user to each server for EJB access:
- For Linux: EAP_HOME/bin/add-user.sh -a -u quickuser -p quick-123
- For Windows: EAP_HOME\bin\add-user.bat -a -u quickuser -p quick-123
-
Unzip
- Copy the prepared JBoss EAP server to 4 different directories labeled EAP_HOME[1-4].
- Open a command line for each of the 4 nodes and navigate to the root of the JBoss EAP server directory.
Start all four of the JBoss EAP servers using the following commands:
For Linux:
EAP_HOME1/bin/standalone.sh -Djboss.node.name=node1 EAP_HOME2/bin/standalone.sh -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100 EAP_HOME3/bin/standalone.sh -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml EAP_HOME4/bin/standalone.sh -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
EAP_HOME1/bin/standalone.sh -Djboss.node.name=node1 EAP_HOME2/bin/standalone.sh -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100 EAP_HOME3/bin/standalone.sh -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml EAP_HOME4/bin/standalone.sh -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME1\bin\standalone.bat -Djboss.node.name=node1 EAP_HOME2\bin\standalone.bat -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100 EAP_HOME3\bin\standalone.bat -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml EAP_HOME4\bin\standalone.bat -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
EAP_HOME1\bin\standalone.bat -Djboss.node.name=node1 EAP_HOME2\bin\standalone.bat -Djboss.node.name=node2 -Djboss.socket.binding.port-offset=100 EAP_HOME3\bin\standalone.bat -Djboss.node.name=node3 -Djboss.socket.binding.port-offset=200 -c standalone-ha.xml EAP_HOME4\bin\standalone.bat -Djboss.node.name=node4 -Djboss.socket.binding.port-offset=300 -c standalone-ha.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the configuration for node2 (AppOne) to use EJB server-to-server invocation:
For Linux:
EAP_HOME2/bin/jboss-cli.sh -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
EAP_HOME2/bin/jboss-cli.sh -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME2\bin\jboss-cli.bat -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
EAP_HOME2\bin\jboss-cli.bat -c --controller=localhost:10099 --file=QUICKSTART_HOME/install-appOne-standalone.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure and Start the Servers in domain mode
Copy a fresh JBoss EAP installation to EAP_HOME:
-
Unzip
jboss-datagrid-${version}-eap-modules-library.zip
. Copy the modules to the server modules directory:
For Linux:
cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
cp -a jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
xcopy /e/i/f jboss-datagrid-${version}-eap-modules-library/modules EAP_HOME\modules
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
Unzip
- Open a command line and navigate to the root of JBoss EAP.
Add a user:
For Linux:
EAP_HOME/bin/add-user.sh -a -u quickuser -p quick-123
EAP_HOME/bin/add-user.sh -a -u quickuser -p quick-123
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME\bin\add-user.bat -a -u quickuser -p quick-123
EAP_HOME\bin\add-user.bat -a -u quickuser -p quick-123
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The following shows the command to start the domain:
For Linux:
EAP_HOME/bin/domain.sh
EAP_HOME/bin/domain.sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME\bin\domain.bat
EAP_HOME\bin\domain.bat
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Apply the configuration for the quickstart, the domain will contain 4 nodes:
For Linux:
EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/install-domain.cli
EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/install-domain.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/install-domain.cli
EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/install-domain.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.4. Build the Application リンクのコピーリンクがクリップボードにコピーされました!
Build the Application
- Open a command line and navigate to the root directory of this quickstart.
Execute the following command to build the archive:
mvn clean install
mvn clean install
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy the application to the appropriate server:
For Linux:
cp adminApp/ear/target/jboss-eap-application-adminApp.ear EAP_HOME1/standalone/deployments cp appOne/ear/target/jboss-eap-application-AppOne.ear EAP_HOME2/standalone/deployments cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME3/standalone/deployments cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME4/standalone/deployments
cp adminApp/ear/target/jboss-eap-application-adminApp.ear EAP_HOME1/standalone/deployments cp appOne/ear/target/jboss-eap-application-AppOne.ear EAP_HOME2/standalone/deployments cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME3/standalone/deployments cp appTwo/ear/target/jboss-eap-application-AppTwo.ear EAP_HOME4/standalone/deployments
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
copy adminApp\ear\target\jboss-eap-application-adminApp.ear EAP_HOME1\standalone\deployments copy appOne\ear\target\jboss-eap-application-AppOne.ear EAP_HOME2\standalone\deployments copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME3\standalone\deployments copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME4\standalone\deployments
copy adminApp\ear\target\jboss-eap-application-adminApp.ear EAP_HOME1\standalone\deployments copy appOne\ear\target\jboss-eap-application-AppOne.ear EAP_HOME2\standalone\deployments copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME3\standalone\deployments copy appTwo\ear\target\jboss-eap-application-AppTwo.ear EAP_HOME4\standalone\deployments
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
When domain mode is used, deploy the applications in the following way:
For Linux:
EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/deploy-domain.cli
EAP_HOME/bin/jboss-cli.sh -c --file=QUICKSTART_HOME/deploy-domain.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For Windows:
EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/deploy-domain.cli
EAP_HOME\bin\jboss-cli.bat -c --file=QUICKSTART_HOME/deploy-domain.cli
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.5. Run the Application リンクのコピーリンクがクリップボードにコピーされました!
Once built the deployed applications may be accessed using the included classes.
Using the AdminClient
In this example neither the AdminServer
nor the AppOneServer
are clustered at the JBoss EAP level; only the JBoss Data Grid instances are clustered as configured by the application. This application will perform the following:
-
Add values to the
App1
cache, usingAdminApp
, and validated they are replicated to the server instance ofAppOne
. -
Add a value to the
App2
cache, then rollback the transaction and confirm that it is not added to the cache after the rollback.
Procedure: Execute the AdminClient application
- Open a command line and navigate to the $QUICKSTART_HOME/client/ directory.
Execute the following command:
mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AdminClient exec:java
mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AdminClient exec:java
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注記By default the application will attempt to access
localhost:4447
andlocalhost:4547
for theAdminHost
andAppOneHost
. This may be changed by adding the following parameter to themvn
command:-Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
-Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the following text appears in the console; any unexpected results will raise an Exception:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Using the AppOneClient
In this example both JBoss EAP and the JBoss Data Grid caches are clustered; however, the purpose of this example is to demonstrate that the clusters are independent of one other. The JBoss Data Grid cluster is able to use a different JGroups implementation compared to the JBoss EAP servers, and this example will: ** Add values to the App2
cache using the AdminApp
and access AppOne
to show that the EJB invocation is clustered and both AppTwo
instances are used.
Execute the AppOneClient
- Open a command line and navigate to the $QUICKSTART_HOME/client/ directory.
Execute the following command:
mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AppOneClient exec:java
mvn -Dexec.mainClass=org.jboss.as.quickstarts.datagrid.eap.app.AppOneClient exec:java
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注記By default the application will attempt to access
localhost:4447
andlocalhost:4547
for theAdminHost
andAppOneHost
. This may be changed by adding the following parameter to themvn
command:-Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
-Dexec.args="AdminHost AdminPort AppOneHost AppOnePort"
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Confirm that the following text appears in the console; any unexpected results will raise an Exception:
Add a value to App2Cache with the AdminApp Access the App2Cache from the AppOneServer by using the clustered EJB@AppTwoServer success : received the following node names for EJB invocation : [node3, node4]
Add a value to App2Cache with the AdminApp Access the App2Cache from the AppOneServer by using the clustered EJB@AppTwoServer success : received the following node names for EJB invocation : [node3, node4]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.6. Debug the Application リンクのコピーリンクがクリップボードにコピーされました!
To debug, or examine the source code, of the quickstart or any of its associated libraries run either of the following commands to pull them into the local repository:
mvn dependency:sources mvn dependency:resolve -Dclassifier=javadoc
mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc