HBASE-18544 Move the HRegion#addRegionToMETA to TestDefaultMemStore Signed-off-by: Michael Stack <st...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/310934d0 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/310934d0 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/310934d0 Branch: refs/heads/HBASE-18467 Commit: 310934d0604605fe361e836fe4277c48b5c493fa Parents: 63e313b Author: Chun-Hao Tang <tang7...@gmail.com> Authored: Wed Aug 16 00:43:02 2017 +0800 Committer: Michael Stack <st...@apache.org> Committed: Tue Aug 15 14:52:33 2017 -0700 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/HRegion.java | 31 ++------------------ .../hbase/regionserver/TestDefaultMemStore.java | 28 +++++++++++++++++- 2 files changed, 29 insertions(+), 30 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/310934d0/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 3b24f3d..b9cafd9 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -3928,7 +3928,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi * We throw RegionTooBusyException if above memstore limit * and expect client to retry using some kind of backoff */ - private void checkResources() throws RegionTooBusyException { + void checkResources() throws RegionTooBusyException { // If catalog region, do not impose resource constraints or block updates. if (this.getRegionInfo().isMetaRegion()) return; @@ -3974,7 +3974,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi * @param edits Cell updates by column * @throws IOException */ - private void put(final byte [] row, byte [] family, List<Cell> edits) + void put(final byte [] row, byte [] family, List<Cell> edits) throws IOException { NavigableMap<byte[], List<Cell>> familyMap; familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); @@ -6878,33 +6878,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi } /** - * Inserts a new region's meta information into the passed - * <code>meta</code> region. Used by the HMaster bootstrap code adding - * new table to hbase:meta table. - * - * @param meta hbase:meta HRegion to be updated - * @param r HRegion to add to <code>meta</code> - * - * @throws IOException - */ - // TODO remove since only test and merge use this - public static void addRegionToMETA(final HRegion meta, final HRegion r) throws IOException { - meta.checkResources(); - // The row key is the region name - byte[] row = r.getRegionInfo().getRegionName(); - final long now = EnvironmentEdgeManager.currentTime(); - final List<Cell> cells = new ArrayList<>(2); - cells.add(new KeyValue(row, HConstants.CATALOG_FAMILY, - HConstants.REGIONINFO_QUALIFIER, now, - r.getRegionInfo().toByteArray())); - // Set into the root table the version of the meta table. - cells.add(new KeyValue(row, HConstants.CATALOG_FAMILY, - HConstants.META_VERSION_QUALIFIER, now, - Bytes.toBytes(HConstants.META_VERSION))); - meta.put(row, HConstants.CATALOG_FAMILY, cells); - } - - /** * Computes the Path of the HRegion * * @param tabledir qualified path for table http://git-wip-us.apache.org/repos/asf/hbase/blob/310934d0/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java index 0b1638b..7b10846 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestDefaultMemStore.java @@ -975,7 +975,7 @@ public class TestDefaultMemStore { HRegion r = HRegion.createHRegion(hri, testDir, conf, desc, wFactory.getWAL(hri.getEncodedNameAsBytes(), hri.getTable().getNamespace())); - HRegion.addRegionToMETA(meta, r); + addRegionToMETA(meta, r); edge.setCurrentTimeMillis(1234 + 100); StringBuffer sb = new StringBuffer(); assertTrue(meta.shouldFlush(sb) == false); @@ -983,6 +983,32 @@ public class TestDefaultMemStore { assertTrue(meta.shouldFlush(sb) == true); } + /** + * Inserts a new region's meta information into the passed + * <code>meta</code> region. Used by the HMaster bootstrap code adding + * new table to hbase:meta table. + * + * @param meta hbase:meta HRegion to be updated + * @param r HRegion to add to <code>meta</code> + * + * @throws IOException + */ + public static void addRegionToMETA(final HRegion meta, final HRegion r) throws IOException { + meta.checkResources(); + // The row key is the region name + byte[] row = r.getRegionInfo().getRegionName(); + final long now = EnvironmentEdgeManager.currentTime(); + final List<Cell> cells = new ArrayList<>(2); + cells.add(new KeyValue(row, HConstants.CATALOG_FAMILY, + HConstants.REGIONINFO_QUALIFIER, now, + r.getRegionInfo().toByteArray())); + // Set into the root table the version of the meta table. + cells.add(new KeyValue(row, HConstants.CATALOG_FAMILY, + HConstants.META_VERSION_QUALIFIER, now, + Bytes.toBytes(HConstants.META_VERSION))); + meta.put(row, HConstants.CATALOG_FAMILY, cells); + } + private class EnvironmentEdgeForMemstoreTest implements EnvironmentEdge { long t = 1234; @Override