Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8049839
  • 博文数量: 594
  • 博客积分: 13065
  • 博客等级: 上将
  • 技术积分: 10324
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-26 16:44
个人简介

推荐: blog.csdn.net/aquester https://github.com/eyjian https://www.cnblogs.com/aquester http://blog.chinaunix.net/uid/20682147.html

文章分类

全部博文(594)

分类: HADOOP

2015-11-18 11:43:09

HBase的FlushLargeStoresPolicy.pdf

众所周知,HBase的一个例族flush时,会导致所有例族都跟着被flush。在HBase-0.94的官方说明()也明确HBase不能很好的支持一个以上的例族。


HBase-2.0.0HBase-1.1.0)引入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;

    }

}

阅读(3855) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~