Failed to start near cache (a cache with the same name without near cache is already started)

classic Classic list List threaded Threaded
6 messages Options
Hemambara Hemambara
Reply | Threaded
Open this post in threaded view
|

Failed to start near cache (a cache with the same name without near cache is already started)

I followed the below post
http://apache-ignite-users.70518.x6.nabble.com/Failed-to-start-near-cache-a-cache-with-the-same-name-without-near-cache-is-already-started-td18322.html
but it did not solve my problem, hence requesting for help.

I tried two options
a) Start ignite with below xml config and then call
this.ignite.getOrCreateNearCache("MyCache", nearCfg);
b) Start ignite with below xml config and then call
this.ignite.getOrCreateCache("MyNearCache"); and then
this.ignite.getOrCreateNearCache("MyNearCache", nearCfg);

Both are giving error like "Failed to start near cache (a cache with the
same name without near cache is already started)". AS per doc, I just need
to pass existing cache name and pass near cfg to get near cache for client
alone. But either way I am getting exception. Can you provide how can I
create a near cache ONLY for client, but not on server


<bean id="MyCache"
class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="MyCache"/>
<property name="storeKeepBinary" value="false"/>
<property name="statisticsEnabled" value="false"/>
<property name="sqlSchema" value="PUBLIC"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="backups" value="1"/>
<property name="writeSynchronizationMode" value="FULL_SYNC"/>
<property name="partitionLossPolicy" value="READ_WRITE_SAFE"/>
<property name="affinity">
<bean
class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
<property name="excludeNeighbors" value="true"/>
</bean>
</property>
<property name="queryEntities">
<list>
<bean class="org.apache.ignite.cache.QueryEntity">
<property name="tableName" value="MyCache"/>
<property name="keyType" value="java.lang.String"/>
<property name="valueType" value="java.lang.String"/>
</bean>
</list>
</property>
</bean>
</beans>



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
akorensh akorensh
Reply | Threaded
Open this post in threaded view
|

Re: Failed to start near cache (a cache with the same name without near cache is already started)

This post was updated on .
This happens because you created a cache without a near configuration first
then tried to create it again with a near config.

for example:
  start a server node
   then do as follows:
        NearCacheConfiguration<Integer, Integer> nearCfg = new
NearCacheConfiguration<>();
        IgniteCache cache1 = ignite.getOrCreateCache("myCache1");
        IgniteCache cache2 = ignite.getOrCreateNearCache("myCache1",
nearCfg);   <-- exception thrown here because you already created this cache

In order to remedy this put the near cache config into the original cache
config.
i.e.
        CacheConfiguration<Integer, Integer> cfg = new
CacheConfiguration<>("myCache1");
        NearCacheConfiguration<Integer, Integer> nearCfg = new
NearCacheConfiguration<>();
        cfg.setNearConfiguration(nearCfg);
        IgniteCache cache1 = ignite.getOrCreateCache(cfg);



more info: https://www.gridgain.com/docs/latest/developers-guide/near-cache

If you start a cache on the server and then use getOrCreateNearCache(...) on the client
then you would be able to dynamically create a near cache for that cache.

i.e.

  On server:
    cache = ignite.getOrCreateCache("cache1")

  On client:
    cache = ignite.getOrCreateNearCache("cache1")
   
  Start Server, then client (with the above code)

  Here the cache on the client would be a dynamically created near cache referencing "cache1" created on the server.

Thanks, Alex





--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Hemambara Hemambara
Reply | Threaded
Open this post in threaded view
|

Re: Failed to start near cache (a cache with the same name without near cache is already started)

Thank you. I am not getting this error now. But not sure if something wrong
with config. When I call getAll(all keys) on near cache, then the
performance is worse than regular cache. If regular cache getAll() is taking
100ms then near cache getAll() is taking 330 ms. Its almost 3 times. I am
expecting better performance as the near cache is local



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

Re: Failed to start near cache (a cache with the same name without near cache is already started)

Hello!

Did you try to profile it? What is taking the time?

Regards,
--
Ilya Kasnacheev


ср, 27 нояб. 2019 г. в 18:59, Hemambara <[hidden email]>:
Thank you. I am not getting this error now. But not sure if something wrong
with config. When I call getAll(all keys) on near cache, then the
performance is worse than regular cache. If regular cache getAll() is taking
100ms then near cache getAll() is taking 330 ms. Its almost 3 times. I am
expecting better performance as the near cache is local



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Hemambara Hemambara
Reply | Threaded
Open this post in threaded view
|

Re: Failed to start near cache (a cache with the same name without near cache is already started)

I have disabled copyonread and the time taken to getAll() reduced to 1/3.
Earlier it was 300 ms on 10k entries and now it is 100ms. Is disabling
copyonread is fine ???



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Mikael Mikael
Reply | Threaded
Open this post in threaded view
|

Re: Failed to start near cache (a cache with the same name without near cache is already started)

Hi!

You need to be careful, with copyOnRead disabled, any local read can
return a "real" copy of the object and you can cause pretty weird bugs
if you modify that object, so be careful with that or best is to only
use it for readonly cases.

If you see that much performance improvement I would think that you run
it locally or on one node, when you fetch remote data copyOnRead would
not make any difference.

Mikael

Den 2019-12-09 kl. 12:43, skrev Hemambara:
> I have disabled copyonread and the time taken to getAll() reduced to 1/3.
> Earlier it was 300 ms on 10k entries and now it is 100ms. Is disabling
> copyonread is fine ???
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>