前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >HBase的FlushLargeStoresPolicy多例族支持

HBase的FlushLargeStoresPolicy多例族支持

作者头像
一见
发布2018-08-06 19:20:36
4710
发布2018-08-06 19:20:36
举报
文章被收录于专栏:蓝天蓝天蓝天

众所周知,HBase的一个例族flush时,会导致所有例族都跟着被flush。在HBase-0.94的官方说明(http://hbase.apache.org/0.94/book/number.of.cfs.html)也明确HBase不能很好的支持一个以上的例族。

HBase-2.0.0和HBase-1.1.0(https://issues.apache.org/jira/browse/HBASE-10201)引入FlushLargeStoresPolicy来解决这个问题。

FlushLargeStoresPolicy的实现非常简单,就是在flush之前先判断下Store的大小,当超过指定大小时才flush(注:实际上不仅仅受此决定,具体可查看HRegion类的shouldFlushStore()的实现)。

相关的类(之前只有FlushAllStoresPolicy一种flush策略,也就是flush一个例族时也会flush其它所有例族):

flush过程:

相关源代码:

public abstract class FlushPolicy {
protected HRegion region;
protected void configureForRegion(HRegion region) {
this.region = region;
}
public abstract Collection selectStoresToFlush();
}
public class FlushLargeStoresPolicy extends FlushPolicy {
private boolean shouldFlush(Store store) {
if (store.getMemStoreSize() > this.flushSizeLowerBound) {
return true;
}
// 请注意下面这句
return region.shouldFlushStore(store);
}
public Collection selectStoresToFlush() {
Collection stores = region.stores.values();
Set specificStoresToFlush = new HashSet();
for (Store store : stores) {
if (shouldFlush(store)) {
specificStoresToFlush.add(store);
}
}
return specificStoresToFlush;
}
}
public class FlushAllStoresPolicy extends FlushPolicy {
public Collection selectStoresToFlush() {
return region.stores.values();
}
}
public class HRegion {
boolean shouldFlushStore(Store store) {
if ((maxFlushedSeqId > 0)
&& (maxFlushedSeqId + flushPerChanges < sequenceId.get())) {
return true;
}
if (flushCheckInterval <= 0) {
return false;
}
long now = EnvironmentEdgeManager.currentTime();
if (store.timeOfOldestEdit() < now - flushCheckInterval) {
return true;
}
return false;
}
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015-11-18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档