A newer kid on the block is hazelcast. I've been playing with it and it is amazingly simple to use and configure.
As far as I can see there shouldn't be any conflict between Gigaspaces and hazelcast as hazelcast doesn't have any dependencies i.e. no jgroups.jar etc
Hazelcast:
A mutual exclusion (lock), yep implementation of java.util.concurrency.locks.Lock
Automatic lock release after a certain timeout, yep all locks are released if a member leaves the cluster
Java implementation, yep
Nice to have: .Net implementation, nope is a pure java solution, might be possible to port to j#
If it's free: Deadlock detection / mitigation, nope no effort is made my Hazelcast to handle this
Easy deployment, it's a single jar with a single config file, deployed as part of your application, no additional processes are required
Check out Apache's Zookeeper (A Hadoop sub-project) - it offers distributed synchronization. The documentation isn't great, but what there is makes it look an interesting product - checkout the recipes for ideas on how to use Zookeeper.
It is lower-level than you'd probably want and it does require additional deployment as it recommends dedicated servers.
You can model different locking strategies and it does offer a solution for a lock holder dying (ephemeral nodes).
Teracotta, including the Open Source edition, has distributed locking semantics by using either synchronized or the java.util.concurrent.ReentrantReadWriteLock - the latter apparently fitting your requirements.
Update
Since the question now added the requirement of 'mixing' with GigaSpaces, I'm going to say don't mix them. It's just going to add more complexity to your technological stack, and the effort of:
integrating, in terms of both code and infrastructure;
managing synchronisation between them;
learning/tuning/debugging Teracotta.
will be better spent creating or implementing a locking solution based on GigaSpaces.
Redisson redisson = Redisson.create(config);
Lock lock = redisson.getLock("anyLock");
try {
// unlock automatically after 10 seconds of hold
lock.lock(10, TimeUnit.SECONDS);
} finally {
lock.unlock();
}
...
redisson.shutdown();
支持 Azure 和 AWS 等云供应商。
I recommend to use Redisson it's a Redis based on In-Memory Data Grid. It implements familiar Java data structures including distributed java.util.Lock and java.util.concurrent.ReentrantReadWriteLock objects. Including ability to setup leaseTime. Lock usage example:
Redisson redisson = Redisson.create(config);
Lock lock = redisson.getLock("anyLock");
try {
// unlock automatically after 10 seconds of hold
lock.lock(10, TimeUnit.SECONDS);
} finally {
lock.unlock();
}
...
redisson.shutdown();
ZooKeeper became a de facto standard in distributed locking with the help of Apache Curator framework. Check out the locks in recipes for more information.
Oracle Coherence, which is very stable and mature, includes mutual exclusion support:
cache.lock(key, -1);
try {
// .. add your critical code here
} finally {
cache.unlock(key);
}
Locks survive server failures, rolling re-starts, etc.
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.
发布评论
评论(6)
hazelcast 是一个新人。 我一直在使用它,它的使用和配置非常简单。
据我所知,Gigaspaces 和 hazelcast 之间不应该有任何冲突,因为 hazelcast 没有任何依赖项,即没有 jgroups.jar 等
Hazelcast:
java.util.concurrency.locks.Lock
A newer kid on the block is hazelcast. I've been playing with it and it is amazingly simple to use and configure.
As far as I can see there shouldn't be any conflict between Gigaspaces and hazelcast as hazelcast doesn't have any dependencies i.e. no jgroups.jar etc
Hazelcast:
java.util.concurrency.locks.Lock
查看 Apache 的 Zookeeper(Hadoop 子项目) - 它提供分布式同步。 文档不是很好,但是它看起来是一个有趣的产品 - 查看食谱以获取有关如何使用 Zookeeper 的想法。
它的级别比您可能想要的要低,并且确实需要额外的部署,因为它建议使用专用服务器。
您可以对不同的锁定策略进行建模,它确实为锁持有者死亡(临时节点)提供了解决方案。
Check out Apache's Zookeeper (A Hadoop sub-project) - it offers distributed synchronization. The documentation isn't great, but what there is makes it look an interesting product - checkout the recipes for ideas on how to use Zookeeper.
It is lower-level than you'd probably want and it does require additional deployment as it recommends dedicated servers.
You can model different locking strategies and it does offer a solution for a lock holder dying (ephemeral nodes).
Teracotta(包括开源版本)通过使用任一
synchronized
或java.util.concurrent.ReentrantReadWriteLock
- 后者显然符合您的要求。更新
由于问题现在添加了与 GigaSpaces“混合”的要求,我要说不要将它们混合。 它只会增加您的技术堆栈的复杂性,并增加以下工作量:
将更好地用于创建或实施基于 GigaSpaces 的锁定解决方案。
Teracotta, including the Open Source edition, has distributed locking semantics by using either
synchronized
or thejava.util.concurrent.ReentrantReadWriteLock
- the latter apparently fitting your requirements.Update
Since the question now added the requirement of 'mixing' with GigaSpaces, I'm going to say don't mix them. It's just going to add more complexity to your technological stack, and the effort of:
will be better spent creating or implementing a locking solution based on GigaSpaces.
我建议使用 Redisson 它是一个 Redis 基于内存数据网格。 它实现了熟悉的 Java 数据结构,包括分布式 java.util.Lock 和 java.util.concurrent.ReentrantReadWriteLock 对象。 包括设置租用时间的能力。
Lock
使用示例:支持 Azure 和 AWS 等云供应商。
I recommend to use Redisson it's a Redis based on In-Memory Data Grid. It implements familiar Java data structures including distributed
java.util.Lock
andjava.util.concurrent.ReentrantReadWriteLock
objects. Including ability to setup leaseTime.Lock
usage example:Supports cloud vendors like Azure and AWS.
在 ZooKeeper 的帮助下,ZooKeeper 成为分布式锁定的事实上的标准。 apache.org/index.html" rel="nofollow">Apache Curator 框架。 查看 recipes 中的锁以获取更多信息。
ZooKeeper became a de facto standard in distributed locking with the help of Apache Curator framework. Check out the locks in recipes for more information.
Oracle Coherence 非常稳定和成熟,包括互斥支持:
锁可以承受服务器故障、滚动重新启动等。
为了充分披露,我在 Oracle 工作。 这篇文章中表达的意见和观点是我自己的,并不一定反映我的雇主的意见或看法。
Oracle Coherence, which is very stable and mature, includes mutual exclusion support:
Locks survive server failures, rolling re-starts, etc.
For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.