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;

        }

    }

  • 相关阅读:
    为动态添加的元素,绑定click事件
    Struts报错NoSuchMethodException的解决方法
    Struts报错ObjectNotFoundException的解决方法
    HTML通知、新闻等文字列表的无缝滚动效果
    HTML通过使用JS动态显示table内容
    CentOS下整合Apache与Tomcat的一种方法
    Centos下Apache整合Tomcat访问报Forbidden 403 错误的解决方法
    从Google趋势来看五大联赛在世界范围内的影响力
    Java实现多线程的三种方法
    DataGrid中插入Combobox选择框
  • 原文地址:https://www.cnblogs.com/aquester/p/9891559.html
Copyright © 2011-2022 走看看