Java Cassandra - 事务支持

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2976932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 15:09:25  来源:igfitidea点击:

Cassandra - transaction support

javadatabasenosqlcassandra

提问by Kumar D

I am going through apache cassandra and working on sample data insertion, retrieving etc.

我正在浏览 apache cassandra 并处理样本数据插入、检索等。

The documentation is very limited.

文档非常有限。

I am interested in knowing

我有兴趣知道

  • can we completely replace relation db like mysql/ oracle with cassandra?
  • does cassandra support rollback/ commit?
  • does cassandra clients (thrift/ hector) support fetching associated object (objects where we save one super columns' key in another super column family)?
  • 我们可以用cassandra完全替换像mysql/oracle这样的关系数据库吗?
  • cassandra 是否支持回滚/提交?
  • cassandra 客户端(thrift/ hector)是否支持获取关联对象(我们将一个超级列的键保存在另一个超级列族中的对象)?

This will help me a lot to proceed further.

这将有助于我继续前进。

thank you in advance.

先感谢您。

采纳答案by Lautis

Short answer: No.

简短的回答:没有。

By design, Cassandra values availability and partition tolerance over consistency1. Basically, it's not possible to get acceptable latency while maintaining all three of qualities: one has to be sacrificed. This is called CAP theorem.

根据设计,Cassandra 重视可用性和分区容错性而不是一致性1。基本上,在保持所有三种品质的同时获得可接受的延迟是不可能的:必须牺牲一种品质。这称为CAP定理。

The amount of consistency is configurable in Cassandra using consistency levels, but there doesn't exist any semantics for rollback. There's no guarantee that you'll be able to roll back your changes even if the first write succeeds.

使用一致性级别在 Cassandra 中可以配置一致性的数量,但不存在任何回滚语义。即使第一次写入成功,也无法保证您能够回滚更改。

If you wan't to build application with transactions or locks on top of Cassandra, you probably want to look at Zookeeper, which can be used to provide distributed synchronization.

如果您不想在 Cassandra 之上构建具有事务或锁的应用程序,您可能需要查看 Zookeeper,它可用于提供分布式同步。

You might've already guessed this, but Cassandra doesn't have foreign keys or anything like that. This has to be handled manually. I'm not that familiar with Hector, but a higher-level client could be able to do this semi-automatically.

您可能已经猜到了,但是 Cassandra 没有外键或类似的东西。这必须手动处理。我对 Hector 不是很熟悉,但是更高级别的客户端可以半自动地做到这一点。

Whether or not you can use Cassandra to easily replace a RDBMS depends on your specific use case. In your use case (based on your questions), it might be hard to do so.

您是否可以使用 Cassandra 轻松替换 RDBMS 取决于您的特定用例。在您的用例中(根据您的问题),可能很难这样做。

回答by Mattias

If Zookeeper is able to handle transactions that has Oracle-quality then its a done deal. Relations and relation integrity is no problem to implement on top of ANY database. A foreign key is just another data-field. ACID/Transactions is the key issue.

如果 Zookeeper 能够处理具有 Oracle 质量的事务,那么它就完成了。关系和关系完整性在任何数据库之上实施都没有问题。外键只是另一个数据字段。ACID/事务是关键问题。

回答by sedovav

In version 2.x you can combine CQL-statements in logged batchthat is atomic. Either all or none of statements succeed. Also you can read about lightweight transactions. More than that - there are several persistence managers for Cassandra. You can achive foreign keys behavior on client level with them. For example, Achillesand Kundera.

在版本 2.x 中,您可以在原子记录的批处理中组合 CQL 语句。要么所有语句都成功,要么都不成功。您还可以阅读有关轻量级事务的信息。不仅如此 - Cassandra 有几个持久性管理器。您可以使用它们在客户端级别实现外键行为。例如,阿喀琉斯昆德拉