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.
Applications must obtain an ObjectGrid instance to work with an ObjectGrid. The application can then call the ObjectGrid.getSession method on a thread and use that session for that thread. Each thread must have its own Session.
Core ObjectGrid instance
An application that is running in a core ObjectGrid mode can use a code fragment like the following example to obtain an ObjectGrid instance:
ObjectGrid grid = ObjectGridManagerFactory.getObjectGridManager().createObjectGrid();
This example obtains an instance for an anonymous ObjectGrid. This instance should be stored in a static variable. If you are using the Spring Framework, then declare the instance as a singleton bean and inject the instance wherever needed in the application. No defaults or Maps are defined on this grid. If the application uses the EntityManager APIs and Java 5 annotations to annotate its Java objects, then use the following code to create the Maps for its entities:
grid.registerEntities(new Class[] {Entity1.class, Entity2.class, Entity3.class});
See the ObjectGrid API documentation for other createObjectGrid methods that can be used for obtaining a core ObjectGrid instance.
Client ObjectGrid instance
A distributed ObjectGrid application uses one of the ObjectGridManager.connect methods to obtain an ObjectGrid instance. The method that is used depends on the type of environment. The ObjectGridManager.connect(ClientSecurityConfiguration securityProps, URL overRideObjectGridXml) method is used in Websphere Application Server when the ObjectGrid server runtime is running in the same cluster.
The ObjectGridManager.connect(String catalogServerAddresses, ClientSecurityConfiguration securityProps, URL overRideObjectGridXml) method is used to connect to a remote collection of ObjectGrid containers that are managed by an ObjectGrid catalog server.
All other connect methods on the ObjectGridManager interface are used for connecting to the legacy static deployment topology ObjectGrid server runtime.
Each connect method returns a ClientClusterContext instance. This context is used to get a reference to any of the ObjectGrids that hosted on the remote or collocated servers. The ObjectGridManager.connect(ClientClusterContext context) method is used to obtain a reference to the ObjectGrid. Examples of invocations of these methods follow:
ObjectGridManager ogm = ObjectGridManagerFactory.getObjectGridManager();
ClientClusterContext remoteContext = ogm.connect("MyServer1.company.com:2809,MyServer2.company.com:2809", null, null);
ObjectGrid remoteGrid = ogm.getObjectGrid(remoteContext, "MyObjectGrid");
ObjectGridManager ogm = ObjectGridManagerFactory.getObjectGridManager();
ClientClusterContext colocatedContext = ogm.connect(null, null);
ObjectGrid colocatedGrid = ogm.getObjectGrid(colocatedContext, "MyObjectGrid");
 |
A client override ObjectGrid descriptor XML file is always required when connecting to an ObjectGrid that has entities defined. |
Server ObjectGrid instance
The ObjectGrid instances that are running on an ObjectGrid server can be obtained by using the ObjectGridEventListener interface and by implementing the ObjectGridEventGroup.ShardEvents interface. This ObjectGridEventListener must be part of the ObjectGrid server configurations. When a shard activates, or becomes a primary, for a particular mapset, the ShardEvents.shardActivated(ObjectGrid) method is invoked. At this point, the application can start and work can be processed to the server ObjectGrid.
© Copyright IBM Corporation 2007,2009. All Rights Reserved.