现在的位置: 首页 > 综合 > 正文

[转]Hazelcast简介

2013年10月07日 ⁄ 综合 ⁄ 共 2527字 ⁄ 字号 评论关闭

Hazelcase 简介


 

 

 

以下内容,
原文出自: http://www.open-open.com/open253825.htm

 

 

Hazelcast是一个高度可扩展的数据分发和集群平台。特性包括: 
提供java.util.{Queue, Set, List, Map}分布式实现。 
提供java.util.concurrency.locks.Lock分布式实现。 
提供java.util.concurrent.ExecutorService分布式实现。 
提供用于一对多关系的分布式MultiMap。
提供用于发布/订阅的分布式Topic(主题)。
通过JCA与J2EE容器集成和事务支持。
提供用于安全集群的Socket层加密。
支持同步和异步持久化。
为Hibernate提供二级缓存Provider 。
通过JMX监控和管理集群。
支持动态HTTP Session集群。
利用备份实现动态分割。
支持动态故障恢复。

 


 

 以下内容,
原文出自:   http://www.cnblogs.com/gpcuster/archive/2010/09/26/1836049.html

 

要使用分布式的Map,只需要以下代码即可实现:

 

Hazelcast的官网上面有一个非常直观的视频:http://www.hazelcast.com/screencast.jsp,建议有兴趣的朋友花10分钟时间看看。

还有一份PDF可以参考:http://roma.javaday.it/javaday2010/sites/default/files/ClusteringHazelcast-javaday.pdf

Hazelcast作为一款与ZooKeeper类似的开源实现,我在网上找了一篇相关的文章:http://blog.armstrongconsulting.com/?p=132 在这篇文章中有一段这样写道:

I had occasional hangs with Hazelcast 1.8.4 which caused me to switch to Zookeeper. As expected, Zookeeper was a lot harder to use than Hazelcast – you need Zookeeper installed on 3 servers. There’s no official java client, just some recipes and I found an implementation of Zookeeper locks called Cages on google code. For a java developer, Hazelcast is obviously way easier to use.

另外,在Hazelcast的官方文档中,提到了Hazelcast的集群机制:

If there is no existing node, then the node will be the first member of the cluster. If multicast is enabled then it will start a multicast listener so that it can respond to incoming join requests. Otherwise it will listen for join request coming via TCP/IP.

If there is an existing cluster already, then the oldest member in the cluster will receive the join request and check if the request is for the right group. If so, the oldest member in the cluster will start the join process.

In the join process, the oldest member will:

send the new member list to all members

tell members to sync data in order to balance the data load

Every member in the cluster has the same member list in the same order. First member is the oldest member so if the oldest member dies, second member in the list becomes the first member in the list and the new oldest member.

从这点可以看出,虽然Hazelcast没有所谓的“Master”,但是仍然有一个Leader节点(the oldest member),这个概念与ZooKeeper中的Leader类似,但是实现原理却完全不同。同时,Hazelcast中的数据是分布式的,每一个member持有部分数据和相应的backup数据,这点也与ZooKeeper不同。

虽然Hazelcast应用便捷,但是要将其实际应用于生产环境,还是具有一定的风险的,这个需要大量的实际应用来验证。

更多关于ZooKeeper的文章请参考:http://www.cnblogs.com/gpcuster/tag/ZooKeeper/

【上篇】
【下篇】

抱歉!评论已关闭.