Skip to content

Commit

Permalink
Close region after warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
terence-yoo committed Jan 12, 2023
1 parent 377c5e1 commit 78cf4c9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7756,7 +7756,7 @@ public static HRegion openReadOnlyFileSystemHRegion(final Configuration conf, fi
return r.openHRegion(null);
}

public static void warmupHRegion(final RegionInfo info, final TableDescriptor htd, final WAL wal,
public static HRegion warmupHRegion(final RegionInfo info, final TableDescriptor htd, final WAL wal,
final Configuration conf, final RegionServerServices rsServices,
final CancelableProgressable reporter) throws IOException {

Expand All @@ -7773,6 +7773,8 @@ public static void warmupHRegion(final RegionInfo info, final TableDescriptor ht
}
HRegion r = HRegion.newHRegion(tableDir, wal, fs, conf, info, htd, null);
r.initializeWarmup(reporter);
r.close();
return r;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ public Set<Path> get() {
// SFT implementations.
private final Supplier<StoreFileWriterCreationTracker> storeFileWriterCreationTrackerFactory;

private final boolean warmup;

/**
* Constructor
* @param family HColumnDescriptor for this column
Expand Down Expand Up @@ -290,6 +292,7 @@ protected HStore(final HRegion region, final ColumnFamilyDescriptor family,
this.compactionCheckMultiplier = DEFAULT_COMPACTCHECKER_INTERVAL_MULTIPLIER;
}

this.warmup = warmup;
this.storeEngine = createStoreEngine(this, this.conf, region.getCellComparator());
storeEngine.initialize(warmup);
// if require writing to tmp dir first, then we just return null, which indicate that we do not
Expand Down Expand Up @@ -740,7 +743,7 @@ private ImmutableCollection<HStoreFile> closeWithoutLock() throws IOException {
public Void call() throws IOException {
boolean evictOnClose =
getCacheConfig() != null ? getCacheConfig().shouldEvictOnClose() : true;
f.closeStoreFile(evictOnClose);
f.closeStoreFile(!warmup && evictOnClose);
return null;
}
});
Expand Down Expand Up @@ -774,6 +777,10 @@ public Void call() throws IOException {
return result;
}

private boolean needToEvictOnClose(boolean evictOnClose) {
return !this.warmup && evictOnClose;
}

/**
* Close all the readers We don't need to worry about subsequent requests because the Region holds
* a write lock that will prevent any more reads or writes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public boolean evaluate() throws IOException {
*/
@After
public void tearDown() throws Exception {
// Nothing to do.
TEST_UTIL.deleteTable(TABLENAME);
}

protected void runwarmup() throws InterruptedException {
Expand Down Expand Up @@ -163,4 +163,18 @@ public void testWarmup() throws Exception {
serverid = (serverid + 1) % 2;
}
}

@Test
public void testWarmupAndClose() throws IOException {
HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
HRegion region = TEST_UTIL.getMiniHBaseCluster().getRegions(TABLENAME).get(0);
RegionInfo info = region.getRegionInfo();

TableDescriptor htd = table.getDescriptor();
for (int i = 0; i < 10; i++) {
HRegion warmedUpRegion =
warmupHRegion(info, htd, rs.getWAL(info), rs.getConfiguration(), rs, null);
assertTrue(warmedUpRegion.isClosed());
}
}
}

0 comments on commit 78cf4c9

Please sign in to comment.