You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by techbysample <tu...@netmille.com> on 2016/03/06 18:48:34 UTC

IniteCache: How to ensure cache is 'rebalanced' when a node leaves topology?

Forum,

Background:

I started an IgniteCache using the following configuration:

              Ignition.setClientMode(true);

              try (Ignite ignite = Ignition.start()) {
	        
              CacheConfiguration<Integer, String> cacheCfg = new
CacheConfiguration<>("myCacheName");
              cacheCfg.setAtomicityMode(TRANSACTIONAL);
              cacheCfg.setCacheMode(CacheMode.PARTITIONED);
              cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
              cacheCfg.setStatisticsEnabled(true);
            
              IgniteCache<Integer, String> cache =
ignite.cache("myCacheName");
	          //   Store keys in cache
            for (int i = 0; i < 10; i++)
            cache.put(i, Integer.toString(i));
         
	            for (int i = 0; i < 10; i++)
	                System.out.println("Got [key=" + i + ", val=" +
cache.get(i) + ']');
	        }

For my example, In my topology I expect to have 1 client node and 2 server
nodes.
I expect a total of 10 keys/values.

Question:
I noticed that when I start with 1 client and 1 server, cache is re-balanced
when 2nd server nodes joins.
However, when 1 server node shuts down, leaving only 1 remaining server
node, cache is not re-balanced.
As a result, the node that was shut down had 4 keys/values. The remaining
node has only 6 keys/values.
It is my expectation that the remaining server node would have 10
key/values. Correct?


Please advise on how to ensure IgniteCache is re-balanced when node leaves
topology to have
a total of 10 keys/values?

Thank you in advance.








--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/IniteCache-How-to-ensure-cache-is-rebalanced-when-a-node-leaves-topology-tp3379.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: IniteCache: How to ensure cache is 'rebalanced' when a node leaves topology?

Posted by techbysample <tu...@netmille.com>.
Thank you. That worked.





--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/IgniteCache-How-to-ensure-cache-is-rebalanced-when-a-node-leaves-topology-tp3379p3385.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: IniteCache: How to ensure cache is 'rebalanced' when a node leaves topology?

Posted by Denis Magda <dm...@gridgain.com>.
You need to set number of backups to 1 to guarantee that there won't be
data loss when a node leaves the cluster.

Use CacheConfiguration.setBackups(1) method for that.

--

Denis

On Sunday, March 6, 2016, techbysample <tu...@netmille.com> wrote:

> Forum,
>
> Background:
>
> I started an IgniteCache using the following configuration:
>
>               Ignition.setClientMode(true);
>
>               try (Ignite ignite = Ignition.start()) {
>
>               CacheConfiguration<Integer, String> cacheCfg = new
> CacheConfiguration<>("myCacheName");
>               cacheCfg.setAtomicityMode(TRANSACTIONAL);
>               cacheCfg.setCacheMode(CacheMode.PARTITIONED);
>               cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC);
>               cacheCfg.setStatisticsEnabled(true);
>
>               IgniteCache<Integer, String> cache =
> ignite.cache("myCacheName");
>                   //   Store keys in cache
>             for (int i = 0; i < 10; i++)
>             cache.put(i, Integer.toString(i));
>
>                     for (int i = 0; i < 10; i++)
>                         System.out.println("Got [key=" + i + ", val=" +
> cache.get(i) + ']');
>                 }
>
> For my example, In my topology I expect to have 1 client node and 2 server
> nodes.
> I expect a total of 10 keys/values.
>
> Question:
> I noticed that when I start with 1 client and 1 server, cache is
> re-balanced
> when 2nd server nodes joins.
> However, when 1 server node shuts down, leaving only 1 remaining server
> node, cache is not re-balanced.
> As a result, the node that was shut down had 4 keys/values. The remaining
> node has only 6 keys/values.
> It is my expectation that the remaining server node would have 10
> key/values. Correct?
>
>
> Please advise on how to ensure IgniteCache is re-balanced when node leaves
> topology to have
> a total of 10 keys/values?
>
> Thank you in advance.
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/IniteCache-How-to-ensure-cache-is-rebalanced-when-a-node-leaves-topology-tp3379.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>