From user-return-26429-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Mon Jul 1 17:00:07 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id AF8D9180670 for ; Mon, 1 Jul 2019 19:00:06 +0200 (CEST) Received: (qmail 76721 invoked by uid 500); 1 Jul 2019 17:00:05 -0000 Mailing-List: contact user-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@ignite.apache.org Delivered-To: mailing list user@ignite.apache.org Received: (qmail 76711 invoked by uid 99); 1 Jul 2019 17:00:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Jul 2019 17:00:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 9D3A1180F2F for ; Mon, 1 Jul 2019 17:00:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.801 X-Spam-Level: * X-Spam-Status: No, score=1.801 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id kpvUKo3QYnJo for ; Mon, 1 Jul 2019 17:00:01 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2a00:1450:4864:20::542; helo=mail-ed1-x542.google.com; envelope-from=ilya.kasnacheev@gmail.com; receiver= Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 23D847E208 for ; Mon, 1 Jul 2019 17:00:01 +0000 (UTC) Received: by mail-ed1-x542.google.com with SMTP id k8so24345372edr.11 for ; Mon, 01 Jul 2019 10:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=MDzyXOqUX5vrieihiBx20OL4LFKAHKCJ+k/5b/Ty6Jg=; b=E8Lw9jxPVe/4iGa3hRiUiAn8G1QQwRTAO6MSbX+FuMNR01o3SNmFGTmte9TkwWcXY/ XXLQSJZ4gJl3NhquvImWnHg/peRj6c8rSvrpCFm8lNteleD4PYhpbUAEIqhchp1v895I 56y/QuRjIcilZqeE7F563TaQ/I14ASY/K4GSW1sd2GD58QFNFn6tTF9NuXb2QlWJQUHN 6hEqQ7DX6g237b170Oc4Hpsd5EXjFjxS/WHQS72ZRsyC1LpO7693Qq0LY+X/R1C6HOOa DiVINOKJ4EWIm4xYTwm+8yqWm7/502CUZ1cYcUjWK2ibb+v9dldfL9HkY5VwzTgO3ulQ 2m/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=MDzyXOqUX5vrieihiBx20OL4LFKAHKCJ+k/5b/Ty6Jg=; b=GW5r18Lxjb1VXCzaAynT58k7Px7nYlWzTlhLPfUS8JiQcmeDQ3o/m2Wx33Qvbp0irA XPWmtS5Qe0Bj+pvMUauynWdIihaXBohyXH5QxDSu1IuD/Xv3+6vcD+f30R7LoHQMyqbY 5u5VsRMmKPlbzg4NQojjvhVum3bs3+Z0LBEcf8mo23JOMmTyIswPzwstmT7NYCoDe3X3 PqKyOUJn2gFsoUj8tDmXxJIOcrWP5c5it2oa351ZwYuPc3Km5P/USh0jQJOUk43HeQju vqlRGP6hdy2EwKTC6LEDM/BtcW930fsP731fPS35a1O7VNP7UJMmM43LdNozGYbRw+cB 7SyA== X-Gm-Message-State: APjAAAVO5M9pwsVVLvH0aYLSOWv4WbHCFQvOiy1LziKIru4KC+lfS/25 dc+s30sC/BALti+o9vDEVBCLEK7oQoNDaPAvS0j3m/Nv X-Google-Smtp-Source: APXvYqweL7S0Ha91OL85i/WjOsTKMitbAuVu61349OuJ8VpEMh3ywhytqvXKHpXQ2jD69ES7ngnJh+8tED6o/9g+m4Y= X-Received: by 2002:a50:9947:: with SMTP id l7mr30935765edb.305.1562000400392; Mon, 01 Jul 2019 10:00:00 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ilya Kasnacheev Date: Mon, 1 Jul 2019 19:59:48 +0300 Message-ID: Subject: Re: Issue in starting Near cache only on client node To: user@ignite.apache.org Content-Type: multipart/alternative; boundary="0000000000000123bd058ca18f71" --0000000000000123bd058ca18f71 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 cache =3D ignite.getOrCreateCache( new CacheConfiguration("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, --=20 Ilya Kasnacheev =D0=BF=D0=BD, 1 =D0=B8=D1=8E=D0=BB. 2019 =D0=B3. =D0=B2 19:34, Prasad Bhale= rao : > 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 metho= d > in cache configuration. But this starts near cache on client as well as o= n > server node. > > > On Mon 1 Jul, 2019, 8:53 PM Ilya Kasnacheev 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 >> >> >> =D1=87=D1=82, 27 =D0=B8=D1=8E=D0=BD. 2019 =D0=B3. =D0=B2 10:32, Prasad B= halerao < >> 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 sta= rtup. >>> >>> 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=3DDOMAIN_CACH= E, >>> id=3D-2139013081, memoryPolicyName=3Dnull, mode=3DPARTITIONED, >>> atomicity=3DTRANSACTIONAL, backups=3D1]* >>> >>> 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 t= o >>> 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 nearCfg =3D new NearCacheConfigurati= on<>(); >>> 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 cache =3D ignite.cache(CacheName.A= SSET_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 >>>>> >>>>> >>>>> =D0=BF=D0=BD, 29 =D0=B0=D0=BF=D1=80. 2019 =D0=B3. =D0=B2 13:52, Prasa= d 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 serv= er >>>>>> nodes. >>>>>> >>>>>> Cache configuration on server is node is as follows: >>>>>> >>>>>> private CacheConfiguration agCacheCfg() { >>>>>> >>>>>> CacheConfiguration agCacheCfg =3D new CacheConfiguration<>(CacheNa= me.AG_CACHE.name()); >>>>>> agCacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); >>>>>> agCacheCfg.setWriteThrough(ENABLE_WRITE_THROUGH); >>>>>> agCacheCfg.setReadThrough(false); >>>>>> agCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC); >>>>>> agCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMo= de.FULL_SYNC); >>>>>> agCacheCfg.setBackups(1); >>>>>> agCacheCfg.setIndexedTypes(DefaultDataAffinityKey.class, AgData.cl= ass); >>>>>> Factory storeFactory =3D FactoryBuilder.factoryO= f(AgDataCacheStore.class); >>>>>> agCacheCfg.setCacheStoreFactory(storeFactory); >>>>>> agCacheCfg.setCacheStoreSessionListenerFactories(cacheStoreSession= ListenerFactory()); >>>>>> agCacheCfg.setSqlIndexMaxInlineSize(100); >>>>>> RendezvousAffinityFunction affinityFunction =3D new RendezvousAffi= nityFunction(); >>>>>> 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 cache() { >>>>>> String cacheName =3D getCacheName(); >>>>>> if (this.cache =3D=3D null) { >>>>>> //We are configuring few caches only on client node for fast loo= kup during validations. >>>>>> if (ignite.configuration().isClientMode() && NearCacheName.isNea= rCache(cacheName)) { >>>>>> NearCacheConfiguration nearCfg =3D new NearCacheConfigur= ation<>(); >>>>>> nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFact= ory<>(10_000)); >>>>>> this.cache =3D ignite.createNearCache(cacheName, nearCfg); >>>>>> } else { >>>>>> this.cache =3D ignite.cache(cacheName); >>>>>> } >>>>>> } >>>>>> return this.cache; >>>>>> } >>>>>> >>>>>> >>>>>> *EXCEPTION:* >>>>>> >>>>>> *javax.cache.CacheException: class org.apache.ignite.IgniteCheckedEx= ception: Failed to start near cache (a cache with the same name without nea= r cache is already started)* >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> * at org.apache.ignite.internal.processors.cache.GridCacheUtils.conv= ertToCacheException(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.a= gms.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(AbstractDataGri= dDAO.java:31) at com.qualys.agms.grid.dataservice.DefaultDataGridService.pu= tData(DefaultDataGridService.java:27) at com.qualys.agms.grid.dataservice.D= efaultDataGridService.putData(DefaultDataGridService.java:10) at com.qualys= .agms.IgniteClientTester.testGet(IgniteClientTester.java:382) at sun.reflec= t.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMeth= odAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.Dele= gatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at ja= va.lang.reflect.Method.invoke(Method.java:498) at org.junit.runners.model.F= rameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.in= ternal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at = org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.j= ava:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(Invo= keMethod.java:17) at org.springframework.test.context.junit4.statements.Run= BeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:= 74) at org.springframework.test.context.junit4.statements.RunAfterTestExecu= tionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.sprin= gframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.eval= uate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.cont= ext.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMeth= odCallbacks.java:86) at org.springframework.test.context.junit4.statements.= SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunn= er.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit= 4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org= .springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(Sprin= gJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$3.run(ParentR= unner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.j= ava: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.spring= framework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evalua= te(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context= .junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCal= lbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363= ) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(Sp= ringJUnit4ClassRunner.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.IdeaTestRu= nner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.r= t.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 start= ed) at org.apache.ignite.internal.IgniteKernal.checkNearCacheStarted(Ignite= Kernal.java:3019) at org.apache.ignite.internal.IgniteKernal.createNearCach= e(IgniteKernal.java:2955) ... 37 more* >>>>>> >>>>>> >>>>>> Thanks, >>>>>> Prasad >>>>>> >>>>>> On Sat, Apr 20, 2019 at 9:05 AM Denis Magda >>>>>> 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 val= idate the >>>>>>>> data. To improve this lookup performance I want to enable near cac= he. >>>>>>>> >>>>>>>> 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(IgniteSpringBea= n ignite) { >>>>>>>> >>>>>>>> String[] hosts =3D appConfigProperties.getHosts().split(","); >>>>>>>> TcpDiscoveryVmIpFinder ipFinder =3D new TcpDiscoveryVmIpFinder()= ; >>>>>>>> ipFinder.setAddresses(Arrays.asList(hosts)); >>>>>>>> >>>>>>>> TcpDiscoverySpi discoSpi =3D new TcpDiscoverySpi(); >>>>>>>> discoSpi.setIpFinder(ipFinder); >>>>>>>> >>>>>>>> IgniteConfiguration cfg =3D 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 attributeMap =3D new HashMap<>(); >>>>>>>> attributeMap.put(NODE_TYPE,NODE_TYPE_WEB); >>>>>>>> cfg.setUserAttributes(attributeMap); >>>>>>>> >>>>>>>> return cfg; >>>>>>>> } >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Prasad >>>>>>>> >>>>>>> --0000000000000123bd058ca18f71 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

Unfortunately, near c= aches configuration is somewhat confusing.

I can s= ee in the docs the following:
// Create a distributed cache on server no= des and // a near cache on the local node, named &= quot;myCache". IgniteCache<Integer, <= span class=3D"gmail-cm-variable-3">Integer> cache =3D igni= te.getOrCreateCache( new CacheConfiguration<Integer, Integer>(= "myCache"), nearCfg);
If that does not work (when myCache i= s already present on server but without near cache), please share a reprodu= cer I can tweak.

Regards,
--
Ilya Kasnacheev

=D0=BF=D0=BD, 1 =D0=B8=D1=8E=D0=BB. 2019 =D0=B3. =D0=B2 19:34, Pras= ad Bhalerao <prasadbhale= rao1983@gmail.com>:
Actually I wanted to start near cache only on = client node using getOrCreateNearCache method. But somehow it didn't wo= rk.=C2=A0

So now. I have confi= gured near cache using cache.setNearCacheConfig method in cache configurati= on. 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 wrot= e:
Hello!

I think the cache would start if l= isted in node's configuration (via XML or Java). Make sure you also hav= e near caches there.

Regards,
--
Ilya Kasnacheev

<= /div>
= =D1=87=D1=82, 27 =D0=B8=D1=8E=D0=BD. 2019 =D0=B3. =D0=B2 10:32, Prasad Bhal= erao <prasadbhalerao1983@gmail.com>:
=
Hi,

I am getting following error on ignite client nodes.

c= lass 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 followi= ng code in ApplicationRunner's run() method to explicitly start the cac= he. Application runner Interface is provided by spring boot to execute requ= ired code just before server startup.

But even aft= er doing this I am still getting error "a cache with the same name wit= hout near cache is already started".

I see f= ollowing info messages in my log file multiple times. Firs= t time it is logged when ApplicationRunner.run() method is invoked during s= erver startup.

o.a.i.i= .p.cache.GridCacheProcessor - Started cache [name=3DDOMAIN_CACHE, id=3D-213= 9013081, memoryPolicyName=3Dnull, mode=3DPARTITIONED, atomicity=3DTRANSACTI= ONAL, backups=3D1]

On whi= ch events GridCacheProcessor starts the cache?

Ca= n this event be intercepted or handled to start near cache?

<= /div>
What is the reason behind getting "GridCacheProcessor - Star= ted cache" info messages multiple times in log files?

Is near cache is destroyed/invalidate=C2=A0= when client node is reconnected to the cluster?

Can some please advise?
=

CODE TO START caches explicitly:
@Override
public void run(Appl= icationArguments 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() && Cac= heName.isNearCache(cacheName)) { NearCacheConfiguration<K, T> nearCfg =3D new NearCacheConfiguration<>()= ;
nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactory<>(nearCa= cheSize));
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 <pr= asadbhalerao1983@gmail.com> wrote:
<= div dir=3D"ltr">
Yes, I found the issue. Actually it was in my Junit. I= had accidently added following line in my junit case. This was starting th= e cache and I was trying to get=C2=A0=C2=A0it using my service call.
=

//final IgniteCache<Object, Object> cache =3D ignite.cache(CacheName.ASSET_GROUP_CACHE.name());
Thanks= ,
Prasad


On Mon, Apr 29, 2019 at 5:10 PM Ilya Kasnacheev <ilya.ka= snacheev@gmail.com> wrote:
Hell= o!

As this error points out, you can't have ne= ar cache with same name as already existing regular cache.

Regards,
--
I= lya Kasnacheev


=
=D0=BF=D0=BD, 29 =D0=B0=D0=BF=D1=80. 2019 =D0=B3. =D0=B2 13:5= 2, Prasad Bhalerao <prasadbhalerao1983@gmail.com>:
=
Hi,
=

I am getting "Failed to start near cache = exception" while starting near cache only on client node.= =C2=A0Near cache is not configured on server nodes.=C2=A0

Cache configuration on server is node is as follows:<= br>
private CacheConfiguration agCach=
eCfg() {

CacheConfiguration agCacheCfg =3D new CacheConfiguration<>(CacheNam= e.= AG_CACHE.name());
agCacheCfg.setAtomicityMode(CacheAtomicityMod= e.= TRANSACTIONAL);
agCacheCfg.setWriteThrough(ENABLE_WRITE_THROUGH);
agCa= cheCfg.setReadThrough(f= alse);
agCacheCfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
agCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMo= de.FULL_SYNC);
agCacheCfg.setBackups(1);
agCacheCfg.setIndexedTypes(DefaultDataAffinityKey.class
, AgData.class);
Factory= <AgDataCacheStore> storeFactory =3D FactoryBuilder.factoryOf(AgDataCacheStore.class);
agCacheCfg.setCacheStoreFact= ory(storeFactory);
agCacheCfg.setCacheStoreSessionListenerFactories(ca= cheStoreSessionListenerFactory());
agCacheCfg.setSqlIndexMaxInlineSize= (100);
RendezvousAffinityFun= ction affinityFunction =3D new RendezvousAffinityFunction();
affinityFunction.setExclu= deNeighbors(true= );
agCacheCfg.setAffinity(affinityFunction);
agCacheCfg.setStatis= ticsEnabled(true= );


return = agCacheCfg;
}

I am using following code to get the Near cache on clien= t node=C2=A0only for configured cache names.
Can some please help= me with this?

<= /font>
protected IgniteCache<K, =
T> cache() {
String cacheName =3D getCacheName();
if (this.cache =3D=3D null) {
//We are configuring few caches only on client = node for fast lookup during validations.
if (ignite.configuration().isClientMode() && NearCac= heName.isNearCache(cacheName)) { NearCacheConfiguration<K, T> nearCfg =3D new NearCacheConfigur= ation<>();
nearCfg.setNearEvictionPolicyFactory(new LruEvictionPolicyFactor= y<>(10_000));
this.cache =3D ignite.createNearCache(cacheNam= e, nearCfg);
} e= lse {
t= his.cache =3D ignite
.cache(cacheName);
}
}
return this.cache;
}

EX=
CEPTION:
javax.cache.CacheException: class org.apache.ignite.IgniteCh=
eckedException: Failed to start near cache (a cache with the same name with=
out near cache is already started)
=C2= =A0at org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToC= acheException(GridCacheUtils.java:1303)
=C2=A0at org.apache.ignite.inter= nal.IgniteKernal.createNearCache(IgniteKernal.java:2960)
=C2=A0at org.ap= ache.ignite.IgniteSpringBean.createNearCache(IgniteSpringBean.java:382)
= =C2=A0at com.qualys.agms.grid.dao.AbstractDataGridDAO.cache(AbstractDataGri= dDAO.java:112)
=C2=A0at com.qualys.agms.grid.dao.AbstractDataGridDAO.put= Data(AbstractDataGridDAO.java:47)
=C2=A0at com.qualys.agms.grid.dao.Abst= ractDataGridDAO.putData(AbstractDataGridDAO.java:31)
=C2=A0at com.qualys= .agms.grid.dataservice.DefaultDataGridService.putData(DefaultDataGridServic= e.java:27)
=C2=A0at com.qualys.agms.grid.dataservice.DefaultDataGridServ= ice.putData(DefaultDataGridService.java:10)
=C2=A0at com.qualys.agms.Ign= iteClientTester.testGet(IgniteClientTester.java:382)
=C2=A0at sun.reflec= t.NativeMethodAccessorImpl.invoke0(Native Method)
=C2=A0at sun.reflect.N= ativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
=C2=A0a= t sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorI= mpl.java:43)
=C2=A0at java.lang.reflect.Method.invoke(Method.java:498)=C2=A0at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Fram= eworkMethod.java:50)
=C2=A0at org.junit.internal.runners.model.Reflectiv= eCallable.run(ReflectiveCallable.java:12)
=C2=A0at org.junit.runners.mod= el.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
=C2=A0at o= rg.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.jav= a:17)
=C2=A0at org.springframework.test.context.junit4.statements.RunBef= oreTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)=
=C2=A0at org.springframework.test.context.junit4.statements.RunAfterTes= tExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
=C2= =A0at org.springframework.test.context.junit4.statements.RunBeforeTestMetho= dCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
=C2=A0at org.s= pringframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.e= valuate(RunAfterTestMethodCallbacks.java:86)
=C2=A0at org.springframewor= k.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84= )
=C2=A0at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)=
=C2=A0at org.springframework.test.context.junit4.SpringJUnit4ClassRunne= r.runChild(SpringJUnit4ClassRunner.java:251)
=C2=A0at org.springframewor= k.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRun= ner.java:97)
=C2=A0at org.junit.runners.ParentRunner$3.run(ParentRunner.= java:290)
=C2=A0at org.junit.runners.ParentRunner$1.schedule(ParentRunne= r.java:71)
=C2=A0at org.junit.runners.ParentRunner.runChildren(ParentRun= ner.java:288)
=C2=A0at org.junit.runners.ParentRunner.access$000(ParentR= unner.java:58)
=C2=A0at org.junit.runners.ParentRunner$2.evaluate(Parent= Runner.java:268)
=C2=A0at org.springframework.test.context.junit4.statem= ents.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:= 61)
=C2=A0at org.springframework.test.context.junit4.statements.RunAfter= TestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
=C2=A0at= org.junit.runners.ParentRunner.run(ParentRunner.java:363)
=C2=A0at org.= springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit= 4ClassRunner.java:190)
=C2=A0at org.junit.runner.JUnitCore.run(JUnitCore= .java:137)
=C2=A0at com.intellij.junit4.JUnit4IdeaTestRunner.startRunner= WithArgs(JUnit4IdeaTestRunner.java:68)
=C2=A0at com.intellij.rt.executio= n.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)=
=C2=A0at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAnd= Start(JUnitStarter.java:242)
=C2=A0at com.intellij.rt.execution.junit.JU= nitStarter.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)
=C2=A0at org.apache.ignite.i= nternal.IgniteKernal.checkNearCacheStarted(IgniteKernal.java:3019)
=C2= =A0at org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.= java:2955)
=C2=A0... 37 more

