java - Hazelcast: Can I configure a Map per JVM? -


is there option in hazelcast make map cache values per node, , not replicate state? thought difference between getmap() , getdistributedmap() seems both replicated between nodes.

i have application in weblogic cluster, configuration is:

<?xml version="1.0" encoding="utf-8"?> <hazelcast>     <properties>         <property name="hazelcast.logging.type">slf4j</property>     </properties>     <network>         <port auto-increment="true">5107</port>         <join>             <multicast enabled="false" />             <tcp-ip enabled="true">                 <members>127.0.0.1:5701, 127.0.0.2:5702</members>             </tcp-ip>         </join>     </network>     <map name="default">         <time-to-live-seconds>1800</time-to-live-seconds>         <backup-count>0</backup-count>         <eviction-policy>lru</eviction-policy>     </map> </hazelcast> 

in logs can see both nodes up

members [2] {         member [127.0.0.1]:5107         member [127.0.0.1]:5108 } 

when call method in first node can see cache added

.default (self-tuning)'] [] debug b.c.l.c.c.i.e.c.h.abstracthazelcastcacheinterceptor - hazelcast instance hazelcastinstance{name='my-instance', node=address[127.0.0.1]:5107} 2015-03-31 21:09:40.040 [[active] executethread: '1' queue: 'weblogic.kernel.default (self-tuning)'] [] debug b.c.l.c.c.i.e.c.h.abstracthazelcastcacheinterceptor - cache map imap{name='my_app.cache.cachename'} 2015-03-31 21:09:40.040 [[active] executethread: '1' queue: 'weblogic.kernel.default (self-tuning)'] [] debug b.c.l.c.c.i.e.c.h.abstracthazelcastcacheinterceptor - adding object in cache key 2342425 

but in second node see cache name log, it's using added cache...

.default (self-tuning)'] [] debug b.c.l.c.c.i.e.c.h.abstracthazelcastcacheinterceptor - hazelcast instance hazelcastinstance{name='my-instance', node=address[127.0.0.1]:5108} 2015-03-31 21:09:40.040 [[active] executethread: '1' queue: 'weblogic.kernel.default (self-tuning)'] [] debug b.c.l.c.c.i.e.c.h.abstracthazelcastcacheinterceptor - cache map imap{name='my_app.cache.cachename'} 

am missing configuration? possible achieve hazelcast?

as mentioned in comment use case where:

  • put(key, value) adds tuple locally
  • evict(key) evicts maps

isn't transparent , doubt hazelcast (or popular in-memory grid) supports out of box can implement simple pub-sub hazelcast. on each hazelcast node start topic listener:

itopic<string> eviction = hazelcast.gettopic("evict"); eviction.addmessagelistener(new evictionlistener()); 

where evictionlistener like:

public class evictionlistener implements messagelistener<string> {     @override    public void onmessage(message<string> message) {       // gets local (per jvm) cache , evicts entry       cache.getcache().evict(message.getmessageobject());    } } 

and can implement eviction method as:

public void evict(string key) {     hazelcast.gettopic("evict").publish(key); } 

something this. need create cache (as mentioned simple java map or guava cache) per jvm , use evict method eviction.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -