cache.size() and cache.keyset() in Remote Client-Server Distributed cache
raghav_11 May 26, 2014 7:55 AMI am trying to set up Remote Client-Server mode cache(distributed cache) using Hot Rod API.
I am using 2 remote Hot Rod Servers and added configuration for ip-address:port in client. I have made all necessary XML Configuration in server side.
Sample Code for client is:
RemoteCacheManager cacheManager = new RemoteCacheManager();
RemoteCache<Integer, String> cache = cacheManager.getCache("myCache");
for(int i = 0 ;i< 10 ;i++)
cache.put(i, "hi"+i);
Sample XML Configuration(clustered.xml) in server Node1:
<cache-container name="clustered" default-cache="default" statistics="true">
<transport executor="infinispan-transport" lock-timeout="60000"/>
<distributed-cache name="default" mode="SYNC" segments="20" owners="2" remote-timeout="30000" start="EAGER">
<locking isolation="READ_COMMITTED" acquire-timeout="30000" concurrency-level="1000" striping="false"/>
<transaction mode="NONE"/>
</distributed-cache>
<distributed-cache name="myCache" mode="SYNC" segments="20" owners="2" remote-timeout="30000" start="EAGER">
<!-- <locking isolation="READ_COMMITTED" acquire-timeout="3000" concurrency-level="1000" striping="false"/>
<transaction mode="NONE"/> -->
<eviction max-entries="5" strategy="LRU" />
<expiration lifespan="-1" max-idle="-1" />
<file-store name="myFileStore"
passivation="false"
purge="false"
shared="true"
relative-to="jboss.server.log.dir"
path="file2"
max-entries="10000"
fetch-state="true"
preload="true"
singleton="false"/>
</distributed-cache>
</cache-container>
When i use cache.size() its returning value lesser than 10,if i set eviction maxentries="5" in XML file at server side.(Note: Its working fine if i remove the eviction tag).
and i tried with cache.keySet().size() and it gives exact value 10. But if one node goes down, all the distributed keys in that particular node get missed and cache.keySet().size() returns lesser value.
Can some please help me in configuring Hot Rod Remote client server for distributed cache.