Forum Stats

  • 3,854,212 Users
  • 2,264,340 Discussions
  • 7,905,609 Comments

Discussions

Cachestore for distributed scheme not getting invoked to "load" the entries

SandeepMahendru
SandeepMahendru Member Posts: 12
edited May 17, 2010 7:35AM in Coherence Support
Hi,
We have a distributed scheme with CacheStore as below,


SERVER PART
***********

<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>

<cache-mapping>
<cache-name>ReferenceData-Cache</cache-name>
<scheme-name>RefData_Distributed_Scheme</scheme-name>
</cache-mapping>

<!--

FEW OTHER DISTRIBUTED CACHE

-- >

</caching-scheme-mapping>

<caching-schemes>


<!-- definition of other cache schemes including one proxy scheme -->

<distributed-scheme>
<scheme-name>RefData_Distributed_Scheme</scheme-name>
<service-name>RefData_Distributed_Service</service-name>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>TradeEngine-POF.xml</param-value>
</init-param>
</init-params>
</serializer>
<backing-map-scheme>
<read-write-backing-map-scheme>
<internal-cache-scheme>
<local-scheme>
<expiry-delay>1m</expiry-delay>
</local-scheme>
</internal-cache-scheme>
<cachestore-scheme>
<class-scheme>
<class-name>com.csfb.fid.gtb.referencedatacache.cachestore.RefDataCacheStore</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>{cache-name}</param-value>
</init-param>
</init-params>
</class-scheme>
</cachestore-scheme>
<read-only>true</read-only>
<refresh-ahead-factor>.5</refresh-ahead-factor>
</read-write-backing-map-scheme>
</backing-map-scheme>
<backup-count>1</backup-count>
<autostart system-property="tangosol.coherence.distributed-service.enabled">false</autostart>
</distributed-scheme>


</caching-schemes>
</cache-config>


The above configuration is used on tcp extend proxy node with localstorage=false

There is similar configuration on storage node,
- with no proxy,
- with same "ReferenceData-Cache" (autostart=true)
- and localstorage=true.

Following is my CacheStore implementation.
NOTE: This Cachestore is only for loading the cache entry from cache store.i.e. from some excel file in my case, i.e. only load() and loadAll() methods.
NO store() or storeAll().

package com.csfb.fid.gtb.referencedatacache.cachestore;

import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.creditsuisse.fid.gtb.common.FileLogger;
import com.csfb.fid.gtb.referencedatacache.Currency;
import com.csfb.fid.gtb.utils.refdada.DBDetails;
import com.csfb.fid.gtb.utils.refdada.ReferenceDataReaderUtility;
import com.tangosol.net.NamedCache;
import com.tangosol.net.cache.CacheStore;


public class RefDataCacheStore implements CacheStore
{


private DBDetails dbDetails = null;
private ReferenceDataReaderUtility utils = null;


public RefDataCacheStore(String cacheName)
{
System.out.println("RefDataCacheStore constructor..");
//dbDetails = DBDetails.getInstance();
utils = new ReferenceDataReaderUtility();

}



public Object load(Object key)
{
return utils.readCurrency(key);
}


public void store(Object oKey, Object oValue)
{

}


public void erase(Object oKey)
{

}


public void eraseAll(Collection colKeys)
{

}


public Map loadAll(Collection colKeys)
{
System.out.println("RefDataCacheStore loadAll..");
Map<String, Object> obejctMap = new HashMap<String, Object>();
List<Object> list = utils.readAllCurrencies();
Iterator<Object> listItr = list.iterator(colKeys);
while(listItr.hasNext()){
Object obj = listItr.next();
if(obj != null){
String key = "CU-"+((Currency)obj).getId();
obejctMap.put(key, (Currency)obj);
}
}
return obejctMap;
}


public void storeAll(Map mapEntries)
{

}





}



CLIENT PART
***********

I connect to this cache using extend client with follwing config file,
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">

<cache-config>
<caching-scheme-mapping>

<cache-mapping>
<cache-name>ReferenceData-Cache</cache-name>
<scheme-name>coherence-remote-scheme</scheme-name>
</cache-mapping>


</caching-scheme-mapping>
<caching-schemes>
<remote-cache-scheme>
<scheme-name>coherence-remote-scheme</scheme-name>
<initiator-config>
<serializer>
<class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
<init-params>
<init-param>
<param-type>string</param-type>
<param-value>TradeEngine-POF.xml</param-value>
</init-param>
</init-params>
</serializer>
<tcp-initiator>
<remote-addresses>
<socket-address>
<address>169.39.30.182</address>
<port>9001</port>
</socket-address>
</remote-addresses>
<connect-timeout>10s</connect-timeout>
</tcp-initiator>
<outgoing-message-handler>
<request-timeout>3000s</request-timeout>
</outgoing-message-handler>
</initiator-config>
</remote-cache-scheme>
</caching-schemes>
</cache-config>




PROBLEM
*******
From my test case (with extend client file as configuration), when i try to connect to get cache handle of this cache, as

refDataCache = CacheFactory.getCache("ReferenceData-Cache");

I get following error on server side,

