You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Ilya Kasnacheev <il...@gmail.com> on 2019/07/01 15:22:53 UTC
Re: Issue in starting Near cache only on client node
Hello!
I think the cache would start if listed in node's configuration (via XML or
Java). Make sure you also have near caches there.
Regards,
--
Ilya Kasnacheev
чт, 27 июн. 2019 г. в 10:32, Prasad Bhalerao <pr...@gmail.com>:
> Hi,
>
> I am getting following error on ignite client nodes.
>
> *class org.apache.ignite.IgniteCheckedException: Failed to start near
> cache (a cache with the same name without near cache is already started*
>
> To solve this issue I added following code in ApplicationRunner's run()
> method to explicitly start the cache. Application runner Interface is
> provided by spring boot to execute required code just before server startup.
>
> But even after doing this I am still getting error "a cache with the same
> name without near cache is already started".
>
> I see following info messages in my log file *multiple times*. First time
> it is logged when ApplicationRunner.run() method is invoked during server
> startup.
>
> *o.a.i.i.p.cache.GridCacheProcessor - Started cache [name=DOMAIN_CACHE,
> id=-2139013081, memoryPolicyName=null, mode=PARTITIONED,
> atomicity=TRANSACTIONAL, backups=1]*
>
> On which events GridCacheProcessor starts the cache?
>
> Can this event be intercepted or handled to start near cache?
>
> What is the reason behind getting "GridCacheProcessor - Started cache"
> info messages *multiple* *times *in log files?
>
> Is near cache is destroyed/invalidate when client node is reconnected to
> the cluster?
>
> Can some please advise?
>
> *CODE TO START caches explicitly:*
>
> @Override
> public void run(ApplicationArguments args) throws Exception {
> for (CacheName cacheName : CacheName.values()) {
> //We are configuring few caches only on client node for fast lookup during validations.
> if (ignite.configuration().isClientMode() && CacheName.isNearCache(cacheName)) {
> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(nearCacheSize));
> ignite.getOrCreateNearCache(cacheName, nearCfg);
> } else {
> ignite.cache(cacheName);
> }
> }
> LOGGER.info("Caches Started....");
> }
>
>
> Thanks,
> Prasad
>
> On Mon, Apr 29, 2019 at 5:34 PM Prasad Bhalerao <
> prasadbhalerao1983@gmail.com> wrote:
>
>> Yes, I found the issue. Actually it was in my Junit. I had accidently
>> added following line in my junit case. This was starting the cache and I
>> was trying to get it using my service call.
>>
>> //final IgniteCache<Object, Object> cache = ignite.cache(CacheName.ASSET_GROUP_CACHE.name());
>>
>> Thanks,
>> Prasad
>>
>>
>>
>> On Mon, Apr 29, 2019 at 5:10 PM Ilya Kasnacheev <
>> ilya.kasnacheev@gmail.com> wrote:
>>
>>> Hello!
>>>
>>> As this error points out, you can't have near cache with same name as
>>> already existing regular cache.
>>>
>>> Regards,
>>> --
>>> Ilya Kasnacheev
>>>
>>>
>>> пн, 29 апр. 2019 г. в 13:52, Prasad Bhalerao <
>>> prasadbhalerao1983@gmail.com>:
>>>
>>>> Hi,
>>>>
>>>> I am getting "*Failed to start near cache* exception" while starting
>>>> near cache only on client node. Near cache is not configured on server
>>>> nodes.
>>>>
>>>> Cache configuration on server is node is as follows:
>>>>
>>>> private CacheConfiguration agCacheCfg() {
>>>>
>>>> CacheConfiguration agCacheCfg = new CacheConfiguration<>(CacheName.AG_CACHE.name());
>>>> agCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>>>> agCacheCfg.setWriteThrough(ENABLE_WRITE_THROUGH);
>>>> agCacheCfg.setReadThrough(false);
>>>> agCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
>>>> agCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
>>>> agCacheCfg.setBackups(1);
>>>> agCacheCfg.setIndexedTypes(DefaultDataAffinityKey.class, AgData.class);
>>>> Factory<AgDataCacheStore> storeFactory = FactoryBuilder.factoryOf(AgDataCacheStore.class);
>>>> agCacheCfg.setCacheStoreFactory(storeFactory);
>>>> agCacheCfg.setCacheStoreSessionListenerFactories(cacheStoreSessionListenerFactory());
>>>> agCacheCfg.setSqlIndexMaxInlineSize(100);
>>>> RendezvousAffinityFunction affinityFunction = new RendezvousAffinityFunction();
>>>> affinityFunction.setExcludeNeighbors(true);
>>>> agCacheCfg.setAffinity(affinityFunction);
>>>> agCacheCfg.setStatisticsEnabled(true);
>>>>
>>>>
>>>> return agCacheCfg;
>>>> }
>>>>
>>>>
>>>> I am using following code to get the Near cache on client node only for
>>>> configured cache names.
>>>> Can some please help me with this?
>>>>
>>>> protected IgniteCache<K, T> cache() {
>>>> String cacheName = getCacheName();
>>>> if (this.cache == null) {
>>>> //We are configuring few caches only on client node for fast lookup during validations.
>>>> if (ignite.configuration().isClientMode() && NearCacheName.isNearCache(cacheName)) {
>>>> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
>>>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(10_000));
>>>> this.cache = ignite.createNearCache(cacheName, nearCfg);
>>>> } else {
>>>> this.cache = ignite.cache(cacheName);
>>>> }
>>>> }
>>>> return this.cache;
>>>> }
>>>>
>>>>
>>>> *EXCEPTION:*
>>>>
>>>> *javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started)*
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> * at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1303) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2960) at org.apache.ignite.IgniteSpringBean.createNearCache(IgniteSpringBean.java:382) at com.qualys.agms.grid.dao.AbstractDataGridDAO.cache(AbstractDataGridDAO.java:112) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:47) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:31) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:27) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:10) at com.qualys.agms.IgniteClientTester.testGet(IgniteClientTester.java:382) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started) at org.apache.ignite.internal.IgniteKernal.checkNearCacheStarted(IgniteKernal.java:3019) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2955) ... 37 more*
>>>>
>>>>
>>>> Thanks,
>>>> Prasad
>>>>
>>>> On Sat, Apr 20, 2019 at 9:05 AM Denis Magda <dm...@apache.org> wrote:
>>>>
>>>>> Hi Prasad,
>>>>>
>>>>> It's required to define a NearCacheConfiguration on a node you'd like
>>>>> to have it one. Use one of the approaches defined in the docs:
>>>>> https://apacheignite.readme.io/docs/near-caches
>>>>>
>>>>> Near caches can be created directly on *client* nodes by passing
>>>>> NearCacheConfiguration to the
>>>>> Ignite.createNearCache(NearCacheConfiguration) or
>>>>> Ignite.getOrCreateNearCache(NearCacheConfiguration) methods. Use the Ignite.getOrCreateCache(CacheConfiguration,
>>>>> NearCacheConfiguration) method if you need to both start a
>>>>> distributed cache dynamically and create a near cache for it.
>>>>>
>>>>> -
>>>>> Denis
>>>>>
>>>>>
>>>>> On Fri, Apr 19, 2019 at 5:53 AM Prasad Bhalerao <
>>>>> prasadbhalerao1983@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Is there any to enable near cache only on client nodes?
>>>>>>
>>>>>> I am using partitioned cache and using colocation to submit the
>>>>>> ignite jobs. But in my code I do few lookups on client node to validate the
>>>>>> data. To improve this lookup performance I want to enable near cache.
>>>>>>
>>>>>> I saw the example on GitHub and in ignite docs. But I am still
>>>>>> struggling to configure near cache on client nodes only.
>>>>>>
>>>>>> This my Ignite configuration on client node. All the cache
>>>>>> configurations are defined only on ignite server nodes.
>>>>>>
>>>>>> Can some please tell me where to include near cache configuration in
>>>>>> following config?
>>>>>>
>>>>>> private IgniteConfiguration getIgniteConfiguration(IgniteSpringBean ignite) {
>>>>>>
>>>>>> String[] hosts = appConfigProperties.getHosts().split(",");
>>>>>> TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
>>>>>> ipFinder.setAddresses(Arrays.asList(hosts));
>>>>>>
>>>>>> TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
>>>>>> discoSpi.setIpFinder(ipFinder);
>>>>>>
>>>>>> IgniteConfiguration cfg = new IgniteConfiguration();
>>>>>> cfg.setDiscoverySpi(discoSpi);
>>>>>> cfg.setIgniteInstanceName("springDataNode");
>>>>>> cfg.setPeerClassLoadingEnabled(false);
>>>>>> cfg.setRebalanceThreadPoolSize(4);
>>>>>> cfg.setClientFailureDetectionTimeout(failureDetectionTimeout);
>>>>>> //cfg.setLifecycleBeans(new IgniteLifeCycleBean());
>>>>>> cfg.setClientMode(true);
>>>>>> HashMap<String, String> attributeMap = new HashMap<>();
>>>>>> attributeMap.put(NODE_TYPE,NODE_TYPE_WEB);
>>>>>> cfg.setUserAttributes(attributeMap);
>>>>>>
>>>>>> return cfg;
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> Prasad
>>>>>>
>>>>>
Re: Issue in starting Near cache only on client node
Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!
Unfortunately, near caches configuration is somewhat confusing.
I can see in the docs the following:
// Create a distributed cache on server nodes and // a near cache on
the local node, named "myCache".IgniteCache<Integer, Integer> cache =
ignite.getOrCreateCache(
new CacheConfiguration<Integer, Integer>("myCache"), nearCfg);
If that does not work (when myCache is already present on server but
without near cache), please share a reproducer I can tweak.
Regards,
--
Ilya Kasnacheev
пн, 1 июл. 2019 г. в 19:34, Prasad Bhalerao <pr...@gmail.com>:
> Actually I wanted to start near cache only on client node using
> getOrCreateNearCache method. But somehow it didn't work.
>
> So now. I have configured near cache using cache.setNearCacheConfig method
> in cache configuration. But this starts near cache on client as well as on
> server node.
>
>
> On Mon 1 Jul, 2019, 8:53 PM Ilya Kasnacheev <ilya.kasnacheev@gmail.com
> wrote:
>
>> Hello!
>>
>> I think the cache would start if listed in node's configuration (via XML
>> or Java). Make sure you also have near caches there.
>>
>> Regards,
>> --
>> Ilya Kasnacheev
>>
>>
>> чт, 27 июн. 2019 г. в 10:32, Prasad Bhalerao <
>> prasadbhalerao1983@gmail.com>:
>>
>>> Hi,
>>>
>>> I am getting following error on ignite client nodes.
>>>
>>> *class org.apache.ignite.IgniteCheckedException: Failed to start near
>>> cache (a cache with the same name without near cache is already started*
>>>
>>> To solve this issue I added following code in ApplicationRunner's run()
>>> method to explicitly start the cache. Application runner Interface is
>>> provided by spring boot to execute required code just before server startup.
>>>
>>> But even after doing this I am still getting error "a cache with the
>>> same name without near cache is already started".
>>>
>>> I see following info messages in my log file *multiple times*. First
>>> time it is logged when ApplicationRunner.run() method is invoked during
>>> server startup.
>>>
>>> *o.a.i.i.p.cache.GridCacheProcessor - Started cache [name=DOMAIN_CACHE,
>>> id=-2139013081, memoryPolicyName=null, mode=PARTITIONED,
>>> atomicity=TRANSACTIONAL, backups=1]*
>>>
>>> On which events GridCacheProcessor starts the cache?
>>>
>>> Can this event be intercepted or handled to start near cache?
>>>
>>> What is the reason behind getting "GridCacheProcessor - Started cache"
>>> info messages *multiple* *times *in log files?
>>>
>>> Is near cache is destroyed/invalidate when client node is reconnected to
>>> the cluster?
>>>
>>> Can some please advise?
>>>
>>> *CODE TO START caches explicitly:*
>>>
>>> @Override
>>> public void run(ApplicationArguments args) throws Exception {
>>> for (CacheName cacheName : CacheName.values()) {
>>> //We are configuring few caches only on client node for fast lookup during validations.
>>> if (ignite.configuration().isClientMode() && CacheName.isNearCache(cacheName)) {
>>> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
>>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(nearCacheSize));
>>> ignite.getOrCreateNearCache(cacheName, nearCfg);
>>> } else {
>>> ignite.cache(cacheName);
>>> }
>>> }
>>> LOGGER.info("Caches Started....");
>>> }
>>>
>>>
>>> Thanks,
>>> Prasad
>>>
>>> On Mon, Apr 29, 2019 at 5:34 PM Prasad Bhalerao <
>>> prasadbhalerao1983@gmail.com> wrote:
>>>
>>>> Yes, I found the issue. Actually it was in my Junit. I had accidently
>>>> added following line in my junit case. This was starting the cache and I
>>>> was trying to get it using my service call.
>>>>
>>>> //final IgniteCache<Object, Object> cache = ignite.cache(CacheName.ASSET_GROUP_CACHE.name());
>>>>
>>>> Thanks,
>>>> Prasad
>>>>
>>>>
>>>>
>>>> On Mon, Apr 29, 2019 at 5:10 PM Ilya Kasnacheev <
>>>> ilya.kasnacheev@gmail.com> wrote:
>>>>
>>>>> Hello!
>>>>>
>>>>> As this error points out, you can't have near cache with same name as
>>>>> already existing regular cache.
>>>>>
>>>>> Regards,
>>>>> --
>>>>> Ilya Kasnacheev
>>>>>
>>>>>
>>>>> пн, 29 апр. 2019 г. в 13:52, Prasad Bhalerao <
>>>>> prasadbhalerao1983@gmail.com>:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am getting "*Failed to start near cache* exception" while starting
>>>>>> near cache only on client node. Near cache is not configured on server
>>>>>> nodes.
>>>>>>
>>>>>> Cache configuration on server is node is as follows:
>>>>>>
>>>>>> private CacheConfiguration agCacheCfg() {
>>>>>>
>>>>>> CacheConfiguration agCacheCfg = new CacheConfiguration<>(CacheName.AG_CACHE.name());
>>>>>> agCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>>>>>> agCacheCfg.setWriteThrough(ENABLE_WRITE_THROUGH);
>>>>>> agCacheCfg.setReadThrough(false);
>>>>>> agCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
>>>>>> agCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
>>>>>> agCacheCfg.setBackups(1);
>>>>>> agCacheCfg.setIndexedTypes(DefaultDataAffinityKey.class, AgData.class);
>>>>>> Factory<AgDataCacheStore> storeFactory = FactoryBuilder.factoryOf(AgDataCacheStore.class);
>>>>>> agCacheCfg.setCacheStoreFactory(storeFactory);
>>>>>> agCacheCfg.setCacheStoreSessionListenerFactories(cacheStoreSessionListenerFactory());
>>>>>> agCacheCfg.setSqlIndexMaxInlineSize(100);
>>>>>> RendezvousAffinityFunction affinityFunction = new RendezvousAffinityFunction();
>>>>>> affinityFunction.setExcludeNeighbors(true);
>>>>>> agCacheCfg.setAffinity(affinityFunction);
>>>>>> agCacheCfg.setStatisticsEnabled(true);
>>>>>>
>>>>>>
>>>>>> return agCacheCfg;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> I am using following code to get the Near cache on client node only
>>>>>> for configured cache names.
>>>>>> Can some please help me with this?
>>>>>>
>>>>>> protected IgniteCache<K, T> cache() {
>>>>>> String cacheName = getCacheName();
>>>>>> if (this.cache == null) {
>>>>>> //We are configuring few caches only on client node for fast lookup during validations.
>>>>>> if (ignite.configuration().isClientMode() && NearCacheName.isNearCache(cacheName)) {
>>>>>> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
>>>>>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(10_000));
>>>>>> this.cache = ignite.createNearCache(cacheName, nearCfg);
>>>>>> } else {
>>>>>> this.cache = ignite.cache(cacheName);
>>>>>> }
>>>>>> }
>>>>>> return this.cache;
>>>>>> }
>>>>>>
>>>>>>
>>>>>> *EXCEPTION:*
>>>>>>
>>>>>> *javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started)*
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> * at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1303) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2960) at org.apache.ignite.IgniteSpringBean.createNearCache(IgniteSpringBean.java:382) at com.qualys.agms.grid.dao.AbstractDataGridDAO.cache(AbstractDataGridDAO.java:112) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:47) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:31) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:27) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:10) at com.qualys.agms.IgniteClientTester.testGet(IgniteClientTester.java:382) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started) at org.apache.ignite.internal.IgniteKernal.checkNearCacheStarted(IgniteKernal.java:3019) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2955) ... 37 more*
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> Prasad
>>>>>>
>>>>>> On Sat, Apr 20, 2019 at 9:05 AM Denis Magda <dm...@apache.org>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi Prasad,
>>>>>>>
>>>>>>> It's required to define a NearCacheConfiguration on a node you'd
>>>>>>> like to have it one. Use one of the approaches defined in the docs:
>>>>>>> https://apacheignite.readme.io/docs/near-caches
>>>>>>>
>>>>>>> Near caches can be created directly on *client* nodes by passing
>>>>>>> NearCacheConfiguration to the
>>>>>>> Ignite.createNearCache(NearCacheConfiguration) or
>>>>>>> Ignite.getOrCreateNearCache(NearCacheConfiguration) methods. Use
>>>>>>> the Ignite.getOrCreateCache(CacheConfiguration,
>>>>>>> NearCacheConfiguration) method if you need to both start a
>>>>>>> distributed cache dynamically and create a near cache for it.
>>>>>>>
>>>>>>> -
>>>>>>> Denis
>>>>>>>
>>>>>>>
>>>>>>> On Fri, Apr 19, 2019 at 5:53 AM Prasad Bhalerao <
>>>>>>> prasadbhalerao1983@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Is there any to enable near cache only on client nodes?
>>>>>>>>
>>>>>>>> I am using partitioned cache and using colocation to submit the
>>>>>>>> ignite jobs. But in my code I do few lookups on client node to validate the
>>>>>>>> data. To improve this lookup performance I want to enable near cache.
>>>>>>>>
>>>>>>>> I saw the example on GitHub and in ignite docs. But I am still
>>>>>>>> struggling to configure near cache on client nodes only.
>>>>>>>>
>>>>>>>> This my Ignite configuration on client node. All the cache
>>>>>>>> configurations are defined only on ignite server nodes.
>>>>>>>>
>>>>>>>> Can some please tell me where to include near cache configuration
>>>>>>>> in following config?
>>>>>>>>
>>>>>>>> private IgniteConfiguration getIgniteConfiguration(IgniteSpringBean ignite) {
>>>>>>>>
>>>>>>>> String[] hosts = appConfigProperties.getHosts().split(",");
>>>>>>>> TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
>>>>>>>> ipFinder.setAddresses(Arrays.asList(hosts));
>>>>>>>>
>>>>>>>> TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
>>>>>>>> discoSpi.setIpFinder(ipFinder);
>>>>>>>>
>>>>>>>> IgniteConfiguration cfg = new IgniteConfiguration();
>>>>>>>> cfg.setDiscoverySpi(discoSpi);
>>>>>>>> cfg.setIgniteInstanceName("springDataNode");
>>>>>>>> cfg.setPeerClassLoadingEnabled(false);
>>>>>>>> cfg.setRebalanceThreadPoolSize(4);
>>>>>>>> cfg.setClientFailureDetectionTimeout(failureDetectionTimeout);
>>>>>>>> //cfg.setLifecycleBeans(new IgniteLifeCycleBean());
>>>>>>>> cfg.setClientMode(true);
>>>>>>>> HashMap<String, String> attributeMap = new HashMap<>();
>>>>>>>> attributeMap.put(NODE_TYPE,NODE_TYPE_WEB);
>>>>>>>> cfg.setUserAttributes(attributeMap);
>>>>>>>>
>>>>>>>> return cfg;
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Prasad
>>>>>>>>
>>>>>>>
Re: Issue in starting Near cache only on client node
Posted by Prasad Bhalerao <pr...@gmail.com>.
Actually I wanted to start near cache only on client node using
getOrCreateNearCache method. But somehow it didn't work.
So now. I have configured near cache using cache.setNearCacheConfig method
in cache configuration. But this starts near cache on client as well as on
server node.
On Mon 1 Jul, 2019, 8:53 PM Ilya Kasnacheev <ilya.kasnacheev@gmail.com
wrote:
> Hello!
>
> I think the cache would start if listed in node's configuration (via XML
> or Java). Make sure you also have near caches there.
>
> Regards,
> --
> Ilya Kasnacheev
>
>
> чт, 27 июн. 2019 г. в 10:32, Prasad Bhalerao <prasadbhalerao1983@gmail.com
> >:
>
>> Hi,
>>
>> I am getting following error on ignite client nodes.
>>
>> *class org.apache.ignite.IgniteCheckedException: Failed to start near
>> cache (a cache with the same name without near cache is already started*
>>
>> To solve this issue I added following code in ApplicationRunner's run()
>> method to explicitly start the cache. Application runner Interface is
>> provided by spring boot to execute required code just before server startup.
>>
>> But even after doing this I am still getting error "a cache with the same
>> name without near cache is already started".
>>
>> I see following info messages in my log file *multiple times*. First
>> time it is logged when ApplicationRunner.run() method is invoked during
>> server startup.
>>
>> *o.a.i.i.p.cache.GridCacheProcessor - Started cache [name=DOMAIN_CACHE,
>> id=-2139013081, memoryPolicyName=null, mode=PARTITIONED,
>> atomicity=TRANSACTIONAL, backups=1]*
>>
>> On which events GridCacheProcessor starts the cache?
>>
>> Can this event be intercepted or handled to start near cache?
>>
>> What is the reason behind getting "GridCacheProcessor - Started cache"
>> info messages *multiple* *times *in log files?
>>
>> Is near cache is destroyed/invalidate when client node is reconnected to
>> the cluster?
>>
>> Can some please advise?
>>
>> *CODE TO START caches explicitly:*
>>
>> @Override
>> public void run(ApplicationArguments args) throws Exception {
>> for (CacheName cacheName : CacheName.values()) {
>> //We are configuring few caches only on client node for fast lookup during validations.
>> if (ignite.configuration().isClientMode() && CacheName.isNearCache(cacheName)) {
>> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(nearCacheSize));
>> ignite.getOrCreateNearCache(cacheName, nearCfg);
>> } else {
>> ignite.cache(cacheName);
>> }
>> }
>> LOGGER.info("Caches Started....");
>> }
>>
>>
>> Thanks,
>> Prasad
>>
>> On Mon, Apr 29, 2019 at 5:34 PM Prasad Bhalerao <
>> prasadbhalerao1983@gmail.com> wrote:
>>
>>> Yes, I found the issue. Actually it was in my Junit. I had accidently
>>> added following line in my junit case. This was starting the cache and I
>>> was trying to get it using my service call.
>>>
>>> //final IgniteCache<Object, Object> cache = ignite.cache(CacheName.ASSET_GROUP_CACHE.name());
>>>
>>> Thanks,
>>> Prasad
>>>
>>>
>>>
>>> On Mon, Apr 29, 2019 at 5:10 PM Ilya Kasnacheev <
>>> ilya.kasnacheev@gmail.com> wrote:
>>>
>>>> Hello!
>>>>
>>>> As this error points out, you can't have near cache with same name as
>>>> already existing regular cache.
>>>>
>>>> Regards,
>>>> --
>>>> Ilya Kasnacheev
>>>>
>>>>
>>>> пн, 29 апр. 2019 г. в 13:52, Prasad Bhalerao <
>>>> prasadbhalerao1983@gmail.com>:
>>>>
>>>>> Hi,
>>>>>
>>>>> I am getting "*Failed to start near cache* exception" while starting
>>>>> near cache only on client node. Near cache is not configured on server
>>>>> nodes.
>>>>>
>>>>> Cache configuration on server is node is as follows:
>>>>>
>>>>> private CacheConfiguration agCacheCfg() {
>>>>>
>>>>> CacheConfiguration agCacheCfg = new CacheConfiguration<>(CacheName.AG_CACHE.name());
>>>>> agCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>>>>> agCacheCfg.setWriteThrough(ENABLE_WRITE_THROUGH);
>>>>> agCacheCfg.setReadThrough(false);
>>>>> agCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
>>>>> agCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
>>>>> agCacheCfg.setBackups(1);
>>>>> agCacheCfg.setIndexedTypes(DefaultDataAffinityKey.class, AgData.class);
>>>>> Factory<AgDataCacheStore> storeFactory = FactoryBuilder.factoryOf(AgDataCacheStore.class);
>>>>> agCacheCfg.setCacheStoreFactory(storeFactory);
>>>>> agCacheCfg.setCacheStoreSessionListenerFactories(cacheStoreSessionListenerFactory());
>>>>> agCacheCfg.setSqlIndexMaxInlineSize(100);
>>>>> RendezvousAffinityFunction affinityFunction = new RendezvousAffinityFunction();
>>>>> affinityFunction.setExcludeNeighbors(true);
>>>>> agCacheCfg.setAffinity(affinityFunction);
>>>>> agCacheCfg.setStatisticsEnabled(true);
>>>>>
>>>>>
>>>>> return agCacheCfg;
>>>>> }
>>>>>
>>>>>
>>>>> I am using following code to get the Near cache on client node only
>>>>> for configured cache names.
>>>>> Can some please help me with this?
>>>>>
>>>>> protected IgniteCache<K, T> cache() {
>>>>> String cacheName = getCacheName();
>>>>> if (this.cache == null) {
>>>>> //We are configuring few caches only on client node for fast lookup during validations.
>>>>> if (ignite.configuration().isClientMode() && NearCacheName.isNearCache(cacheName)) {
>>>>> NearCacheConfiguration<K, T> nearCfg = new NearCacheConfiguration<>();
>>>>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(10_000));
>>>>> this.cache = ignite.createNearCache(cacheName, nearCfg);
>>>>> } else {
>>>>> this.cache = ignite.cache(cacheName);
>>>>> }
>>>>> }
>>>>> return this.cache;
>>>>> }
>>>>>
>>>>>
>>>>> *EXCEPTION:*
>>>>>
>>>>> *javax.cache.CacheException: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started)*
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> * at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1303) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2960) at org.apache.ignite.IgniteSpringBean.createNearCache(IgniteSpringBean.java:382) at com.qualys.agms.grid.dao.AbstractDataGridDAO.cache(AbstractDataGridDAO.java:112) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:47) at com.qualys.agms.grid.dao.AbstractDataGridDAO.putData(AbstractDataGridDAO.java:31) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:27) at com.qualys.agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridService.java:10) at com.qualys.agms.IgniteClientTester.testGet(IgniteClientTester.java:382) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)Caused by: class org.apache.ignite.IgniteCheckedException: Failed to start near cache (a cache with the same name without near cache is already started) at org.apache.ignite.internal.IgniteKernal.checkNearCacheStarted(IgniteKernal.java:3019) at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2955) ... 37 more*
>>>>>
>>>>>
>>>>> Thanks,
>>>>> Prasad
>>>>>
>>>>> On Sat, Apr 20, 2019 at 9:05 AM Denis Magda <dm...@apache.org> wrote:
>>>>>
>>>>>> Hi Prasad,
>>>>>>
>>>>>> It's required to define a NearCacheConfiguration on a node you'd like
>>>>>> to have it one. Use one of the approaches defined in the docs:
>>>>>> https://apacheignite.readme.io/docs/near-caches
>>>>>>
>>>>>> Near caches can be created directly on *client* nodes by passing
>>>>>> NearCacheConfiguration to the
>>>>>> Ignite.createNearCache(NearCacheConfiguration) or
>>>>>> Ignite.getOrCreateNearCache(NearCacheConfiguration) methods. Use the Ignite.getOrCreateCache(CacheConfiguration,
>>>>>> NearCacheConfiguration) method if you need to both start a
>>>>>> distributed cache dynamically and create a near cache for it.
>>>>>>
>>>>>> -
>>>>>> Denis
>>>>>>
>>>>>>
>>>>>> On Fri, Apr 19, 2019 at 5:53 AM Prasad Bhalerao <
>>>>>> prasadbhalerao1983@gmail.com> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Is there any to enable near cache only on client nodes?
>>>>>>>
>>>>>>> I am using partitioned cache and using colocation to submit the
>>>>>>> ignite jobs. But in my code I do few lookups on client node to validate the
>>>>>>> data. To improve this lookup performance I want to enable near cache.
>>>>>>>
>>>>>>> I saw the example on GitHub and in ignite docs. But I am still
>>>>>>> struggling to configure near cache on client nodes only.
>>>>>>>
>>>>>>> This my Ignite configuration on client node. All the cache
>>>>>>> configurations are defined only on ignite server nodes.
>>>>>>>
>>>>>>> Can some please tell me where to include near cache configuration in
>>>>>>> following config?
>>>>>>>
>>>>>>> private IgniteConfiguration getIgniteConfiguration(IgniteSpringBean ignite) {
>>>>>>>
>>>>>>> String[] hosts = appConfigProperties.getHosts().split(",");
>>>>>>> TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
>>>>>>> ipFinder.setAddresses(Arrays.asList(hosts));
>>>>>>>
>>>>>>> TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
>>>>>>> discoSpi.setIpFinder(ipFinder);
>>>>>>>
>>>>>>> IgniteConfiguration cfg = new IgniteConfiguration();
>>>>>>> cfg.setDiscoverySpi(discoSpi);
>>>>>>> cfg.setIgniteInstanceName("springDataNode");
>>>>>>> cfg.setPeerClassLoadingEnabled(false);
>>>>>>> cfg.setRebalanceThreadPoolSize(4);
>>>>>>> cfg.setClientFailureDetectionTimeout(failureDetectionTimeout);
>>>>>>> //cfg.setLifecycleBeans(new IgniteLifeCycleBean());
>>>>>>> cfg.setClientMode(true);
>>>>>>> HashMap<String, String> attributeMap = new HashMap<>();
>>>>>>> attributeMap.put(NODE_TYPE,NODE_TYPE_WEB);
>>>>>>> cfg.setUserAttributes(attributeMap);
>>>>>>>
>>>>>>> return cfg;
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Prasad
>>>>>>>
>>>>>>