You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by zshamrock <al...@gmail.com> on 2016/05/04 14:37:28 UTC

Ignite client near cache conflicts with server distributed cache

Based on the discussion in Gitter it was proposed to ask a question here.

package experiments.ignite;

import org.apache.ignite.Ignite;
import org.apache.ignite.Ignition;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.NearCacheConfiguration;

public class ClientNearCache {

    public static void main(String[] args) {
        final CacheConfiguration<String, String> cacheConfiguration = new
CacheConfiguration<>("sample");

        final IgniteConfiguration igniteConfiguration = new
IgniteConfiguration()
                .setGridName("experiments")
                .setCacheConfiguration(cacheConfiguration);

        Ignition.setClientMode(true);
        final Ignite client = Ignition.start(igniteConfiguration);
        client.createNearCache("sample", new NearCacheConfiguration<>());
    }
}


The code above fails with the following error (there is a server node
running in another process):

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:2593)
	at
org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2545)
	... 6 more

My expectations would be, that according to
https://apacheignite.readme.io/docs/clients-vs-servers#creating-distributed-caches,
calling Ignition.start(igniteConfiguration) first time, will create a
distributed server cache. And client.createNearCache() will create the near
cache for that specific node's client.

Is it a potential bug, or an expected behavior?




--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-client-near-cache-conflicts-with-server-distributed-cache-tp4768.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite client near cache conflicts with server distributed cache

Posted by Denis Magda <dm...@gridgain.com>.
There are several options how you can deal with this:

1) define caches in Spring XML configuration of all server nodes and start near caches on clients when needed;
2) start a special client that will initialize all required caches dynamically and stop it after that. The rest of the clients can later create near caches for the caches created by that client.

—
Denis

> On May 5, 2016, at 5:13 PM, zshamrock <al...@gmail.com> wrote:
> 
> Yes, removing definition of the cache from IgniteConfiguration, helps. And I
> know about this.
> 
> The point was that I wanted for the client to be self sufficient, i.e. to
> create all the distributed server caches first (by providing cache
> definition for IgniteConfiguration), and then configure the near cache.
> 
> Although, I've switched from this direction, and only configure now near
> cache for the client. But, still the scenario described could be a valid
> one. And it is for you to evaluate whether this is the expected behavior or
> a bug.
> 
> Thank you.
> 
> 
> 
> --
> View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-client-near-cache-conflicts-with-server-distributed-cache-tp4768p4792.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.


Re: Ignite client near cache conflicts with server distributed cache

Posted by Alexei Scherbakov <al...@gmail.com>.
You can't have on the client node "far" and "near" cache simultaneously.
The error message you get on the attempt is pretty self-explanatory.
So I see not bug here.

2016-05-05 17:13 GMT+03:00 zshamrock <al...@gmail.com>:

> Yes, removing definition of the cache from IgniteConfiguration, helps. And
> I
> know about this.
>
> The point was that I wanted for the client to be self sufficient, i.e. to
> create all the distributed server caches first (by providing cache
> definition for IgniteConfiguration), and then configure the near cache.
>
> Although, I've switched from this direction, and only configure now near
> cache for the client. But, still the scenario described could be a valid
> one. And it is for you to evaluate whether this is the expected behavior or
> a bug.
>
> Thank you.
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Ignite-client-near-cache-conflicts-with-server-distributed-cache-tp4768p4792.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 

Best regards,
Alexei Scherbakov

Re: Ignite client near cache conflicts with server distributed cache

Posted by zshamrock <al...@gmail.com>.
Yes, removing definition of the cache from IgniteConfiguration, helps. And I
know about this.

The point was that I wanted for the client to be self sufficient, i.e. to
create all the distributed server caches first (by providing cache
definition for IgniteConfiguration), and then configure the near cache.

Although, I've switched from this direction, and only configure now near
cache for the client. But, still the scenario described could be a valid
one. And it is for you to evaluate whether this is the expected behavior or
a bug.

Thank you.



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-client-near-cache-conflicts-with-server-distributed-cache-tp4768p4792.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite client near cache conflicts with server distributed cache

Posted by Alexei Scherbakov <al...@gmail.com>.
Hi,

You should remove definition of the cache from IgniteConfiguration:

Ignition.setClientMode(true);
IgniteConfiguration igniteConfiguration = new
IgniteConfiguration().setGridName("experiments");
Ignite client = Ignition.start(igniteConfiguration);
IgniteCache<Object, Object> nearCache =
client.getOrCreateNearCache("sample", new NearCacheConfiguration<>());

Did this helped?


2016-05-04 17:37 GMT+03:00 zshamrock <al...@gmail.com>:

> Based on the discussion in Gitter it was proposed to ask a question here.
>
> package experiments.ignite;
>
> import org.apache.ignite.Ignite;
> import org.apache.ignite.Ignition;
> import org.apache.ignite.configuration.CacheConfiguration;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.configuration.NearCacheConfiguration;
>
> public class ClientNearCache {
>
>     public static void main(String[] args) {
>         final CacheConfiguration<String, String> cacheConfiguration = new
> CacheConfiguration<>("sample");
>
>         final IgniteConfiguration igniteConfiguration = new
> IgniteConfiguration()
>                 .setGridName("experiments")
>                 .setCacheConfiguration(cacheConfiguration);
>
>         Ignition.setClientMode(true);
>         final Ignite client = Ignition.start(igniteConfiguration);
>         client.createNearCache("sample", new NearCacheConfiguration<>());
>     }
> }
>
>
> The code above fails with the following error (there is a server node
> running in another process):
>
> 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:2593)
>         at
>
> org.apache.ignite.internal.IgniteKernal.createNearCache(IgniteKernal.java:2545)
>         ... 6 more
>
> My expectations would be, that according to
>
> https://apacheignite.readme.io/docs/clients-vs-servers#creating-distributed-caches
> ,
> calling Ignition.start(igniteConfiguration) first time, will create a
> distributed server cache. And client.createNearCache() will create the near
> cache for that specific node's client.
>
> Is it a potential bug, or an expected behavior?
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Ignite-client-near-cache-conflicts-with-server-distributed-cache-tp4768.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>



-- 

Best regards,
Alexei Scherbakov