You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2026/04/08 15:24:01 UTC
(hbase) 11/32: HBASE-29594: Add suffix to Master Region data directory (#7330)
This is an automated email from the ASF dual-hosted git repository.
andor pushed a commit to branch HBASE-29081
in repository https://gitbox.apache.org/repos/asf/hbase.git
commit 6ffba71224b9d31db6a6f2199cebe3499bcf4d8e
Author: Kota-SH <sh...@gmail.com>
AuthorDate: Mon Oct 20 10:37:49 2025 -0400
HBASE-29594: Add suffix to Master Region data directory (#7330)
---
.../hbase/master/region/MasterRegionFactory.java | 28 ++++++++++++++++++++--
.../store/region/HFileProcedurePrettyPrinter.java | 2 +-
.../master/region/TestMasterRegionInitialize.java | 18 ++++++++++++++
.../region/TestHFileProcedurePrettyPrinter.java | 2 +-
.../region/TestWALProcedurePrettyPrinter.java | 2 +-
5 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFactory.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFactory.java
index 878f8dc17a1..cec8cd4ce9e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFactory.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFactory.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.master.region;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
@@ -34,6 +35,8 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ReflectionUtils;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Strings;
+
/**
* The factory class for creating a {@link MasterRegion}.
*/
@@ -54,7 +57,24 @@ public final class MasterRegionFactory {
public static final String USE_HSYNC_KEY = "hbase.master.store.region.wal.hsync";
- public static final String MASTER_STORE_DIR = "MasterData";
+ // Default master data dir
+ private static final String MASTER_REGION_DIR_NAME_DEFAULT = "MasterData";
+
+ private static final String MASTER_REGION_DIR_NAME;
+ static {
+ Configuration conf = HBaseConfiguration.create();
+ MASTER_REGION_DIR_NAME = initMasterRegionDirName(conf);
+ }
+
+ public static String initMasterRegionDirName(Configuration conf) {
+ String suffix = conf.get(HConstants.HBASE_META_TABLE_SUFFIX,
+ HConstants.HBASE_META_TABLE_SUFFIX_DEFAULT_VALUE);
+ if (Strings.isNullOrEmpty(suffix)) {
+ return MASTER_REGION_DIR_NAME_DEFAULT;
+ } else {
+ return MASTER_REGION_DIR_NAME_DEFAULT + "_" + suffix;
+ }
+ }
private static final String FLUSH_SIZE_KEY = "hbase.master.store.region.flush.size";
@@ -116,7 +136,7 @@ public final class MasterRegionFactory {
public static MasterRegion create(MasterServices server) throws IOException {
Configuration conf = server.getConfiguration();
MasterRegionParams params = new MasterRegionParams().server(server)
- .regionDirName(MASTER_STORE_DIR).tableDescriptor(withTrackerConfigs(conf));
+ .regionDirName(getMasterRegionDirName()).tableDescriptor(withTrackerConfigs(conf));
long flushSize = conf.getLong(FLUSH_SIZE_KEY, DEFAULT_FLUSH_SIZE);
long flushPerChanges = conf.getLong(FLUSH_PER_CHANGES_KEY, DEFAULT_FLUSH_PER_CHANGES);
long flushIntervalMs = conf.getLong(FLUSH_INTERVAL_MS_KEY, DEFAULT_FLUSH_INTERVAL_MS);
@@ -134,4 +154,8 @@ public final class MasterRegionFactory {
.archivedHFileSuffix(ARCHIVED_HFILE_SUFFIX);
return MasterRegion.create(params);
}
+
+ public static String getMasterRegionDirName() {
+ return MASTER_REGION_DIR_NAME;
+ }
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/HFileProcedurePrettyPrinter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/HFileProcedurePrettyPrinter.java
index c254201db9b..0752c814f38 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/HFileProcedurePrettyPrinter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure2/store/region/HFileProcedurePrettyPrinter.java
@@ -85,7 +85,7 @@ public class HFileProcedurePrettyPrinter extends AbstractHBaseTool {
private void addAllHFiles() throws IOException {
Path masterProcDir =
- new Path(CommonFSUtils.getRootDir(conf), MasterRegionFactory.MASTER_STORE_DIR);
+ new Path(CommonFSUtils.getRootDir(conf), MasterRegionFactory.getMasterRegionDirName());
Path tableDir = CommonFSUtils.getTableDir(masterProcDir, MasterRegionFactory.TABLE_NAME);
FileSystem fs = tableDir.getFileSystem(conf);
Path regionDir =
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionInitialize.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionInitialize.java
index b3e732db3eb..15d5908591c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionInitialize.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/region/TestMasterRegionInitialize.java
@@ -24,7 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
+import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.TableDescriptor;
@@ -109,4 +112,19 @@ public class TestMasterRegionInitialize extends MasterRegionTestBase {
// but the data should have been cleaned up
assertTrue(region.get(new Get(row)).isEmpty());
}
+
+ @Test
+ public void testMasterRegionDirSuffix() {
+ String currentMasterRegionDirName = MasterRegionFactory.getMasterRegionDirName();
+ assertEquals("Default master region directory should be MasterData", "MasterData",
+ currentMasterRegionDirName);
+
+ Configuration confWithSuffix = HBaseConfiguration.create();
+ String suffix = "replica1";
+ confWithSuffix.set(HConstants.HBASE_META_TABLE_SUFFIX, suffix);
+ String dirNameWithSuffix = MasterRegionFactory.initMasterRegionDirName(confWithSuffix);
+ String expectedDirName = "MasterData_" + suffix;
+ assertEquals("Directory name should have suffix when configured", expectedDirName,
+ dirNameWithSuffix);
+ }
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestHFileProcedurePrettyPrinter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestHFileProcedurePrettyPrinter.java
index aa9648995a3..d3c09875338 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestHFileProcedurePrettyPrinter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestHFileProcedurePrettyPrinter.java
@@ -97,7 +97,7 @@ public class TestHFileProcedurePrettyPrinter extends RegionProcedureStoreTestBas
store.cleanup();
store.region.flush(true);
Path tableDir = CommonFSUtils.getTableDir(
- new Path(htu.getDataTestDir(), MasterRegionFactory.MASTER_STORE_DIR),
+ new Path(htu.getDataTestDir(), MasterRegionFactory.getMasterRegionDirName()),
MasterRegionFactory.TABLE_NAME);
FileSystem fs = tableDir.getFileSystem(htu.getConfiguration());
Path regionDir =
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestWALProcedurePrettyPrinter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestWALProcedurePrettyPrinter.java
index 95f72f69b96..bbfa2bff655 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestWALProcedurePrettyPrinter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestWALProcedurePrettyPrinter.java
@@ -59,7 +59,7 @@ public class TestWALProcedurePrettyPrinter extends RegionProcedureStoreTestBase
}
store.cleanup();
Path walParentDir = new Path(htu.getDataTestDir(),
- MasterRegionFactory.MASTER_STORE_DIR + "/" + HConstants.HREGION_LOGDIR_NAME);
+ MasterRegionFactory.getMasterRegionDirName() + "/" + HConstants.HREGION_LOGDIR_NAME);
FileSystem fs = walParentDir.getFileSystem(htu.getConfiguration());
Path walDir = fs.listStatus(walParentDir)[0].getPath();
Path walFile = fs.listStatus(walDir)[0].getPath();