From 09cb269db2b350ab023768f1c44d019400a95762 Mon Sep 17 00:00:00 2001 From: Subhadeep Samantaray Date: Tue, 17 Mar 2015 14:51:37 -0700 Subject: [PATCH] Removed IS_ROOT from HTableDescriptor and performed code cleanup Summary: Removed IS_ROOT from HTableDescriptor Test Plan: Ran existing tests Differential Revision: https://reviews.facebook.net/D35241 --- .../org/apache/hadoop/hbase/HTableDescriptor.java | 46 ++-------------------- .../hadoop/hbase/rest/model/TableSchemaModel.java | 16 -------- .../hbase/rest/model/TestTableSchemaModel.java | 3 -- .../hadoop/hbase/master/TestRegionPlacement.java | 2 +- 4 files changed, 4 insertions(+), 63 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index a0ab484..13f9f0a 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -133,16 +133,6 @@ public class HTableDescriptor implements Comparable { /** * INTERNAL Used by rest interface to access this metadata - * attribute which denotes if the table is a -ROOT- region or not - * - * @see #isRootRegion() - */ - public static final String IS_ROOT = "IS_ROOT"; - private static final Bytes IS_ROOT_KEY = - new Bytes(Bytes.toBytes(IS_ROOT)); - - /** - * INTERNAL Used by rest interface to access this metadata * attribute which denotes if it is a catalog table, either * hbase:meta or -ROOT- * @@ -239,7 +229,6 @@ public class HTableDescriptor implements Comparable { for (String s : DEFAULT_VALUES.keySet()) { RESERVED_KEYWORDS.add(new Bytes(Bytes.toBytes(s))); } - RESERVED_KEYWORDS.add(IS_ROOT_KEY); RESERVED_KEYWORDS.add(IS_META_KEY); } @@ -247,10 +236,6 @@ public class HTableDescriptor implements Comparable { * Cache of whether this is a meta table or not. */ private volatile Boolean meta = null; - /** - * Cache of whether this is root table or not. - */ - private volatile Boolean root = null; /** * Durability setting for the table @@ -362,32 +347,7 @@ public class HTableDescriptor implements Comparable { * @param name */ private void setMetaFlags(final TableName name) { - setMetaRegion(isRootRegion() || - name.equals(TableName.META_TABLE_NAME)); - } - - /** - * Check if the descriptor represents a -ROOT- region. - * - * @return true if this is a -ROOT- region - */ - public boolean isRootRegion() { - if (this.root == null) { - this.root = isSomething(IS_ROOT_KEY, false)? Boolean.TRUE: Boolean.FALSE; - } - return this.root.booleanValue(); - } - - /** - * INTERNAL Used to denote if the current table represents - * -ROOT- region. This is used internally by the - * HTableDescriptor constructors - * - * @param isRoot true if this is the -ROOT- region - */ - protected void setRootRegion(boolean isRoot) { - // TODO: Make the value a boolean rather than String of boolean. - setValue(IS_ROOT_KEY, isRoot? TRUE: FALSE); + setMetaRegion(name.equals(TableName.META_TABLE_NAME)); } /** @@ -436,7 +396,7 @@ public class HTableDescriptor implements Comparable { * @return true if table is hbase:meta region. */ public boolean isMetaTable() { - return isMetaRegion() && !isRootRegion(); + return isMetaRegion(); } /** @@ -894,7 +854,7 @@ public class HTableDescriptor implements Comparable { } // only print out IS_ROOT/IS_META if true String value = Bytes.toString(values.get(k).get()); - if (key.equalsIgnoreCase(IS_ROOT) || key.equalsIgnoreCase(IS_META)) { + if (key.equalsIgnoreCase(IS_META)) { if (Boolean.valueOf(value) == false) continue; } // see if a reserved key is a default value. may not want to print it out diff --git a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java index 9e9fe47..962450d 100644 --- a/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java +++ b/hbase-rest/src/main/java/org/apache/hadoop/hbase/rest/model/TableSchemaModel.java @@ -65,7 +65,6 @@ import org.codehaus.jackson.annotate.JsonIgnore; public class TableSchemaModel implements Serializable, ProtobufMessageHandler { private static final long serialVersionUID = 1L; private static final QName IS_META = new QName(HTableDescriptor.IS_META); - private static final QName IS_ROOT = new QName(HTableDescriptor.IS_ROOT); private static final QName READONLY = new QName(HTableDescriptor.READONLY); private static final QName TTL = new QName(HColumnDescriptor.TTL); private static final QName VERSIONS = new QName(HConstants.VERSIONS); @@ -225,14 +224,6 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler { } /** - * @return true if IS_ROOT attribute exists and is truel - */ - public boolean __getIsRoot() { - Object o = attrs.get(IS_ROOT); - return o != null ? Boolean.valueOf(o.toString()) : false; - } - - /** * @return true if READONLY attribute exists and is truel */ public boolean __getReadOnly() { @@ -249,13 +240,6 @@ public class TableSchemaModel implements Serializable, ProtobufMessageHandler { } /** - * @param value desired value of IS_ROOT attribute - */ - public void __setIsRoot(boolean value) { - attrs.put(IS_ROOT, Boolean.toString(value)); - } - - /** * @param value desired value of READONLY attribute */ public void __setReadOnly(boolean value) { diff --git a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java index 4b2eb05..3ce1ff7 100644 --- a/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java +++ b/hbase-rest/src/test/java/org/apache/hadoop/hbase/rest/model/TestTableSchemaModel.java @@ -33,7 +33,6 @@ public class TestTableSchemaModel extends TestModelBase { public static final String TABLE_NAME = "testTable"; private static final boolean IS_META = false; - private static final boolean IS_ROOT = false; private static final boolean READONLY = false; TestColumnSchemaModel testColumnSchemaModel; @@ -72,7 +71,6 @@ public class TestTableSchemaModel extends TestModelBase { TableSchemaModel model = new TableSchemaModel(); model.setName(name); model.__setIsMeta(IS_META); - model.__setIsRoot(IS_ROOT); model.__setReadOnly(READONLY); model.addColumnFamily(testColumnSchemaModel.buildTestModel()); return model; @@ -85,7 +83,6 @@ public class TestTableSchemaModel extends TestModelBase { public void checkModel(TableSchemaModel model, String tableName) { assertEquals(model.getName(), tableName); assertEquals(model.__getIsMeta(), IS_META); - assertEquals(model.__getIsRoot(), IS_ROOT); assertEquals(model.__getReadOnly(), READONLY); Iterator families = model.getColumns().iterator(); assertTrue(families.hasNext()); diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java index 4034291..6805137 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionPlacement.java @@ -431,7 +431,7 @@ public class TestRegionPlacement { assertTrue("User region " + region.getTableDesc().getTableName() + " should have favored nodes", - (desc.isRootRegion() || desc.isMetaRegion())); + (desc.isMetaRegion())); } else { // For user region, the favored nodes in the region server should be // identical to favored nodes in the assignmentPlan -- 1.9.5