| 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; } } |