You can dynamically create maps that are based on
a set of map templates. You can create your own map templates.
About this task
WebSphere® eXtreme Scale uses
Java regular expression pattern matching. For more information about
the regular expression engine in Java™,
see the API documentation for the java.util.regex package and classes.
Limitations:
- The QuerySchema element does not support the template for mapName.
- You cannot use entities with dynamic maps.
- An entity BackingMap is implicitly defined, mapped to the entity
through the class name.
Considerations:
- Many plug-ins have no way of determining the map with which each
plug-in is associated.
- Other plug-ins differentiate themselves by using a map name or
BackingMap name as an argument.
Procedure
Define a template map in your ObjectGrid
XML file. To defining a template map in the ObjectGrid
XML file, set the
template attribute on the backingMap
element to
true. As a result, the name of
the backingMap is interpreted as a regular expression.
Attention: When you are defining template maps, verify that
the map names are unique enough so that the application can match
to only one of the template maps with the Session.getMap(String
mapName) method. If the getMap() method
matches more than one template map pattern, an IllegalArgumentException exception
results. With dynamic maps, every name that matches the regular expression
for a template map results in map creation. Be sure to note the number
of maps that your application creates, particularly if your regular
expression is generic.
An example of an ObjectGrid
XML file with a template map defined follows. This XML file defines
one template map and one non-template map. The name of the template
map is a regular expression:
templateMap.*. When
the
Session.getMap(String) method is called with
a map name matching this regular expression, the application creates
a map.
<?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="accounting">
<backingMap name="payroll" readOnly="false" />
<backingMap name="templateMap.*" template="true"
pluginCollectionRef="templatePlugins" lockStrategy="PESSIMISTIC" />
</objectGrid>
</objectGrids>
<backingMapPluginCollections>
<backingMapPluginCollection id="templatePlugins">
<bean id="Evictor"
className="com.ibm.websphere.objectgrid.plugins.builtins.LFUEvictor" />
</backingMapPluginCollection>
</backingMapPluginCollections>
</objectGridConfig>
Note: A template is not an actual
BackingMap. That is, the “accounting” ObjectGrid does not contain
an actual “templateMap.*” map. The template is only used as a basis
for dynamic map creation. However, you must include the dynamic map
in the mapRef element of the deployment policy XML file named exactly
as in the ObjectGrid XML. This element identifies which mapSet in
which the dynamic maps are defined.
Example
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="session">
<backingMap name="objectgrid.session.metadata.dynamicmap.*" template="true"
lockStrategy="PESSIMISTIC" ttlEvictorType="LAST_ACCESS_TIME">
<backingMap name="objectgrid.session.attribute.dynamicmap.*"
template="true" lockStrategy="OPTIMISTIC"/>
<backingMap name="datagrid.session.global.ids.dynamicmap.*"
lockStrategy="PESSIMISTIC"/>
</objectGrid>
</objectGrids>
</objectGridConfig>
objectGridDeployment.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="session">
<mapSet name="mapSet2" numberOfPartitions="5" minSyncReplicas="0"
maxSyncReplicas="0" maxAsyncReplicas="1" developmentMode="false"
placementStrategy="PER_CONTAINER">
<map ref="logical.name"/>
<map ref="objectgrid.session.metadata.dynamicmap.*"/>
<map ref="objectgrid.session.attribute.dynamicmap.*"/>
<map ref="datagrid.session.global.ids"/>
</mapSet>
</objectgridDeployment>
</deploymentPolicy>
What to do next
Create a dynamic map with your defined templates:
Note: The
ObjectGridPermission.DYNAMIC_MAP is
required for dynamic map creation when
eXtreme Scale security
is enabled. This permission is checked when the
Session.getMap(String) method
is called. For more information, see
Authorizing application clients.