You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Chris Liu <do...@gmail.com> on 2017/01/17 20:38:26 UTC
Question about creating near cache
Hi,
I am trying to create a local nearCache but got the following exception:
Exception in thread "main" javax.cache.CacheException: class
org.apache.ignite.IgniteCheckedException: Failed to start near cache (local
node is an affinity node for cache): myCache
at
org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1440)
at
org.apache.ignite.internal.IgniteKernal.getOrCreateCache(IgniteKernal.java:2691)
at
HelloCityIgniteGetTuneup2.<init>(HelloCityIgniteGetTuneup2.java:26)
at HelloCityIgniteGetTuneup2.main(HelloCityIgniteGetTuneup2.java:57)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start
near cache (local node is an affinity node for cache): myCache
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheChangeRequest(GridCacheProcessor.java:3678)
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:2288)
at
org.apache.ignite.internal.processors.cache.GridCacheProcessor.dynamicStartCache(GridCacheProcessor.java:2253)
at
org.apache.ignite.internal.IgniteKernal.getOrCreateCache(IgniteKernal.java:2679)
Here is my code to create the near cache:
NearCacheConfiguration<String,City> nearCfg = new
NearCacheConfiguration<String,City>();
nearCfg.setNearEvictionPolicy(new
LruEvictionPolicy<String,City>(100_000));
Ignition.setClientMode(true);
cache = ignite.getOrCreateCache(new
CacheConfiguration<String,City>("myCache"),nearCfg);
Thanks for help!
Best Regards,
Chris Liu
Re: Question about creating near cache
Posted by vkulichenko <va...@gmail.com>.
Hi Chris,
This happens because you tried to create a near cache on a server node. If
that's what you're trying to achieve, then provide near cache configuration
in CacheConfiguration.setNearConfiguration(..) method.
However, the most common use case for a near cache is to have it on a client
node which doesn't store any data. In this case your code is correct, but
the node you're running it on should be in client mode:
https://apacheignite.readme.io/docs/clients-vs-servers
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Question-about-creating-near-cache-tp10099p10101.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.