具有大量实体的Ehcache / Hibernate和RMI复制 [英] Ehcache / Hibernate and RMI replication with large number of entities

查看:135
本文介绍了具有大量实体的Ehcache / Hibernate和RMI复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究如何在ehcache中使用RMI分发选项。我配置正确ehcache.xml和复制似乎工作正常。不过,我有两个问题:

- >看来ehcache / hibernate会为每个实体创建一个缓存。这很好,但是当复制到位时,它会创建1个线程/缓存进行复制。这是预期的行为?由于我们的域名很大,所以它创建了大约300个线程,这在我看来真的很大

- >另一个令人讨厌的结果是,心跳messagre似乎将所有这些缓存名。从我看到的消息应该适合1500字节,它不会导致这条消息在我的日志中:心跳不起作用。配置较少的高速缓存进行复制。大小是1747,但不应该大于1500。任何想法如何可以改变?



非常感谢您的帮助

解决方案

我们有我们自己的自定义副本的hibernate EhCacheProvider,它覆盖了buildCache()以创建我们自己的带有缩短名称(名称散列)的Cache对象。这得到了1500的限制。我们使用反向查找的散列名保留原始名称的散列映射。



我们之前做过这样的工作,并且一直在使用它。



我们还查看了您的其他问题以获得单个复制器线程。首先,我们复制了RMICacheReplicatorFactory并更改了createCacheEventListener()以返回我们修改的RMIAsynchronousCacheReplicator的副本,方法是将replicationThread字段设置为static,然后为此创建必要的修补程序。我们没有彻底地测试它或将其投入生产,但是再次看到它是我找到这篇文章的原因:)

I'm currently investigating how to use the RMI distribution option in ehcache. I've configured properly ehcache.xml and replication seems to work fine. However I've 2 questions:

-> It seems ehcache/ hibernate creates 1 cache per Entity. This is fine, however when replication is in place it create 1 thread / cache to replicate. Is this the intended behavious ? As our domain is big, it creates about 300 threads, which seems to me really big

-> Another nasty consequence is that the heartbeat messagre seems to aggregate all of those cache names. From what I saw the message should fit in 1500 bytes, which it does not, which leads to this message in my logs: Heartbeat is not working. Configure fewer caches for replication. Size is 1747 but should be no greater than1500. Any idea on how this could be changed ?

Thanks a lot for your help

解决方案

We already have one hack where we have our own custom copy of the hibernate EhCacheProvider that overrides buildCache() to create our own Cache objects with shortened names (the hash of the name). This gets around the 1500 limit. We keep a hashmap of the original names with the hash names for reverse lookup.

We did this a while ago and have been using it in production.

We also looked at your other issue to have a single replicator thread. First we copied RMICacheReplicatorFactory and changed createCacheEventListener() to return our copy of RMIAsynchronousCacheReplicator that we modified by making the replicationThread field static and then making the necassary fixes for that. We didn't get around to testing it thoroughly or putting it in production, but are looking at it again which is how I found this post :)

这篇关于具有大量实体的Ehcache / Hibernate和RMI复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