From 1fe4d1b3f959b118e161ebabd09d740f7c5750e7 Mon Sep 17 00:00:00 2001 From: LiangJun He <2005hithlj@163.com> Date: Thu, 2 Jun 2022 21:27:25 +0800 Subject: [PATCH] HBASE-27039 Some methods of MasterRegion should be annotated for testing only (#4433) Signed-off-by: Duo Zhang (cherry picked from commit 15002fccb4abb187467a9355f436d533928da7ef) Change-Id: I44188f67e3a7f44d8ef54099b375023a6a821641 --- .../hadoop/hbase/master/region/MasterRegion.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java index 7cf5c8724b49..fdaef781e279 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java @@ -19,6 +19,7 @@ import static org.apache.hadoop.hbase.HConstants.HREGION_LOGDIR_NAME; +import com.google.errorprone.annotations.RestrictedApi; import java.io.IOException; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -141,6 +142,12 @@ public void update(UpdateMasterRegion action) throws IOException { flusherAndCompactor.onUpdate(); } + /** + * The design for master region is to only load all the data to memory at once when starting, so + * typically you should not use the get method to get a single row of data at runtime. + */ + @RestrictedApi(explanation = "Should only be called in tests", link = "", + allowedOnPath = ".*/src/test/.*") public Result get(Get get) throws IOException { return region.get(get); } @@ -149,14 +156,20 @@ public RegionScanner getScanner(Scan scan) throws IOException { return region.getScanner(scan); } + @RestrictedApi(explanation = "Should only be called in tests", link = "", + allowedOnPath = ".*/src/test/.*") public FlushResult flush(boolean force) throws IOException { return region.flush(force); } + @RestrictedApi(explanation = "Should only be called in tests", link = "", + allowedOnPath = ".*/src/test/.*") public void requestRollAll() { walRoller.requestRollAll(); } + @RestrictedApi(explanation = "Should only be called in tests", link = "", + allowedOnPath = ".*/src/test/.*") public void waitUntilWalRollFinished() throws InterruptedException { walRoller.waitUntilWalRollFinished(); }