本文介绍了分布式锁服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您将使用哪种分布式锁服务?

Which distributed lock service would you use?

要求是:


  1. 可以从不同进程/机器看到的互斥(锁定)

  2. 锁定...释放语义

  3. 自动锁定释放后超时 - 如果锁定持有者死亡,它将在X秒后自动释放

  4. Java实现

  5. 很高兴:.Net实现

  6. 如果它是免费的:死锁检测/缓解

  7. 轻松部署,请参阅下面的注释。

  1. A mutual exclusion (lock) that can be seen from different processes/machines
  2. lock...release semantics
  3. Automatic lock release after a certain timeout - if lock holder dies, it will automatically be freed after X seconds
  4. Java implementation
  5. Nice to have: .Net implementation
  6. If it's free: Deadlock detection / mitigation
  7. Easy deployment, see note below.

我对它可以在数据库上完成或它可以在JavaSpaces上完成等答案不感兴趣 - 我知道。我对一个现成的,开箱即用的,经过验证的实现感兴趣。

I'm not interested in answers like "it can be done over a database", or "it can be done over JavaSpaces" - I know. I'm interested in a ready, out-of-the-box, proven implementation.

推荐答案

,包括开源版,通过使用 synchronized 或 java.util.concurrent.ReentrantReadWriteLock - 后者显然符合您的要求。

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.

更新

由于问题现在增加了与GigaSpaces'混合'的要求,我我会说混合它们。这只会增加你的技术堆栈的复杂性,以及:

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:


  • 在代码和基础设施方面的集成;

  • 管理它们之间的同步;

  • 学习/调整/调试Teracotta。

最好花在创建或实现基于GigaSpaces的锁定解决方案上。

will be better spent creating or implementing a locking solution based on GigaSpaces.

这篇关于分布式锁服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 01:31