3

I am exploring the notion of using Hazelcast (or any another caching framework) to advertise services within a cluster. Ideally when a cluster member departs then its services (or objects advertising them) should be removed from the cache.

Is this at all possible?

Martin Cowie
  • 2,788
  • 7
  • 38
  • 74
  • 1
    This is purely my opinion (but then your question does seem to solicit opinions), but I believe zookeeper is more suited to your use case. ZK ephemeral nodes do pretty much exactly what you are asking for. – Aurand Oct 31 '13 at 19:57
  • @Aurand Hazelcast is much more lightweight tool than ZK. You can just embed and use it. – Konstantin Solomatov Mar 24 '16 at 04:06

1 Answers1

3

It is possible for sure.

The question is: which solution do you like.

If the services can be stored in a map, you could create a map with a ttl of e.g. a few minutes and each member needs to refresh its service to prevent the services from expiring.

An alternative solution is to listen to member changes using the membershiplistener and once a member leaves, the services that belong to that member need to be removed from the map.

If you don't like none of this, you could create your own SPI based implementation. The SPI is the lower level infrastructure used by hazelcast to create its distributed datastructures. A lot more work, but also a lot of flexibility.

So there are many solutions.

pveentjer
  • 10,545
  • 3
  • 23
  • 40