= Thanks,
Prasad

On Sat, Apr 20, 2019 at 9:0= 5 AM Denis Magda <dmagda@apache.org> wrote:
Hi Prasad,

It's required to define a Ne= arCacheConfiguration on a node you'd like to have it one. Use one of th= e approaches defined in the docs:

Near caches can be created direct= ly on=C2=A0client=C2=A0nodes by passing=C2=A0NearCacheConfiguration=C2=A0to the=C2=A0Ignite.createNearCache(NearCacheConfigurat= ion)=C2=A0or=C2=A0<= /span>Ignite.getOrCre= ateNearCache(NearCacheConfiguration)=C2=A0methods. Use the=C2=A0Ignite.getOrCreateCache(CacheConfiguration, = NearCacheConfiguration)=C2=A0method if you need to both start a distributed cache dynamically = and create a near cache for it.
<= br clear=3D"all">
-
Denis


On Fri, Apr 19, 2019 at 5:53 AM P= rasad Bhalerao <prasadbhalerao1983@gmail.com> wrote:
<= div dir=3D"ltr">
Hi,

Is there any to enable ne= ar cache only on client nodes?

I am using partitio= ned 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=C2=A0 s= aw the example on GitHub and in ignite docs. But I am still struggling to c= onfigure near cache on client nodes only.

