Saturday, September 15, 2012

Hazelcast Overview

This is just an evaluation summary. A shortened version of Hazelcast documentation. I pointed out the most important facts about it.

Hazelcast allows for distributing application data across cluster nodes. It is a peer-to-peer solution to avoid single point of failure.

  • Data in the cluster is almost evenly distributed (partitioned) across all nodes. So each node carries ~ (1/n * total-data) + backups , n being the number of nodes in the cluster.
    • Although it may be setup as Near Cache which disables even distribution
    • How can this work ? Hazelcast allows you to run distributed queries on distributed map.
    • Instead of getting entire entry set and iterating it locally, look for certain entries you are interested in
    • map.values(new SqlPredicate("active AND age < 30"));
      • OR
    • map.values(e.is("active").and(e.get("age").lessThan(30)));
    • queries run on each member in parallel and only the caller returns the results
  • Distributed Events
    • Hazelcast allows you to register for entry events to get notified when entries are added, updated or removed

    • MembershipListener for cluster membership events
    • InstanceListener for distributed instance creation and destroy events
    • MigrationListener for partition migration start and complete events
    • LifecycleListener for HazelcastInstance lifecycle events
    • EntryListener for IMap and MultiMap entry events
    • ItemListener for IQueue, ISet and IList item events
    • MessageListener for ITopic message events

  • Hazelcast allows you to load and store the distributed map entries from/to a persistent datastore such as relational database. Just supply it with a class that implements MapLoader and MapStore.
    • Existing implementations for JPA spec and MongoDB

  • Integration with Spring
    • overall configuration
    • registering distributed collections and maps and have them injected into beans
    • caching via com.hazelcast.spring.cache.HazelcastCacheManager
    • spring-data : JPA & MongoDB

  • Transaction context :  txn.begin(); txn.commit() / txn.rollback();
  • Hazelcast WM allows you to cluster user http sessions automatically
  • Distributed Execution - running tasks in parallel within cluster
  • Clients
    • enables you to do all Hazelcast operations without being a member of the cluster. It connects to one of the cluster members and delegates all cluster wide operations to it
    • Java Client
    • Rest Client

  • All distributed objects such as your key and value objects have to be Serializable !
  • Hazelcast has a very nice web based Management Center

No comments: