Apache Cassandra 的高级 Java 客户端选择

发布于 2024-10-20 14:27:39 字数 1539 浏览 4 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

半步萧音过轻尘 2024-10-27 14:27:39

我尝试了大部分解决方案,发现 hector 是最好的。即使您遇到一些问题,您也可以随时联系在 freenode 中的 #cassandra 中编写 hector 的人。而且就我而言,代码更加成熟。在 cassandra 客户端中,最关键的部分是连接池管理(因为所有客户端通过 thrift 执行大部分相同的操作,但连接池是使高级客户端滚动的原因)。在这种情况下,我会投票给赫克托,因为我在生产中使用它已经一年多了,没有任何明显的问题(当我发现并发送有关它的电子邮件后,就修复了 1 个重新连接问题)。

不过我仍在使用 cassandra 0.6。

I tried most of these solutions and find hector the best. Even when you have some problem you can always reach people who wrote hector in #cassandra in freenode. and the code is more mature as far as I concern. In cassandra client the most critical part would be connection pooling management (since all the clients do mostly the same operations through thrift, but connection pooling is what makes high level client roll). In that case I would vote for hector since I am using it in production for over a year now with no visible problem (1 reconnect issue fixed as soon as I discovered and send an email about it).

I am still using cassandra 0.6 though.

烟雨扶苏 2024-10-27 14:27:39

datanucleus 插件的作者 Todd Nine 现在正在 Hector 中致力于下一代 JPA 支持。

The author of the datanucleus plugin, Todd Nine, is working on the next-gen JPA support in Hector now.

苏别ゝ 2024-10-27 14:27:39

Hector 客户端是我们选择的 API,因为它具有以下功能:

  • 连接池(共享到节点的连接时可以获得巨大的性能增益)
  • 使用几乎所有内容的接口完成自定义配置。
  • 自动发现托管
  • 自定义负载平衡策略定义(LeastActiveBalancingPolicy 或 RoundRobinBalancingPolicy 或实现 LoadBalancingPolicy)
  • Thrift API 之上的轻量级适配器。
  • 很好的例子:请参阅 hector-examples
  • 内置 JMX 支持。

Hector 的缺点:

  • 文档还不错,但 Java 文档有点缺乏。这很可能是用户社区的 Git fork/pull 请求。
  • ORM 支持有点有限,但在我们的案例中使用并不紧急。我无法让一些一对多关联轻松工作,而且缺乏描述 Cassandra 模型的类型(关联集合的超级列或列族)。还缺少 Java 示例(也许有一些,如果找到的话请发帖)。

另外,我尝试使用昆德拉,但收效甚微。使用或尝试的例子不多,论坛支持也很少。它似乎是由一个人维护的,这使得选择这样的工具变得更加困难。它的出现是基于它正在迁移到的 SVN 活动,而是使用 Hadoop 或对其的支持。

The Hector client was the API that we choose because of the following things that it had:

  • Connection Pooling (huge performance gain when sharing a connection to a node)
  • Complete Custom Configuration using interfaces for most everything.
  • Auto Discovery Hosts
  • Custom Load Balancing Policy definitions (LeastActiveBalancingPolicy or RoundRobinBalancingPolicy or implement LoadBalancingPolicy)
  • Light-weight adapter on top of the Thrift API.
  • Great examples: See hector-examples
  • Built in JMX support.

Downside of Hector:

  • Documentation not bad, but the Java Docs are lacking a bit. That could easily be a Git fork / pull request by the user community.
  • The ORM support was a bit limited, but not urgent for usage in our case. I couldn't get some of the one-to-many associations to work easily, plus lack of describing what type of Cassandra model (super columns or column families for associated collections). Also a lack of Java examples (maybe there are some, please post if you find some).

Also, I tried using kundera with very little success. Not many examples to use or try, very little forum support. It appears to be maintained by one person, which makes it even hard to choose a tool like that. It appears based on the SVN activity it was migrating to using Hadoop instead or support for it as well.

纸伞微斜 2024-10-27 14:27:39

昆德拉2.0.4发布。

此版本中的主要变化:

  • 跨数据存储持久性(通过 nosql 轻松迁移现有 mysql 应用程序)
  • 对关系数据库(例如 Mysql 等)的支持,
  • 用基于 lucene 的索引替换 solandra。
  • 添加了对双向关联的支持。
  • 性能改进修复。

Kundera 2.0.4 released.

Major Changes in this release:

  • Cross-datastore persistence( Easy to migerate existing mysql app over nosql)
  • support for relational databases (e.g Mysql etc)
  • replace solandra with lucene based indexing.
  • Support added for bi-directinal associations.
  • Performance improvement fixes.
朦胧时间 2024-10-27 14:27:39

我也建议使用 Astyanax,我正在使用它并且我很高兴。只是文档不太好。

Astyanax API

