使用 JPA 进行哈希分区/分片的库

发布于 2024-11-14 07:14:05 字数 598 浏览 5 评论 0原文

我的部门已决定对我们的一些大型 Oracle 数据库进行哈希分区/分片。我们将把我们的实体分割到不同的模式中。我的任务是进行一次峰值评估,以评估不同 JPA 实现对此的适用性。

我告诉您要重点关注的两个是 EclipseLink 和 Apache OpenJPA/Slice。我们过去专门使用 Hibernate,但 Hibernate Shards 处于测试阶段,并且似乎没有不再积极开发(最后一次发布是在 2007 年),所以我们不考虑它。

我将进行自己的评估和试验实施,但我不相信在给我的时间内我会对这些实施的整体质量有良好的感觉。如果您在生产环境中使用 OpenJPA 和/或 EclipseLink,特别是如果您的数据库是共享的,我想听听您的经验(正面和负面)、您对它们整体质量的看法,以及您是否也会这样做如果有机会再次选择。

My department has decided move to hash partitioning/sharding for some of our large Oracle databases. We will be splitting our entities across different schemas. I've been tasked to do a spike to evaluate the suitability of different JPA implementations for this.

The two that I've told to focus on are EclipseLink and Apache OpenJPA/Slice. We have exclusively used Hibernate in the past, but Hibernate Shards is in beta, and appears no longer be actively developed (last release was in 2007), so we are not considering it.

I will be doing my own evaluation and trial implementations, but I don't trust that I will get a good feel for the overall quality of these implementations in the time that I've been given. If you are using OpenJPA and/or EclipseLink in a production environment, especially if your database is shareded, I would like to hear about your experiences (positive and negative), your opinions about their overall quality, and if you'd make the same choice again if given the opportunity.

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

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

发布评论

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

评论(3

一曲琵琶半遮面シ 2024-11-21 07:14:05

OpenJPA Slice 可能是分片数据库环境中 JPA 应用程序的一种选择。

OpenJPA Slice 从 1.2 版本开始可用,并且还随 Websphere 7.0 及更高版本一起提供。 Slice 的基本使用契约是保留完全相同的基于 JPA 的应用程序代码,以便与水平分区的数据库分片一起使用,而不以任何方式影响数据库架构。数据库分片可能来自不同的供应商。

切片遵循基于策略的设计,允许用户应用程序控制哪个分片/切片将持久保存新实例、如何针对切片子集进行查询等。

基本限制(在任何分片环境中都很常见)是持久域模型应遵循树约束模式。本质上,给定一个存储在分片 A 中的实例 x,x 的持久闭包(即可从 x 直接或间接访问的实例集)也必须存储在同一个分片 A 中。当您持久化 x 时,Slice 会自动计算闭包。

如果应用程序可以承受这样的约束,那么 Slice 可能是一个不错的选择。

有时,某些实例可能会在闭包之间共享,例如国家代码或货币代码。 Slice 确实提供了跨多个分片复制此类“主数据”实例的功能。

支持与分片交换的聚合运算(MAX、MIN、SUM)。不支持非阿贝尔聚合,例如 AVG。还支持排序或 Top-N 查询。

有关 Slice 的更多信息,请参阅以下参考文献

[1] OpenJPA 用户手册: http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_slice

[2] IBM Developerworks 文章:http://www.ibm.com/developerworks/java/library /os-openjpa/?ca=drs-

OpenJPA Slice could be one option for JPA applications in a sharded database environment.

OpenJPA Slice is available since version 1.2 and also ships with Websphere 7.0 and later. The basic usage contract of Slice is to retain the exact same JPA based application code to work with horizontally partitioned database shards without affecting the database schema in any way. The database shards could be from different vendors.

Slice follows a policy based design that allows the user application to control which shard/slice will persist new instances, how queries would be targeted for subset of slices etc.

The basic limitation (which is typical in any sharded environment) is that the persistent domain model should adhere to a tree-constrained schema. Essentially, given an instance x stored in shard A, the persistent closure of x i.e. the set of instances directly or indirectly reachable from x, must also be stored in the same shard A. Slice computes the closure automatically when you persist x.

If an application can live with such a constraint, Slice could be a good fit.

At times, certain instances may be shared across closures e.g. Country Code or Currency Code. Slice does have a provision for replicating such 'master data'-like instances across multiple shards.

The aggregate operations (MAX, MIN, SUM) that are abelian/commutative to sharding are supported. Non-abelian aggregate such as AVG is not supported. Sorted or Top-N queries are supported as well.

More information about Slice can be found at the following references

[1] OpenJPA User Manual: http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_slice

[2] IBM Developerworks article: http://www.ibm.com/developerworks/java/library/os-openjpa/?ca=drs-

昇り龍 2024-11-21 07:14:05

EclipseLink 的数据分区支持作为 2.2 版本中基本产品的一部分发布。

它支持哈希分区和其他几种类型的分区(值、范围)以及用户定义的策略。 2.3 版本还包括对 Oracle RAC、UCP 和 WebLogic GridLink 的集成支持。

看,
http://java-persistence-performance.blogspot .com/2011/05/data-partitioning-scaling-database.html

EclipseLink's data partitioning support was released as part of the base product in the 2.2 release.

It supports Hash partitioning, and several other types of partitioning (value, range) as well as user defined policies. The 2.3 release also includes integrated support for Oracle RAC, UCP and WebLogic GridLink.

See,
http://java-persistence-performance.blogspot.com/2011/05/data-partitioning-scaling-database.html

暮色兮凉城 2024-11-21 07:14:05

如果您愿意,可以使用外部工具,这不仅可以向应用程序开发人员隐藏分片逻辑,还可以向 BI 用户、DBA 等隐藏分片逻辑。
查看 ScaleBase

If you'd like you can use external tools, that not only hide the sharding logic from the application developers, but also from BI users, DBAs, etc.
Check out ScaleBase

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