论坛首页 Java企业应用论坛

OSCache 集群中数据同步问题

浏览 8747 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2008-05-23  
最近使用oscach集群中,有些问题不甚了解,请各位提些建议。
现有的配置:
oscache.properties 中使用默认jgroup配置

cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener

cache.cluster.properties=UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\
mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\
PING(timeout=2000;num_initial_members=3):\
MERGE2(min_interval=5000;max_interval=10000):\
FD_SOCK:VERIFY_SUSPECT(timeout=1500):\
pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\
UNICAST(timeout=300,600,1200,2400):\
pbcast.STABLE(desired_avg_gossip=20000):\
FRAG(frag_size=8096;down_thread=false;up_thread=false):\
pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true)

cache.cluster.multicast.ip=231.12.21.132

在启动两个测试节点后发现集群正常建立

-------------------------------------------------------
GMS: address is 172.16.3.98:3828
-------------------------------------------------------
2008-05-23 11:54:17 3344 INFO  com.opensymphony.oscache.plugins.clustersupport.J
avaGroupsBroadcastingListener     - JavaGroups clustering support started succes
sfully
2008-05-23 11:54:20 6532 INFO  com.opensymphony.oscache.plugins.clustersupport.
JavaGroupsBroadcastingListener     - A new member at address '172.16.3.98:3831'
has joined the cluster

然后在使用过程中发现,一个节点 Cache.putInCache(key,content) 加入缓存后,
在另一个节点并没有受到任何数据同步信息。但是一个节点 Cache.flushEntry(key) 后,
在另一个节点产生集群通知信息。

2008-05-23 11:54:42 28594 INFO  com.opensymphony.oscache.plugins.clustersupport
.AbstractBroadcastingListener     - Cluster notification (type=1, data=global_te
st) was received.

于是简单翻看了osccache 的Cache 和JavaGroupsBroadcastingListener源码发现;
在Cache的事件处理中,JavaGroupsBroadcastingListener 只是提供了 cacheflushXXX 相关的信息通知,
cacheEntryAdded,cacheEntryRemoved,cacheEntryUpdated都未做处理。

源码实现在 AbstractBroadcastingListener:
  public void cacheFlushed(CachewideEvent event) {
        if (!Cache.NESTED_EVENT.equals(event.getOrigin()) && !CLUSTER_ORIGIN.equals(event.getOrigin())) {
            if (log.isDebugEnabled()) {
                log.debug("cacheFushed called (" + event + ")");
            }
   
    //此处发送通知
            sendNotification(new ClusterNotification(ClusterNotification.FLUSH_CACHE, event.getDate()));
        }
    }

    // --------------------------------------------------------
    // The remaining events are of no interest to this listener
    // --------------------------------------------------------
    public void cacheEntryAdded(CacheEntryEvent event) {
    }

    public void cacheEntryRemoved(CacheEntryEvent event) {
    }

    public void cacheEntryUpdated(CacheEntryEvent event) {
    }

    有此,产生了疑问,Oscache支持集群,那么他的数据同步机制在哪里?难道节点间数据同步需要自己来实现?
     如果要自己实现的话,仅仅支持flush 通知这样的集群还有意义吗?

     查看了oscache cluster的文档也没发现这方面的信息,请使用过oscache集群的高手们指教。

   发表时间:2008-05-23  
个人认为,oscache的源代码要经过修改和扩充才能正确处理clustering的需求。但不知道为什么作者多年来都不修改,也不知道社区里怎么没有人反映。当大家都不吱声的时候,就好象没有这回事一样。不过,在俺的项目里,俺都是要修改的。
0 请登录后投票
   发表时间:2008-05-27  
最近我也碰到这个问题,不知道有人解决了吗?
0 请登录后投票
   发表时间:2008-05-27  
Oscache是特意采用这种机制的,oscache属于分布式cache ,而不是集群式。
Oscache这种方式的好处是,cache占用的内存少,
通过广播缓存的更新消息,既保障了缓存的有效性,
又避免了缓存数据同步的消耗。
jbosscache就是使用了同步缓存数据的方式,
在缓存内容更新较频繁的情况下,效率极其低。
而oscache就不存在这样的问题。


1 请登录后投票
   发表时间:2008-09-18  
codeutil 写道
Oscache是特意采用这种机制的,oscache属于分布式cache ,而不是集群式。
Oscache这种方式的好处是,cache占用的内存少,
通过广播缓存的更新消息,既保障了缓存的有效性,
又避免了缓存数据同步的消耗。
jbosscache就是使用了同步缓存数据的方式,
在缓存内容更新较频繁的情况下,效率极其低。
而oscache就不存在这样的问题。




那么如何处理更新的数据?意思就是说更新的数据就忽略掉了麽?那节点之间怎么可能还同步啊?
1 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics