HBase的FlushLargeStoresPolicy多例族支持HBase的FlushLargeStoresPolicy.pdf

众所周知,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其它所有例族):

HBase的FlushLargeStoresPolicy多例族支持 


flush过程:

HBase的FlushLargeStoresPolicy多例族支持 

相关源代码:

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 

            return true;

        }

        

        if (flushCheckInterval 

            return false;

        }

        

        long now = EnvironmentEdgeManager.currentTime();

        if (store.timeOfOldestEdit() 

            return true;

        }

        

        return false;

    }

}

相关文章:

  • 2022-01-08
  • 2021-11-18
  • 2021-06-19
  • 2021-06-01
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
猜你喜欢
  • 2021-07-03
  • 2022-03-03
  • 2021-11-18
  • 2021-05-13
  • 2021-07-07
  • 2022-03-15
相关资源
相似解决方案