Cassandra互斥锁定(同步)
是否有使用 cassandra 内置函数同步客户端的方法?
我需要执行一些操作,并且这些操作需要与所有其他客户端同步(互斥)。
在 RDBMS 中,我可以锁定整个表或准备特殊表以用于同步目的,并对其使用 SELECT ... FOR UPDATE。
我可以在不使用任何第三方应用程序的情况下使用 Cassandra 实现此目的吗?如果不是,最好的方法是什么?优选的语言是 Java 和 Python。
Is there anyway to synchronise client using cassandra built in functions?
I need to perform some operations and those operations need to be synchronized with all other clients (mutual exclusion).
In RDBMS I can lock entire table or prepare special table for synchronization purposes and use SELECT ... FOR UPDATE on it.
Can I achive this with Cassandra without any third party apps? If not what's the best way to do that? Preferable languages are Java and Python.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果没有像 Apache ZooKeeper。
在开始推出我自己的分布式锁定机制之前,我可能会开始查看 Domic Williams cages
Its not possible to lock an entire (or a subset of a) column familiy without third party libraries like Apache ZooKeeper.
I would probably start looking at Domic Williams cages before start rolling my own distributed locking mechanism
如果要更新列族中的一行,则它是原子的。但它不会像选择更新那样工作。您可能应该重新审视您的数据模型,并考虑更多的非规范化,这样您就不需要担心同步问题。
If you are updating one row in a column family, it is atomic. But it won't work like select for update. You should probably revisit your data model with more denormalization in mind, so that you won't need to worry about synchronization.
因为 C* 提供行级原子性,所以为什么不使用 Lamport 的烘焙算法。我也在 C* wiki 上发现了一个不完整的页面。
https://github.com/jakedouglas/cassandra_lock
Because C* provides row level atomicity why not use Lamport's Bakery Algorithm. I found an incomplete page on C* wiki too.
https://github.com/jakedouglas/cassandra_lock
我也在寻找与 cassandra 同步的方法,但据我所知,它没有提供实现互斥体的机制。
然而,memcached具有原子cas(检查和设置)操作,可以用来实现互斥。它还具有 python 和 java 客户端。
因此,您可以使用 memcached 实现互斥体以进行同步,并在 cassandra 中以仲裁一致性级别读取/写入数据,以确保在读取时始终返回最新的写入。
有没有人有使用 memcached 实现互斥锁的经验?
I was also looking way to make syncronization with cassandra, but as far as I know it does not provide mechanisms to implement mutexes.
However, memcached has atomic cas (check and set) operation, which can be used to implement mutex. It has also python and java clients.
So you could use memcached to implement mutexes for syncronization and does read/write data with quorum consistency level in cassandra to make sure that latest write is always returned on when reading.
Has anyone experience about implementing mutex with memcached?