CoprocessoraccesstoHBaseinternals
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CoprocessoraccesstoHBaseinternals,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3057字,纯文字阅读大概需要5分钟。
内容图文
![CoprocessoraccesstoHBaseinternals](/upload/InfoBanner/zyjiaocheng/558/60fbd75cdd3c4592a6ff952389feb09c.jpg)
By Lars Hofhansl Most folks familiar with HBase have heard of coprocessors. Coprocessors come in two flavors: Observers and Endpoints. An Observer is similar to a database trigger, an Endpoint can be likened to a stored procedure. This ana
By Lars HofhanslMost folks familiar with HBase have heard of coprocessors.
Coprocessors come in two flavors: Observers and Endpoints.
An Observer is similar to a database trigger, an Endpoint can be likened to a stored procedure.
This analogy only goes that far, though.
While triggers and stored procedures are (typically) sandboxed and expressed in a highlevel language (typically SQL with procedural extensions), coprocessors are written in Java and are designed to extend HBase directly (in the sense of avoiding subclassing the HRegionServer class in order to extend it). Code in a coprocessor will happily shutdown a region server by calling System.exit(...)!
On the other hand coprocessors are strangely limited. Before HBASE-6522 they had no access to a RegionServer's locks and leases and hence it was impossible to implement check-and-set type as a coprocessor (because the row modified would need to be locked), or to time out expensive server side data structures (via leases).
HBASE-6522 makes some trivial changes to remedy that.
It was also hard to maintain any kind of share state in coprocessors.
Keep in mind that region coprocessors are loaded per region and there might be 100's of regions for a given region server.
Static members won't work reliably, because coprocessor classes are loaded by special classloaders.
HBASE-6505 fixes that too. Now the RegionCoprocessorEnvironment provides a getSharedData() method, which returns a ConcurrentMap, which is held by the coprocessor environment as a weak reference (in a special map with strongly referenced keys and weakly referenced values), and held strongly by the environment that manages each coprocessor.
That way if the coprocessor is blacklisted (due to throwing an unexpected exception) the coprocessors environment is removed, and any shared data is immediately available for garbage collection, thus avoiding ugly and error prone reference counting (maybe this warrants a separate post).
This shared data is per coprocessor class and per regionserver. As long as there is at least one region observer or endpoint active this shared data is not garbage collected and can be accessed to share state between the remaining coprocessors of the same class.
These changes allow coprocessor to be used for a variety of use cases.
State can be shared across them, allowing coordination between many regions, for example for coordinated queries.
Row locks can be created and released - allowing for check-and-set type operations.
And leases can be used to safely expire expensive data structures or to time out locks among other uses.
Update:
I should also mention that RegionObservers already have access to a region's MVCC.
原文地址:Coprocessor access to HBase internals, 感谢原作者分享。
内容总结
以上是互联网集市为您收集整理的CoprocessoraccesstoHBaseinternals全部内容,希望文章能够帮你解决CoprocessoraccesstoHBaseinternals所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。