anmolnar commented on code in PR #6632:
URL: https://github.com/apache/hbase/pull/6632#discussion_r1934692573
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/InitMetaProcedure.java:
##########
@@ -61,9 +65,21 @@ public class InitMetaProcedure extends
AbstractStateMachineTableProcedure<InitMe
private RetryCounter retryCounter;
+ protected final Configuration conf;
+ public InitMetaProcedure(Configuration conf) {
+ this.conf = conf;
+ }
+
@Override
public TableName getTableName() {
- return TableName.META_TABLE_NAME;
+ String suffix_val = String.valueOf(conf.getStrings(
+ HConstants.HBASE_META_TABLE_SUFFIX,
HConstants.HBASE_META_TABLE_SUFFIX_DEFAULT_VALUE));
+
+ if (suffix_val == null||suffix_val.isEmpty()) {
+ return TableName.META_TABLE_NAME;
+ }
+ return valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "meta_"
+ + suffix_val);
Review Comment:
Don't duplicate the logic, put it at a common place: keep it here or in the
other class, or put it in a common utility.
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/HConstants.java:
##########
@@ -1641,6 +1641,19 @@ public enum OperationStatusCode {
*/
public final static boolean REJECT_DECOMMISSIONED_HOSTS_DEFAULT = false;
+ /**
+ * Adds a suffix to the meta table name: value=’test’ -> ‘hbase:meta_test’
+ * Added in HBASE-XXXXX to support having multiple hbase:meta tables (with
distinct names )to
+ * enable storage sharing by more than one clusters.
+ */
+
Review Comment:
nit: remove empty line
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java:
##########
@@ -65,9 +70,26 @@ public final class TableName implements
Comparable<TableName> {
public static final String VALID_USER_TABLE_REGEX = "(?:(?:(?:" +
VALID_NAMESPACE_REGEX + "\\"
+ NAMESPACE_DELIM + ")?)" + "(?:" + VALID_TABLE_QUALIFIER_REGEX + "))";
- /** The hbase:meta table's name. */
- public static final TableName META_TABLE_NAME =
- valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "meta");
+ /** The name of hbase meta table could either be hbase:meta_xxx or
'hbase:meta' otherwise.
+ * Config hbase.meta.table.suffix will govern the decision of adding suffix
to the habase:meta */
+ public static final TableName META_TABLE_NAME;
+ static {
+ Configuration conf = HBaseConfiguration.create();
+ META_TABLE_NAME = initializeHbaseMetaTableName(conf);
+ }
+
+ static TableName initializeHbaseMetaTableName(Configuration conf) {
+ String suffix_val = String.valueOf(conf.getStrings(
+ HConstants.HBASE_META_TABLE_SUFFIX,
HConstants.HBASE_META_TABLE_SUFFIX_DEFAULT_VALUE));
+
+ if (suffix_val == null||suffix_val.isEmpty()) {
Review Comment:
Use proper formatting:
```java
if (suffix_val == null || suffix_val.isEmpty()) {
```
##########
hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java:
##########
@@ -65,9 +70,26 @@ public final class TableName implements
Comparable<TableName> {
public static final String VALID_USER_TABLE_REGEX = "(?:(?:(?:" +
VALID_NAMESPACE_REGEX + "\\"
+ NAMESPACE_DELIM + ")?)" + "(?:" + VALID_TABLE_QUALIFIER_REGEX + "))";
- /** The hbase:meta table's name. */
- public static final TableName META_TABLE_NAME =
- valueOf(NamespaceDescriptor.SYSTEM_NAMESPACE_NAME_STR, "meta");
+ /** The name of hbase meta table could either be hbase:meta_xxx or
'hbase:meta' otherwise.
+ * Config hbase.meta.table.suffix will govern the decision of adding suffix
to the habase:meta */
+ public static final TableName META_TABLE_NAME;
+ static {
+ Configuration conf = HBaseConfiguration.create();
+ META_TABLE_NAME = initializeHbaseMetaTableName(conf);
+ }
+
+ static TableName initializeHbaseMetaTableName(Configuration conf) {
+ String suffix_val = String.valueOf(conf.getStrings(
+ HConstants.HBASE_META_TABLE_SUFFIX,
HConstants.HBASE_META_TABLE_SUFFIX_DEFAULT_VALUE));
+
+ if (suffix_val == null||suffix_val.isEmpty()) {
+ LOG.debug("Default value for Hbase meta table is being chosen.");
+ return TableName.META_TABLE_NAME;
+ }
+ LOG.debug("Suffix value for Hbase meta table is being chosen.");
Review Comment:
Instead of emitting 2 separate log messages, add a single one at INFO level.
```java
LOG.info("Meta table name: {}", META_TABLE_NAME);
```
##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/InitMetaProcedure.java:
##########
@@ -78,6 +94,7 @@ private static TableDescriptor writeFsLayout(Path rootDir,
Configuration conf)
Path tableDir = CommonFSUtils.getTableDir(rootDir,
TableName.META_TABLE_NAME);
if (fs.exists(tableDir) && !fs.delete(tableDir, true)) {
LOG.warn("Can not delete partial created meta table, continue...");
+ throw new HBaseIOException("Specified meta table already exists.");
Review Comment:
We might not need this I believe for 2 reasons:
- we should keep the original logic here for backward compatiblity,
- you throw this exception only in the case when HBase tried to delete
`tableDir`, but it wasn't successful
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]