See the WebSphere eXtreme Scale Wiki for links to eXtreme Scale Version 7.0 documentation.
If you log in
with your developerWorks ID, you can leave comments and feedback for the development team.
This topic illustrates how to set up a clustered Java 2 Platform Standard Edition (J2SE) application. A pair of J2SE ObjectGrid server containers is created to host the data, and a single client continually increments an entry in a map.
Setup
Before completing the steps in this topic, either:
- Specify the JAVA_HOME system variable in your current operating system command environment, or
- Edit the setupCmdLine.bat file in the bin directory of a standalone ObjectGrid installation to specify a JAVA_HOME value.
If you are not using an IBM JVM then please follow the steps in "Using a non-IBM JDK or JRE with ObjectGrid" to ensure the JVM you want to use is configured to use the IBM ORB.
Create a start catalog service script
Standalone ObjectGrid installs with a bin, lib and an xml directory. First, go to the bin directory and create two scripts. Run the following command:
startOgServer.sh catalogServer -script startcatalog.sh -listenerHost MyServer.company.com
startOgServer.bat catalogServer -script startcatalog.bat -listenerHost MyServer.company.com
This creates a script for starting a single default catalog server. It is important to edit the MyServer.company.com host name to point to the machine running the catalog service. There is no need for application specific class paths on the catalog server.
Create a start application container script
Next, create a startcontainer script as follows:
startOgServer.sh c0 -script startcontainer.sh
-objectgridFile /usr/john/poc/CONFIG/objectgrid.xml
-deploymentPolicyFile /usr/john/poc/CONFIG/deploymentpolicy.xml
-catalogServiceEndpoints MyServer.company.com:2809
-jvmArgs -Xmx1024M -classpath /usr/john/poc/bin
startOgServer.bat c0 -script startcontainer.bat
-objectgridFile /usr/john/poc/CONFIG/objectgrid.xml
-deploymentPolicyFile /usr/john/poc/CONFIG/deploymentpolicy.xml
-catalogServiceEndpoints MyServer.company.com:2809
-jvmArgs -Xmx1024M -classpath /usr/john/poc/bin
Notice that the application classes are added to the class path at /usr/john/poc/bin and are using a 1GB heap. You specified the application objectgrid.xml and deploymentpolicy.xml files on the command line and the catalog server location for bootstrap.
Next, edit the startcontainer.sh (or startcontainer.bat) and replace the reference to 'c0' with $1 (use %1 for Windows). It should have a line similar to the following when you are finished:
/opt/objectgrid/java/AIX64/jre/bin/java
-Xmx1024M -classpath /usr/john/poc/bin:/opt/objectgrid/java/AIX64/jre/../lib/tools.jar:
/usr/john/lib/objectgrid.jar:/usr/john/session/lib/sessionobjectgrid.jar:
/usr/john/lib/cglib.jar:/usr/john/lib/ogstreamquery.jar:
/usr/john/lib/castor.jar:/usr/john/lib/commons-io.jar:/usr/john/lib/mx4j.jar:
/usr/john/lib/mx4j-tools.jar:/usr/john/lib/mx4j-remote.jar:/usr/john/properties
com.ibm.ws.objectgrid.InitializationService $1
-objectgridFile /usr/john/poc/CONFIG/objectgrid.xml
-deploymentPolicyFile /usr/john/poc/CONFIG/deploymentpolicy.xml
-catalogServiceEndpoints MyServer.company.com:2809
The objectgrid.xml and deploymentdescriptor.xml
Following is a simple objectgrid.xml
with a single grid and map contained within it:
<?xml version="1.0" encoding="UTF-8"?>
<objectGridConfig xmlns:xsi="http:
xsi:schemaLocation="http:
xmlns="http:>
<objectGrids>
<objectGrid name="poc" entityMetadataXMLFile="entity.xml">
<bean id="ObjectGridEventListener" className="poc.Partition">
</bean>
<!-- tuning for around 60k (2 x 29023) records in memory -->
<backingMap name="Record" lockStrategy="PESSIMISTIC" numberOfBuckets="29023" />
</objectGrid>
</objectGrids>
</objectGridConfig>
Following is a sample entity.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http:
xmlns:xsi="http:
xsi:schemaLocation="http:>
<description>"Auto-Generated Entity Mapping description"</description>
<entity class-name="poc.Record" name="Record" access="FIELD"/>
</entity-mappings>
Following is the deploymentpolicy.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<deploymentPolicy xmlns:xsi="http:
xsi:schemaLocation="http:
xmlns="http:>
<objectgridDeployment objectgridName="poc">
<mapSet name="pocset" numberOfPartitions="8" numInitialContainers="2"
minSyncReplicas="1" maxSyncReplicas="1" maxAsyncReplicas="0">
<map ref="Record"/>
</mapSet>
</objectgridDeployment>
</deploymentPolicy>
These three files comprise the application configuration for a distributed ObjectGrid. The objectgrid.xml file describes each object grid, any plugins or event handlers and the maps within those grids. There is a single grid called poc, with an ObjectGridEventListener attached and a single Map, Record. The objectgrid.xml also has a reference to the entity.xml that in this case, is defined as an entity using J2SE 5 annotations.
The deployment descriptor provides placement information for each grid in the objectgrid.xml. The important points for simple scenarios are:
- How many partitions?
- How many synchronous replicas?
- How many asynchronous replicas?
The sample specifies 8 partitions with each partition primary having 1 synchronous replica and no asynchronous replicas. A numInitialContainers is specified as well to prevent placement, until that number of container JVMs are started. This prevents thrashing, because the catalog service waits for N containers before placement. The default minimum number of initial containers equals one more than the number of minimum synchronous replicas. If you specify a number smaller than the default minimum, the default will be used.
Starting it up
On box A, named MyServer, run the following command:
This command starts it in the background. Now start one container using this command:
start startcontainer.bat c0
Now, on the same machine or on a second machine with the same files installed, run this command to start the second container:
start startcontainer.bat c1
Both containers now contact the catalog service. When both JVMs attach, the catalog places the 8 partition primaries and their 8 replicas on those two containers.
Additional Information
© Copyright IBM Corporation 2007,2009. All Rights Reserved.