Near cache configuration issue: it is distributing data between nodes

89 views
Skip to first unread message

Daniel López

unread,
Apr 28, 2015, 6:00:46 AM4/28/15
to haze...@googlegroups.com
Hi there,

I'm trying to get some IMaps to be used as near cache, but they don't seem to be storin the data in the near cache and they are distributing the data between the different nodes.

The IMaps are configured like this:

            Config cfg = XmlConfigBuilder().build();
-------
            MapConfig mapConfig = cfg.getMapConfig(cacheName);
            if (mapConfig == null) {
                mapConfig = new MapConfig(cacheName);
                cfg.addMapConfig(mapConfig);
            }
            NearCacheConfig nearCacheConfig = mapConfig.getNearCacheConfig();
            if (nearCacheConfig == null) {
                nearCacheConfig = new NearCacheConfig();
                mapConfig.setNearCacheConfig(nearCacheConfig);
            }
            nearCacheConfig.setName(cacheName);
            nearCacheConfig.setCacheLocalEntries(true);
            ...
-------
I then load some data in the maps and I check their stats:

imap.getLocalMapStats().getOwnedEntryCount() -> returns 100, for example
imap.getLocalMapStats().getNearCacheStats().getOwnedEntryCount() -> always return 0

if I start another node with the same configuration and check the stats again and I get on each node:

imap.getLocalMapStats().getOwnedEntryCount() -> returns 50, aprox.
imap.getLocalMapStats().getNearCacheStats().getOwnedEntryCount() -> always return 0
------
If I don't configure the maps as near cache, I can see that imap.getLocalMapStats().getNearCacheStats() returns null, so something is happening, but items are not stored in the near cache.

Is there anything else that needs to be done so the data are stored in the near cache?

Cheers!
D.

PD: Hazelcast version: 3.4.2.

Enes Akar

unread,
Apr 28, 2015, 6:06:23 AM4/28/15
to haze...@googlegroups.com
Hi;

Near-cache is filled after each get() operation that fetches item from remote node.

So try traversing items ( get() ) in a loop; you should see increased number of items in near cache.   




--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/231606a4-989d-43e3-9e29-ab940fcc83a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Enes Akar
Director of Engineering
Mahir İz Cad. No:35, Altunizade, İstanbul

Daniel López

unread,
Apr 28, 2015, 6:32:56 AM4/28/15
to haze...@googlegroups.com
I see, I would have expected than putting it in the map would also store it in the near cache. Good to know. I added a get() after the put() and I can see now the near cache filled in.
Thanks.

One question then, I'm trying to set it up so a group of nodes all have all the data in the near cache, so no remote call should be required for them and just having another smaller set of nodes be able to modify that data, that should be then replicated to the other nodes.

I can live with temporarilystale data while the update gets to the near cache, but I'd like the maps to use the near cache so the access is predictable. We have already sized the nodes accordingly so the near cache fits in.

If I understand now correcly, the near cache is not going to be updated until a get() is performed, so some calls would be local, others would be remote, which is something I wanted to avoid, if possible.

Is that a way to accomplish that? Is that a bad idea?
D.

Enes Akar

unread,
Apr 28, 2015, 8:15:53 AM4/28/15
to haze...@googlegroups.com

Daniel López

unread,
Apr 28, 2015, 8:23:54 AM4/28/15
to haze...@googlegroups.com
I checked that, but what worries me is that "Lost or missing updates are neither tracked nor resent.". Temporarily stale data is fine, uncontrolled lost updates is not, in my case.

D.

--
You received this message because you are subscribed to a topic in the Google Groups "Hazelcast" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hazelcast/2sZtfLJm4VU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hazelcast+...@googlegroups.com.

To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.

Lukas Blunschi

unread,
May 13, 2015, 10:11:01 AM5/13/15
to haze...@googlegroups.com
Hi,

instead of ReplicatedMap you could also use invalidation on the near cache. A put() will then invalidate stale, cached copies on all nodes.

nearCacheConfig.setInvalidateOnChange(true);

Cheers,
Lukas
Reply all
Reply to author
Forward
0 new messages