zoukankan      html  css  js  c++  java
  • HBase的FlushLargeStoresPolicy多例族支持

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

    HBase-2.0.0HBase-1.1.0https://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<Store> selectStoresToFlush();

    }

    public class FlushLargeStoresPolicy extends FlushPolicy {

        private boolean shouldFlush(Store store) {

            if (store.getMemStoreSize() > this.flushSizeLowerBound) {

                return true;

            }

            

            // 请注意下面这句

            return region.shouldFlushStore(store);

        }

        

        public Collection<Store> selectStoresToFlush() {

            Collection<Store> stores = region.stores.values();

            Set<Store> specificStoresToFlush = new HashSet<Store>();

            for (Store store : stores) {

                if (shouldFlush(store)) {

                    specificStoresToFlush.add(store);

                }

            }

            

            return specificStoresToFlush;

        }

    }

    public class FlushAllStoresPolicy extends FlushPolicy {

      public Collection<Store> 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;

        }

    }

  • 相关阅读:
    webpack 4.X 基础编译
    一个数组中两个数的和为N,找出这两个数字的下标
    Mybatis自动生成,针对字段类型为text等会默认产生XXXXWithBlobs的方法问题
    Docker Mysql
    Docker镜像Push到DockerHub
    E: Unable to locate package git
    linux解压类型总结
    docker安装gitlab
    Docker应用
    解决github访问及上传慢的问题
  • 原文地址:https://www.cnblogs.com/aquester/p/9891559.html
Copyright © 2011-2022 走看看