IBM Support

Objects placed in DistributedMap are not replicated

Troubleshooting


Problem

If the DistributedMap API is being used with cache replication enabled, why are the objects placed in the cache not always being replicated?

Cause

The replication service for a DistributedMap will only be initialized when you use it. If the cache is defined using one of the techniques, but not actually used in the application code, then the replication service for that cache instance will not be initialized.

A DistributedMap can be initialized when the application code performs the look-up operation.

Another way to initialize a DistributedMap is to call:

com.ibm.wsspi.cache.DistributedObjectCacheFactory.getMap(String)
com.ibm.wsspi.cache.DistributedObjectCacheFactory.getMap(String, Properties)



As an example of this problem, say you have defined a cache instance named services/cache/instance_one and enabled cache replication for the same. The cache instance will not be initialized until you perform a look-up for it.

The following code will initialize the cache and replication service:

InitialContext ic = new InitialContext();v
DistributedMap dm =(DistributedMap)ic.lookup("services/cache/instance_one");



You will see the following lines in the SystemOut.log file:

[2008-07-10 18:56:01:828 EST] 0000002c CacheServiceI I   DYNA1001I: WebSphere Dynamic Cache instance named /cache/instance_one initialized successfully.
[2008-07-10 18:56:02:828 EST] 00000042 DRSBootstrapM A   CWWDR0001I:  Replication instance launched : /cache/instance_one



Notice that there will be a small delay between the initialization of the cache instance and the replication service. This delay will normally be around a second and it might be few seconds more if you have a large cluster topology.

Here are the things that might happen when you try to deal with the cache instance before it is completely replicated:

  • If you try to put an object in the cache, it will not be replicated immediately. It should still be replicated during bootstrap.

  • If you try to get an object that was supposed to be replicated from a different cluster member, then the get operation might fail to retrieve the object as the replication service is not ready.

This initialization only happens for the first look-up operation after server start. Subsequent access of cache instance should not have this issue.

Resolving The Problem

The replication for a cache instance is complete when it has finished bootstrapping, that is handshaking with the same cache instance on all the other members/servers of the replication domain. Until this bootstrap is done, users should expect to see a delay in their cache replication and messages like the one pasted above.

Messages like "updatePeerCaches() DRS is not ready!! - CE will be sent during bootstrap CE=" in the dynamic cache trace log indicate that replication has not been initialized and setup is not complete for this cache instance. All the cache data put into this cache instance cannot be sent immediately to the servers. The cache data will be sent to other servers during the process of bootstrap. The cache data for bootstrap is only limited to the memory cache but not the disk cache, if disk offload is enabled.

Typically the JNDI™ look-up of the cache instance can be done in the init method of a servlet. So that, when service is called, the cache instance and its replication service has been initialized successfully.

If you can not isolate the JNDI lookup of cache instance and are working with the cache, it is suggested to add a small delay of about 1 to 5 seconds for the initial look-up only. You may have to tune this delay depending on your environment by reviewing the SystemOut.log file and finding the actual time taken to launch the replication service.

The following code fragment might help:

InitialContext ic = new InitialContext();
DistributedMap dm =(DistributedMap)ic.lookup("services/cache/instance_one");

if(firstAccess) {
firstAccess = false;

//Add delay to sleep for 5000ms.

Thread.sleep(5000);
}

// Hopefully by now, the replication instance is launched, you can continue with the put or get operation on the DistributedMap object
dm.put(...);
MyObject obj = dm.get(...);

[{"Product":{"code":"SSEQTP","label":"WebSphere Application Server"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Dynamic Cache","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.0;7.0;6.1","Edition":"Network Deployment","Line of Business":{"code":"LOB45","label":"Automation"}},{"Product":{"code":"SS7K4U","label":"WebSphere Application Server for z\/OS"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":null,"Platform":[{"code":"PF035","label":"z\/OS"}],"Version":"6.1;6.0","Edition":"","Line of Business":{"code":"LOB45","label":"Automation"}}]

Document Information

Modified date:
15 June 2018

UID

swg21313480