***********************************************************************
2010-05-12 18:28:25.229/1687.847 Oracle Coherence GE 3.5.3/465 <Error> (thread=DistributedCache, member=2): BackingMapManager com.tangosol.net.DefaultConfigurableCacheFactory$Manager: failed to instantiate a cache: ReferenceData-Cache
2010-05-12 18:28:25.229/1687.847 Oracle Coherence GE 3.5.3/465 <Error> (thread=DistributedCache, member=2):
java.lang.IllegalArgumentException: No scheme for cache: "ReferenceData-Cache"
at com.tangosol.net.DefaultConfigurableCacheFactory.findSchemeMapping(DefaultConfigurableCacheFactory.java:507)
at com.tangosol.net.DefaultConfigurableCacheFactory$Manager.instantiateBackingMap(DefaultConfigurableCacheFactory.java:3486)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$Storage.instantiateResourceMap(DistributedCache.CDB:22)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$Storage.setCacheName(DistributedCache.CDB:27)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$ConfigListener.entryInserted(DistributedCache.CDB:15)
at com.tangosol.util.MapEvent.dispatch(MapEvent.java:266)
at com.tangosol.util.MapEvent.dispatch(MapEvent.java:226)
at com.tangosol.util.MapListenerSupport.fireEvent(MapListenerSupport.java:556)
at com.tangosol.util.ObservableHashMap.dispatchEvent(ObservableHashMap.java:229)
at com.tangosol.util.ObservableHashMap$Entry.onAdd(ObservableHashMap.java:270)
at com.tangosol.util.SafeHashMap.put(SafeHashMap.java:244)
at com.tangosol.coherence.component.util.collections.WrapperMap.put(WrapperMap.CDB:1)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid$ServiceConfigMap.put(Grid.CDB:31)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$StorageIdRequest.onReceived(DistributedCache.CDB:45)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:9)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:136)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache.onNotify(DistributedCache.CDB:3)
at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
at java.lang.Thread.run(Thread.java:619)

***********************************************************************
However, with this error also i am able to do normal put operation and get operation against those put.
But when i try to get the cache entry which doesnt exists in cache, like

refDataCache.get("CU-1");

I expected that call would go to RefDataCacheStore.load method. But in my case i dont see it happening.
Also i debugged my jvms in debug mode and i put a class load breakpoint for RefDataCacheStore, but even that is not hit. I have RefDataCacheStore in my server classpath.

Hope to see reply on this soon.
Thanks
Manish
Tagged:

Answers

  • 772739
    772739 Member Posts: 3
    Can someone please reply to this problem, sort of urgent.

    -Manish
  • The error No scheme for cache: "ReferenceData-Cache" in the stack trace would suggest that the server does not have a cache scheme for the ReferenceData-Cache cache. The configuration in your post does have a scheme, so are you sure your server is actually picking up the correct configuration. You can see the configuration files being used at the start of the logs.

    I am not sure how you are still able to do gets and puts though. The reason you cache store is not gettig called is that this lives on the server and the server is obviously not able to create the cache or the cache store.

    JK
  • Lsho-Oracle
    Lsho-Oracle Member Posts: 161 Employee
    Hi Manish,

    You can also look at the caches and services your server has through the local jconsole. Add the following properties when starting your cache server to allow you access the management mbeans:

    -Dtangosol.coherence.management=all
    -Dtangosol.coherence.management.remote=true
    -Dtangosol.coherence.jmxremote=true


    In jconsole, select MBeans, under Coherence, you should see "RefData_Distributed_Service" under Service if the cache serivce is started. There are also other objects such as Cache, Cluster, and Node, etc. you could look at and make sure the cache server, proxy server are in the cluster and your client connects to the correct proxy server.

    -Luk
  • 772739
    772739 Member Posts: 3
    Hi,

    I have my server picking up the correct configuration files for "ReferenceData-Cache". In my local jconsole i could see that the service named "RefData_Distributed_Service" is started under service mbean. Also i am able to perform a put and get on "ReferenceData-Cache", i could even see StorageManager mbean showing my inserted entries for "RefData_Distributed_Service".

    Ideally if the server is not getting class for Cachestore in its classpath i should see ClassNotFoundException, but i dont see such exeption.

    Is default consturctor for cachestore impl is required?

    Any other suggestions? please...

    Regards,
    -Manish
  • robvarga
    robvarga Member Posts: 1,708 Gold Badge
    edited May 17, 2010 7:35AM
    Hi Manish,

    <<previous advice deleted>>

    user13113666 wrote:
    Hi,

    I have my server picking up the correct configuration files for "ReferenceData-Cache". In my local jconsole i could see that the service named "RefData_Distributed_Service" is started under service mbean. Also i am able to perform a put and get on "ReferenceData-Cache", i could even see StorageManager mbean showing my inserted entries for "RefData_Distributed_Service".
    With the local jconsole, are you monitoring the server/proxy node, or the TCP*Extend cleint node?

    The client can have the service with the server still not having it.

    Could you please post the startup log for the storage node on the server...


    Best regards,

    Robert

    Edited by: robvarga on May 17, 2010 12:33 PM
This discussion has been closed.