定制jboss ha-rmi,升级到集群环境


前两天贴了个帖子问如何遍历stateful bean,而且是在集群环境中,好多朋友热情相助,但是都不符合应用环境。

以前我的系统使基于rmi的分布式系统,有一个jvm范围内的全局cache,现在想提高系统可靠性,想转向j2ee平台,但是好像j2ee规范在ejb层没有这个对应的全局cache功能,(只有http层的session对应),但我又不想http破坏我的性能。所以只有放弃j2ee平台。

我查了jboss文档,和源码,利用jboss的集群和ha-rmi,终于让以前的旧系统能无缝升级到集群环境。

现在所有的rmi调用可以分布到多台机器。但还有个问题,如果把调用同时分布到多台机器,每个机器中的jvm 内的cache会不一致。我自己写了一个load balance policy,使得所有的rmi调用都发送到master,只有当master down掉,调用才会转到slave。这样就可以绕开cache不一致这个问题。

现在只是demo版本通过了,经过严格测试后会给出源码。

在此一并对各位的帮助感谢,尤其是banq,呵呵。

环境
p4,512M
win2000 pro
jboss-3.2.1_tomcat-4.1.24

我有点疑问,你使用了一个总的Master,相当于全局Singleton,不是还存在单点风险吗?

但是master down 掉后,slave可以马上起来,

我这个方案不是热备份,所有状态是丢失了,但是用户基本上感觉不到。

如果要热备份,就要涉及到状态复制,状态同步,cache invalidation等东东,这些俺还没来的及看,呵呵。

而且可以自定义集群拓扑变化监听器,当某个机器死掉,可以通知相关的管理员,处理机器,jboss 果然 很cool吧

如果用weblogic,虽然有现成的clustered rmi object 可用,但是要想自定义load balance policy,自定义报警机制,恐怕没那么方便。

Are you building a generic caching mechanism? If that the case, then a dedicate cache( with fail-over capability) is not a complete solution. There have enough talks about external cache vs. in process cache on the web, in my experience, people use cache primarily for data from backend DB, but with less tuned configuration, it normally takes < 10 ms to get data directly from DBMS, with highly optimized network and DB cache, it even much better! The only way you can be faster is using in memory cache and maintain a replicated cache map and cache synchronization. Check out JCache stuffs...

I am not saying dedicate service is bad idea, it can be very useful in many situations, it also offer many advantages over in process ones. Caching service can be one usage of it, but in real life external cache need mixed with duplciated cache.

Cheers,

-Jevang

Jboss has very cool distribution management, but in the defense of Weblogic, I will say that archiving what you want in WLS is not that hard. Thought WLS provides no out of box cluster service in a master-slave mode, thought its weighted based load balance can't be applied to RMI, you still can easily plug-in your own Callrouter class, it will provides a list of servers to be used for a particular call, the server in the front of list will always be used unless it's not available.


Cheers,
-Jevang