Getting started tutorial lesson 1.1: Defining data grids with configuration files

The objectgrid.xml and deployment.xml files are required to start container servers.

About this task

The sample uses the objectgrid.xml and deployment.xml files that are in the [Version 8.6 and later]wxs_install_root/ObjectGrid/gettingstarted/server/config directory. These files are passed to the start commands to start container servers and a catalog server. The objectgrid.xml file is the ObjectGrid descriptor XML file. The deployment.xml file is the ObjectGrid deployment policy descriptor XML file. These files together define a distributed topology.

Related referenceObjectGrid descriptor XML fileTo configure WebSphere eXtreme Scale, use an ObjectGrid descriptor XML file and the ObjectGrid API.Deployment policy descriptor XML fileTo configure a deployment policy, use a deployment policy descriptor XML file.

ObjectGrid descriptor XML file

An ObjectGrid descriptor XML file is used to define the structure of the ObjectGrid that is used by the application. It includes a list of backing map configurations. These backing maps store the cache data. The following example is a sample objectgrid.xml file. The first few lines of the file include the required header for each ObjectGrid XML file. This example file defines the Grid ObjectGrid with Map1 and Map2 backing maps.

<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="Grid" txTimeout="30">
			<backingMap name="Map1" copyMode="COPY_TO_BYTES"  lockStrategy="PESSIMISTIC"
				nullValuesSupported="false"/>
			<backingMap name="Map2" copyMode="COPY_TO_BYTES"  lockStrategy="PESSIMISTIC"
				nullValuesSupported="false"/>
		</objectGrid>  
	</objectGrids>  
</objectGridConfig>
[Version 8.6 and later]
  • The txTimeout value of 30 seconds is a good timeout value for most data grids.
  • The copyMode value of COPY_TO_BYTES is required when you do not provide an object class for serialization.
  • The lockStrategy value of PESSIMISTIC is a good locking strategy when you are first developing your data grid application. With this strategy, you are not using a near cache or loader plug-in. The application does not handle locking issues.
  • The nullValuesSupported value of false eliminates the problem that can occur when you retrieve a value from a key that is a null value. In this situation, you do not know whether the key existed. You can eliminate this problem by not allowing null values in the backing map.

Deployment policy descriptor XML file

The deployment policy descriptor XML file is intended to be paired with the corresponding ObjectGrid XML, the objectgrid.xml file. In the following example, the first few lines of the deployment.xml file include the required header for each deployment policy XML file. The file defines the objectgridDeployment element for the Grid ObjectGrid that is defined in the objectgrid.xml file. The Map1 and Map2 BackingMaps that are defined within the Grid ObjectGrid are included in the mapSet mapSet.

<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="Grid">
       <mapSet name="mapSet" numberOfPartitions="13" minSyncReplicas="0" 
	          maxSyncReplicas="1" >
            <map ref="Map1"/>
            <map ref="Map2"/>
        </mapSet>
    </objectgridDeployment>
</deploymentPolicy>

The numberOfPartitions attribute of the mapSet element specifies the number of partitions for the map set. This attribute is optional; the default value is 1. The attribute value must be appropriate for the anticipated capacity of the data grid.

The minSyncReplicas attribute of the mapSet element specifies the minimum number of synchronous replicas for each partition in the map set. This attribute is optional; the default is 0. Primary and replica shards are not placed until the catalog service domain can support the minimum number of synchronous replicas. To support the minSyncReplicas value, you need one more container server than the value of the minSyncReplicas attribute. If the number of synchronous replicas falls below the value of the minSyncReplicas attribute, write transactions are no longer allowed for that partition.

The maxSyncReplicas attribute of the mapSet element is to specify the maximum number of synchronous replicas for each partition in the map set. This attribute is optional; the default is 0. No other synchronous replicas are placed for a partition after a catalog service domain reaches this number of synchronous replicas for that specific partition. Adding container servers that can support this ObjectGrid can result in an increased number of synchronous replicas if your maxSyncReplicas value is not already met. The sample set the maxSyncReplicas to 1, which means the catalog service domain places one synchronous replica at most. If you start more than one container server, only one synchronous replica is placed in one of the container server instances.

Lesson checkpoint

In this lesson, you learned:
  • How to use the ObjectGrid descriptor XML file to define maps that store the cache data.
  • How to use the deployment descriptor XML file to define the number of partitions and replicas for the data grid.