This my = Ignite configuration on client node. All the cache configurations are defin= ed only on ignite server nodes.

Can some please te= ll me where to include near cache configuration in following config?
<= div>
private IgniteConfiguration ge=
tIgniteConfiguration(IgniteSpringBean ignite) {

String[] hosts =3D= appConfigProperties= .getHosts().split(",");
TcpDiscoveryVmIpFinder ipFinder =3D new TcpDiscoveryVmIpFinde= r();
ipFinder.setAddresses(Arrays.as= List(hosts));

TcpDiscoverySpi discoSpi =3D new TcpDiscoverySpi();
disc= oSpi.setIpFinder(ipFinder);

IgniteConfiguration cfg =3D new IgniteConfiguration();=
cfg.setDiscoverySpi(discoSpi);
cfg.setIgniteInstanceName("springDataNode");
cfg.setPeerClassLoadingEnabled(false);
cfg.setRebalanceThreadPoolSize(4
);
cfg.setClientFailureDetection= Timeout(failureDetec= tionTimeout);
//cfg.setLifecycleBeans(new IgniteLifeCycleBean());
cfg.setClientM= ode(true);
= HashMap<String, String> attributeMap =3D new HashMap<>();
attributeMap.put= (N= ODE_TYPE,NODE_TYPE_WEB);
cfg.setUserAttributes(attributeMa= p);

return cfg;
}


Th= anks,
Prasad
--0000000000000123bd058ca18f71--