| | {include:pageTitle=OG_HEADER} |
| | 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. |
| | |
| | h3. 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. |
| | |
| | h3. 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: |
| | {code:title=Making a start catalog script (Unix)} |
| | startOgServer.sh catalogServer -script startcatalog.sh -listenerHost MyServer.company.com |
| | {code} |
| | {code:title=Making a start catalog script (Windows)} |
| | startOgServer.bat catalogServer -script startcatalog.bat -listenerHost MyServer.company.com |
| | {code} |
| | 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. |
| | |
| | h3. Create a start application container script |
| | |
| | Next, create a startcontainer script as follows: |
| | {code:title=Making a start container script (Unix)} |
| | 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 |
| | {code} |
| | {code:title=Making a start container script (Windows)} |
| | 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 |
| | {code} |
| | 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: |
| | {code:title=Updated start container script} |
| | /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 |
| | {code} |
| | |
| | h3. The objectgrid.xml and deploymentdescriptor.xml |
| | |
| | Following is a simple [^objectgrid.xml] with a single grid and map contained within it: |
| | {code:title=Simple objectgrid.xml} |
| | <?xml version="1.0" encoding="UTF-8"?> |
| | <objectGridConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | xsi:schemaLocation="http://ibm.com/ws/objectgrid/config ../objectGrid.xsd" |
| | xmlns="http://ibm.com/ws/objectgrid/config"> |
| | <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> |
| | {code} |
| | Following is a sample [^entity.xml] file: |
| | {code:title=Simple entity.xml} |
| | <?xml version="1.0" encoding="UTF-8"?> |
| | |
| | <entity-mappings xmlns="http://ibm.com/ws/projector/config/emd" |
| | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | xsi:schemaLocation="http://ibm.com/ws/projector/config/emd ./emd.xsd"> |
| | |
| | <description>"Auto-Generated Entity Mapping description"</description> |
| | <entity class-name="poc.Record" name="Record" access="FIELD"/> |
| | </entity-mappings> |
| | {code} |
| | Following is the [deploymentpolicy.xml | ^deploymentdescriptor.xml]: |
| | {code:title=deploymentpolicy.xml} |
| | <?xml version="1.0" encoding="UTF-8"?> |
| | <deploymentPolicy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
| | xsi:schemaLocation="http://ibm.com/ws/objectgrid/deploymentPolicy ../deploymentPolicy.xsd" |
| | xmlns="http://ibm.com/ws/objectgrid/deploymentPolicy"> |
| | <objectgridDeployment objectgridName="poc"> |
| | <mapSet name="pocset" numberOfPartitions="8" numInitialContainers="2" |
| | minSyncReplicas="1" maxSyncReplicas="1" maxAsyncReplicas="0"> |
| | <map ref="Record"/> |
| | </mapSet> |
| | </objectgridDeployment> |
| | </deploymentPolicy> |
| | {code} |
| | 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. |
| | |
| | h3. Starting it up |
| | |
| | On box A, named MyServer, run the following command: |
| | {code:title=Starting the catalog server (Unix)} |
| | . startcatalog.sh & |
| | {code} |
| | {code:title=Starting the catalog server (Windows)} |
| | start startcatalog.bat |
| | {code} |
| | This command starts it in the background. Now start one container using this command: |
| | {code:title=Starting the first container (Unix)} |
| | . startcontainer.sh c0 & |
| | {code} |
| | {code:title=Starting the first container (Windows)} |
| | start startcontainer.bat c0 |
| | {code} |
| | Now, on the same machine or on a second machine with the same files installed, run this command to start the second container: |
| | {code:title=Starting the second container (Unix)} |
| | . startcontainer.sh c1 & |
| | {code} |
| | {code:title=Starting the second container (Windows)} |
| | start startcontainer.bat c1 |
| | {code} |
| | 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. |
| | |
| | h3. Additional Information |
| | |
| | * [Distributed ObjectGrid configuration] |
| | * [Using a non-IBM JDK or JRE with ObjectGrid] |
| | * [Installation for a Java 2 Platform,Standard Edition (J2SE) client] |
| | * [Obtaining a reference to an ObjectGrid] |
| | * [Starting ObjectGrid server processes] |
| | * [EntityManager in a distributed environment] |
| | |
| | |
| | {include:pageTitle=OG_FOOTER} |