72 WebSphere eXtreme Scale Best Practices for Operation and Management
The grid containers initialize the object grids that are defined in the configuration files upon
start-up of the Java EE application that contains the module. This method makes it easier to
manage the WebSphere eXtreme Scale run time without relying on scripts to launch the grid
containers. For embedded environments, if you want the configuration files to be external to
your modules and .ear or .war files, you can use a technique where you refer to the two
configuration files by defining two URLs each with a well-known Java Naming and Directory
Interface (JNDI) name. This way, the files remain outside any compiled unit and can be more
easily edited by operations as the need arises.
5.1.2 Client XML configuration
An WebSphere eXtreme Scale client also has an ObjectGrid descriptor configuration. The
descriptor initially is the same as the descriptor XML that you gave to the containers to which
the client connects. The client run time is passed this descriptor configuration transparently at
the time that it connects and gets the ObjectGrid reference. In certain cases, it might be
necessary to override parts of the object grid configuration on the client. For example, a
loader plug-in might make sense on the server but the Loader class probably does not even
exist on the client. The specifics of evictors might differ on the client from the server. You
might want to turn off certain features, such as the near cache.
Overriding plug-ins
The following plug-ins and attributes can be overridden in the client ObjectGrid descriptor
XML file:
򐂰 ObjectGrid plug-ins:
TransactionCallback plug-in
ObjectGridEventListener plug-in
Security-related plug-ins
򐂰 BackingMap plug-ins:
ObjectTransformer plug-in (for efficient serialization)
Evictor plug-in
Download material: For an example of WebSphere eXtreme Scale code that allows you
to start a WebSphere Application Server application server as an WebSphere eXtreme
Scale container using your XML files but with those files external to any compiled .ear or
.war file, see the WAS+XS_ExternalXML_Package.zip file in the additional materials that are
available for this book. For information about downloading this material, see Appendix B,
“Additional material” on page 197.
Configuration alternatives: Another alternative for configuring a grid is to invoke the
WebSphere eXtreme Scale application programming interface (API). Then, the actual Java
or Java EE application contains the configuration, and any modification of the configuration
requires you to repackage and redeploy the application. Note, however, that there might be
cases where using the API to configure a grid is desirable, for example when defining a
temporary grid, or if you want to hide the configuration from users, using the WebSphere
eXtreme Scale API can be a better approach.
We do not provide details about how to use the API to configure a grid. You can obtain
more information about how to use the API to configure a grid at this website:
http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1/topic/com.ibm.websphere.e
xtremescale.prog.doc/cxsprgrm.html
Chapter 5. Grid configuration 73
MapEventListener plug-in
numberOfBuckets attribute (which can be used to turn off the near cache)
ttlEvictorType attribute
timeToLive attribute
You also can (and might have to) turn off the reference to a loader plug-in from your server
configuration.
We describe plug-ins later in this chapter, but for now, know that the client configuration can
specify these overrides. You can obtain information about the client ObjectGrid descriptor
XML file at this website:
http://publib.boulder.ibm.com/infocenter/wxsinfo/v7r1/index.jsp?topic=/com.ibm.web
sphere.extremescale.admin.doc/cxscliconfig.html
Typically, a client ObjectGrid descriptor XML file is packaged with the client Java EE
application. The application needs to explicitly use this file when connecting to the object grid,
as shown in Example 5-1.
Example 5-1 How to code connection to a grid with a client ObjectGrid descriptor XML file
URL objectgridxml = Thread.currentThread().getContextClassLoader()
.getResource("/META-INF/objectGridClient.xml");
String catalogEndpoint = ServerFactory.getServerProperties()
.getCatalogServiceBootstrap();
ClientClusterContext ccc = ObjectGridManagerFactory
.getObjectGridManager().connect(catalogEndpoint, null, objectgridxml);
ObjectGrid grid = ObjectGridManagerFactory.getObjectGridManager()
.getObjectGrid(ccc, "MyGrid");
Disabling near cache
A WebSphere eXtreme Scale client can maintain its own near-side cache, which is
automatically enabled when using lockStrategy="OPTIMISTIC" or "NONE". However, you can
disable this client cache using the client ObjectGrid descriptor XML file. You must set the
numberOfBuckets attribute of the BackingMap to zero (0), as shown in Example 5-2.
Example 5-2 Using a client ObjectGrid descriptor XML file to disable the near cache
<?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="Grid">
<backingMap name="Test" numberOfBuckets="0" />
</objectGrid>
</objectGrids>
</objectGridConfig>

Get WebSphere eXtreme Scale Best Practices for Operation and Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.