GridGain remote cache size always zero -
i have configuration cache kept in 1 node , accessed another. although able get() , put() fine, operations size(), keyset() etc don't homecoming me right results.
test1 client node cache config
<bean id="test-cache" class="org.gridgain.grid.cache.gridcacheconfiguration"> <property name="name" value="testcache"/> <property name="cachemode" value="partitioned"/> <property name="distributionmode" value="client_only" /> <property name="swapenabled" value="true"/> </bean>
test1 client node class
public class gridgaintest1 { public static void main(string[] args) throws exception { //client mode grid g = gridgain.start("etc/config/grid-test1.xml"); //put in remote cache g.cache("testcache").put(1, "abc"); g.cache("testcache").put(2, "xyz"); system.out.println("size of cache :- " + g.cache("testcache").size()); system.out.println("value 1 :- " + g.cache("testcache").get(1)); system.out.println("value 2 :- " + g.cache("testcache").get(2)); }
test2 info node cache config
<bean id="test-cache" class="org.gridgain.grid.cache.gridcacheconfiguration"> <property name="name" value="testcache"/> <property name="cachemode" value="partitioned"/> <property name="swapenabled" value="true"/> </bean>
test2 info node class
public class gridgaintest2 { public static void main(string[] args) throws exception { grid g = gridgain.start("etc/config/grid-test2.xml"); } }
the output node 1 follows size comes in 0 though there entries in map. not sure if due misconfiguration.
size of cache :- 0 value 1 :- abc value 2 :- xyz
in gridgain cache api methods size()
, primarysize()
, nearsize()
, keyset()
, primarykeyset()
, values()
, primaryvalues()
, entryset()
, primaryentryset()
local, homecoming sizes or collections keys stored on local node.
in case started cache on test1 in client_only
mode, node not store keys. reason why see 0
cache size.
if need global cache size, can utilize next code:
gridcallable<integer> sizecallable = new gridcallable<integer>() { @override public integer call() throws exception { homecoming g.cache("testcache").size(); } }; collection<integer> sizes = g.forcache("testcache").compute() .broadcast(sizecallable).get(); int globalsize = 0; (integer s : sizes) globalsize += s;
convenience gridcache.globalsize()
method added in upcoming gridgain 6.2 release.
gridgain
No comments:
Post a Comment