Astyanax 实现了一个流畅的 API,可以引导调用者缩小或缩小范围
通过一组定义良好的接口自定义查询。我们还曾
包括一些将有效且尽可能接近地执行的食谱
尽可能到低级别的 RPC 层。客户端也重磅
使用泛型和重载几乎消除了需要
指定序列化器。
API 的一些主要功能包括:

  • 键和列类型在 ColumnFamily 类中定义,该类
    无需指定序列化器。
  • 同一键空间中的多个列族键类型。基于注释的复合列名称。
  • 自动分页。
  • 可识别令牌的并行查询。
  • 每个操作的可配置一致性级别。
  • 每个操作的可配置重试策略。
  • 将操作固定到特定节点。
  • 使用 Future 进行具有单个超时的异步操作。
  • 基于简单注释的对象映射。
  • 操作结果返回主机、延迟、尝试次数。
  • Tracer 接口用于记录操作失败和成功的自定义事件。
  • 优化批量突变。
  • 完全隐藏调用者的时钟,但提供挂钩来自定义它。
  • 简单的 CQL 支持。
  • RangeBuilders 可简化简单和复合列范围的构建。
  • 复合构建器可简化复合列名称的创建。

一些常见用例的食谱:

  • CSV 导入器。
  • JSON 导出器,可将任何查询结果转换为具有广泛范围的 JSON
    定制。
  • 并行反向索引搜索。
  • 关键唯一约束验证。

http://techblog.netflix.com/2012/01/announcing-astyanax.html

I would propose also Astyanax, I'm working with it and I'm quite happy. Only the documentation is not really good.

Astyanax API

Astyanax implements a fluent API which guides the caller to narrow or
customize the query via a set of well defined interfaces. We've also
included some recipes that will be executed efficiently and as close
to the low level RPC layer as possible. The client also makes heavy
use of generics and overloading to almost eliminate the need to
specify serializers.
Some key features of the API include:

  • Key and column types are defined in a ColumnFamily class which
    eliminates the need to specify serializers.
  • Multiple column family key types in the same keyspace. Annotation based composite column names.
  • Automatic pagination.
  • Parallelized queries that are token aware.
  • Configurable consistency level per operation.
  • Configurable retry policy per operation.
  • Pin operations to specific node.
  • Async operations with a single timeout using Futures.
  • Simple annotation based object mapping.
  • Operation result returns host, latency, attempt count.
  • Tracer interfaces to log custom events for operation failure and success.
  • Optimized batch mutation.
  • Completely hide the clock for the caller, but provide hooks to customize it.
  • Simple CQL support.
  • RangeBuilders to simplify constructing simple as well as composite column ranges.
  • Composite builders to simplify creating composite column names.

Recipes Recipes for some common use cases:

  • CSV importer.
  • JSON exporter to convert any query result to JSON with a wide range of
    customizations.
  • Parallel reverse index search.
  • Key unique constraint validation.

http://techblog.netflix.com/2012/01/announcing-astyanax.html

臻嫒无言 2024-10-27 14:27:39

我建议你尝试一下 Kundera-2.0.1。自推出以来,它发生了重大变化,我看到添加了许多新功能并修复了错误。目前它支持 JPA 1.0 和 Cassandra 0.7.6,但他们计划很快添加对 Cassandra 0.8 和 JPA 2.0 的支持。这里有一个很好的例子: https://github .com/impetus-opensource/Kundera/wiki/5 分钟入门

I suggest you give Kundera-2.0.1 a try. It has gone a major change since its inception and I see a lot of new features getting added and bugs being fixed. Currently it supports JPA 1.0 and Cassandra 0.7.6 but they are planning to add support for Cassandra 0.8 and JPA 2.0 very soon. There is a pretty good example here: https://github.com/impetus-opensource/Kundera/wiki/Getting-Started-in-5-minutes

极致的悲 2024-10-27 14:27:39

您可以尝试 Achilles,这是我开发的一个新实体管理器,支持所有 CQL3 功能。

  • 实体映射
  • JPA 风格操作
  • 对连接的有限支持
  • 使用复合主键映射集群实体 查询
  • (本机、类型、切片)
  • 支持计数器
  • 支持一致性级别
  • TTL 和一致性级别时间戳
  • 启动嵌入式 Cassandra 服务器进行测试的 JUnit 4 规则

    还有更多...

    有 2 种实现:ThriftThrift CQL

    Thrift 版本在底层依赖于 Hector

    CQL 版本从 Datastax 中提取全新的 Java Driver Core 用于所有操作

    快速参考此处

You can try Achilles, a new Entity Manager I've developed that supports all CQL3 features.

  • Entity mapping
  • JPA style operations
  • Limited support for join
  • Mapping of clustered entities using compound primary key
  • Queries (native, typed, slice)
  • Support for counters
  • Support for Consistency level
  • TTL & timestamp
  • JUnit 4 Rule to start embedded Cassandra server for testing

    And so more ...

    There are 2 implementations: Thrift & CQL

    The Thrift version relies on Hector under the hood.

    The CQL version pulls the brand new Java Driver Core from Datastax for all operations

    Quick reference here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文