Skip to content

Commit bad2d4e

Browse files
authored
HBASE-24474 Rename LocalRegion to MasterRegion (apache#1811)
Signed-off-by: Michael Stack <stack@apache.org>
1 parent 716702a commit bad2d4e

28 files changed

+215
-230
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@
133133
import org.apache.hadoop.hbase.master.procedure.ReopenTableRegionsProcedure;
134134
import org.apache.hadoop.hbase.master.procedure.ServerCrashProcedure;
135135
import org.apache.hadoop.hbase.master.procedure.TruncateTableProcedure;
136+
import org.apache.hadoop.hbase.master.region.MasterRegion;
137+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
136138
import org.apache.hadoop.hbase.master.replication.AbstractPeerProcedure;
137139
import org.apache.hadoop.hbase.master.replication.AddPeerProcedure;
138140
import org.apache.hadoop.hbase.master.replication.DisablePeerProcedure;
@@ -144,7 +146,6 @@
144146
import org.apache.hadoop.hbase.master.replication.UpdatePeerConfigProcedure;
145147
import org.apache.hadoop.hbase.master.slowlog.SlowLogMasterService;
146148
import org.apache.hadoop.hbase.master.snapshot.SnapshotManager;
147-
import org.apache.hadoop.hbase.master.store.LocalStore;
148149
import org.apache.hadoop.hbase.master.zksyncer.MasterAddressSyncer;
149150
import org.apache.hadoop.hbase.master.zksyncer.MetaLocationSyncer;
150151
import org.apache.hadoop.hbase.mob.MobFileCleanerChore;
@@ -450,7 +451,7 @@ public void run() {
450451
private ProcedureStore procedureStore;
451452

452453
// the master local storage to store procedure data, etc.
453-
private LocalStore localStore;
454+
private MasterRegion masterRegion;
454455

455456
// handle table states
456457
private TableStateManager tableStateManager;
@@ -964,8 +965,8 @@ private void finishActiveMasterInitialization(MonitoredTask status) throws IOExc
964965
this.splitWALManager = new SplitWALManager(this);
965966
}
966967

967-
// initialize local store
968-
localStore = LocalStore.create(this);
968+
// initialize master local region
969+
masterRegion = MasterRegionFactory.create(this);
969970
createProcedureExecutor();
970971
Map<Class<?>, List<Procedure<MasterProcedureEnv>>> procsByType =
971972
procedureExecutor.getActiveProceduresNoCopy().stream()
@@ -1543,8 +1544,8 @@ protected void stopServiceThreads() {
15431544

15441545
stopProcedureExecutor();
15451546

1546-
if (localStore != null) {
1547-
localStore.close(isAborted());
1547+
if (masterRegion != null) {
1548+
masterRegion.close(isAborted());
15481549
}
15491550
if (this.walManager != null) {
15501551
this.walManager.stop();
@@ -1563,7 +1564,7 @@ protected void stopServiceThreads() {
15631564
private void createProcedureExecutor() throws IOException {
15641565
MasterProcedureEnv procEnv = new MasterProcedureEnv(this);
15651566
procedureStore =
1566-
new RegionProcedureStore(this, localStore, new MasterProcedureEnv.FsUtilsLeaseRecovery(this));
1567+
new RegionProcedureStore(this, masterRegion, new MasterProcedureEnv.FsUtilsLeaseRecovery(this));
15671568
procedureStore.registerListener(new ProcedureStoreListener() {
15681569

15691570
@Override

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/HFileCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import org.apache.hadoop.hbase.Stoppable;
3333
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
3434
import org.apache.hadoop.hbase.io.HFileLink;
35-
import org.apache.hadoop.hbase.master.store.LocalStore;
35+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
3636
import org.apache.hadoop.hbase.regionserver.StoreFileInfo;
3737
import org.apache.hadoop.hbase.util.StealJobQueue;
3838
import org.apache.yetus.audience.InterfaceAudience;
@@ -161,7 +161,7 @@ public HFileCleaner(String name, int period, Stoppable stopper, Configuration co
161161
protected boolean validate(Path file) {
162162
return HFileLink.isBackReferencesDir(file) || HFileLink.isBackReferencesDir(file.getParent()) ||
163163
StoreFileInfo.validateStoreFileName(file.getName()) ||
164-
file.getName().endsWith(LocalStore.ARCHIVED_HFILE_SUFFIX);
164+
file.getName().endsWith(MasterRegionFactory.ARCHIVED_HFILE_SUFFIX);
165165
}
166166

167167
/**

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/LogCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.apache.hadoop.hbase.Stoppable;
3636
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
3737
import org.apache.hadoop.hbase.master.procedure.MasterProcedureUtil;
38-
import org.apache.hadoop.hbase.master.store.LocalStore;
38+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
3939
import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
4040
import org.apache.yetus.audience.InterfaceAudience;
4141
import org.slf4j.Logger;
@@ -89,7 +89,7 @@ public LogCleaner(final int period, final Stoppable stopper, Configuration conf,
8989
protected boolean validate(Path file) {
9090
return AbstractFSWALProvider.validateWALFilename(file.getName()) ||
9191
MasterProcedureUtil.validateProcedureWALFilename(file.getName()) ||
92-
file.getName().endsWith(LocalStore.ARCHIVED_WAL_SUFFIX);
92+
file.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX);
9393
}
9494

9595
@Override

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveMasterLocalStoreHFileCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.apache.hadoop.conf.Configuration;
2121
import org.apache.hadoop.fs.Path;
2222
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
23-
import org.apache.hadoop.hbase.master.store.LocalStore;
23+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
2424
import org.apache.yetus.audience.InterfaceAudience;
2525

2626
/**
@@ -42,7 +42,7 @@ protected long getTtlMs(Configuration conf) {
4242

4343
@Override
4444
protected boolean valiateFilename(Path file) {
45-
return file.getName().endsWith(LocalStore.ARCHIVED_HFILE_SUFFIX);
45+
return file.getName().endsWith(MasterRegionFactory.ARCHIVED_HFILE_SUFFIX);
4646
}
4747

4848
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/cleaner/TimeToLiveMasterLocalStoreWALCleaner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import org.apache.hadoop.conf.Configuration;
2121
import org.apache.hadoop.fs.Path;
2222
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
23-
import org.apache.hadoop.hbase.master.store.LocalStore;
23+
import org.apache.hadoop.hbase.master.region.MasterRegionFactory;
2424
import org.apache.yetus.audience.InterfaceAudience;
2525

2626
/**
@@ -42,6 +42,6 @@ protected long getTtlMs(Configuration conf) {
4242

4343
@Override
4444
protected boolean valiateFilename(Path file) {
45-
return file.getName().endsWith(LocalStore.ARCHIVED_WAL_SUFFIX);
45+
return file.getName().endsWith(MasterRegionFactory.ARCHIVED_WAL_SUFFIX);
4646
}
4747
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/store/LocalRegion.java renamed to hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegion.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package org.apache.hadoop.hbase.master.store;
18+
package org.apache.hadoop.hbase.master.region;
1919

2020
import static org.apache.hadoop.hbase.HConstants.HREGION_LOGDIR_NAME;
2121

@@ -54,7 +54,7 @@
5454
import org.apache.hbase.thirdparty.com.google.common.math.IntMath;
5555

5656
/**
57-
* A region that stores data in a separated directory.
57+
* A region that stores data in a separated directory, which can be used to store master local data.
5858
* <p/>
5959
* FileSystem layout:
6060
*
@@ -79,14 +79,14 @@
7979
* Notice that, you can use different root file system and WAL file system. Then the above directory
8080
* will be on two file systems, the root file system will have the data directory while the WAL
8181
* filesystem will have the WALs directory. The archived HFile will be moved to the global HFile
82-
* archived directory with the {@link LocalRegionParams#archivedWalSuffix()} suffix. The archived
82+
* archived directory with the {@link MasterRegionParams#archivedWalSuffix()} suffix. The archived
8383
* WAL will be moved to the global WAL archived directory with the
84-
* {@link LocalRegionParams#archivedHFileSuffix()} suffix.
84+
* {@link MasterRegionParams#archivedHFileSuffix()} suffix.
8585
*/
8686
@InterfaceAudience.Private
87-
public final class LocalRegion {
87+
public final class MasterRegion {
8888

89-
private static final Logger LOG = LoggerFactory.getLogger(LocalRegion.class);
89+
private static final Logger LOG = LoggerFactory.getLogger(MasterRegion.class);
9090

9191
private static final String REPLAY_EDITS_DIR = "recovered.wals";
9292

@@ -100,12 +100,12 @@ public final class LocalRegion {
100100
final HRegion region;
101101

102102
@VisibleForTesting
103-
final LocalRegionFlusherAndCompactor flusherAndCompactor;
103+
final MasterRegionFlusherAndCompactor flusherAndCompactor;
104104

105-
private LocalRegionWALRoller walRoller;
105+
private MasterRegionWALRoller walRoller;
106106

107-
private LocalRegion(HRegion region, WALFactory walFactory,
108-
LocalRegionFlusherAndCompactor flusherAndCompactor, LocalRegionWALRoller walRoller) {
107+
private MasterRegion(HRegion region, WALFactory walFactory,
108+
MasterRegionFlusherAndCompactor flusherAndCompactor, MasterRegionWALRoller walRoller) {
109109
this.region = region;
110110
this.walFactory = walFactory;
111111
this.flusherAndCompactor = flusherAndCompactor;
@@ -128,7 +128,7 @@ private void shutdownWAL() {
128128
}
129129
}
130130

131-
public void update(UpdateLocalRegion action) throws IOException {
131+
public void update(UpdateMasterRegion action) throws IOException {
132132
action.update(region);
133133
flusherAndCompactor.onUpdate();
134134
}
@@ -142,17 +142,17 @@ public RegionScanner getScanner(Scan scan) throws IOException {
142142
}
143143

144144
@VisibleForTesting
145-
FlushResult flush(boolean force) throws IOException {
145+
public FlushResult flush(boolean force) throws IOException {
146146
return region.flush(force);
147147
}
148148

149149
@VisibleForTesting
150-
void requestRollAll() {
150+
public void requestRollAll() {
151151
walRoller.requestRollAll();
152152
}
153153

154154
@VisibleForTesting
155-
void waitUntilWalRollFinished() throws InterruptedException {
155+
public void waitUntilWalRollFinished() throws InterruptedException {
156156
walRoller.waitUntilWalRollFinished();
157157
}
158158

@@ -176,7 +176,7 @@ public void close(boolean abort) {
176176
}
177177
}
178178

179-
private static WAL createWAL(WALFactory walFactory, LocalRegionWALRoller walRoller,
179+
private static WAL createWAL(WALFactory walFactory, MasterRegionWALRoller walRoller,
180180
String serverName, FileSystem walFs, Path walRootDir, RegionInfo regionInfo)
181181
throws IOException {
182182
String logName = AbstractFSWALProvider.getWALDirectoryName(serverName);
@@ -197,7 +197,7 @@ private static WAL createWAL(WALFactory walFactory, LocalRegionWALRoller walRoll
197197

198198
private static HRegion bootstrap(Configuration conf, TableDescriptor td, FileSystem fs,
199199
Path rootDir, FileSystem walFs, Path walRootDir, WALFactory walFactory,
200-
LocalRegionWALRoller walRoller, String serverName) throws IOException {
200+
MasterRegionWALRoller walRoller, String serverName) throws IOException {
201201
TableName tn = td.getTableName();
202202
RegionInfo regionInfo = RegionInfoBuilder.newBuilder(tn).setRegionId(REGION_ID).build();
203203
Path tmpTableDir = CommonFSUtils.getTableDir(rootDir,
@@ -215,7 +215,7 @@ private static HRegion bootstrap(Configuration conf, TableDescriptor td, FileSys
215215
}
216216

217217
private static HRegion open(Configuration conf, TableDescriptor td, FileSystem fs, Path rootDir,
218-
FileSystem walFs, Path walRootDir, WALFactory walFactory, LocalRegionWALRoller walRoller,
218+
FileSystem walFs, Path walRootDir, WALFactory walFactory, MasterRegionWALRoller walRoller,
219219
String serverName) throws IOException {
220220
Path tableDir = CommonFSUtils.getTableDir(rootDir, td.getTableName());
221221
Path regionDir =
@@ -269,7 +269,7 @@ private static HRegion open(Configuration conf, TableDescriptor td, FileSystem f
269269
return HRegion.openHRegionFromTableDir(conf, fs, tableDir, regionInfo, td, wal, null, null);
270270
}
271271

272-
public static LocalRegion create(LocalRegionParams params) throws IOException {
272+
public static MasterRegion create(MasterRegionParams params) throws IOException {
273273
TableDescriptor td = params.tableDescriptor();
274274
LOG.info("Create or load local region for table " + td);
275275
Server server = params.server();
@@ -284,18 +284,21 @@ public static LocalRegion create(LocalRegionParams params) throws IOException {
284284
Configuration conf = new Configuration(baseConf);
285285
CommonFSUtils.setRootDir(conf, rootDir);
286286
CommonFSUtils.setWALRootDir(conf, walRootDir);
287-
LocalRegionFlusherAndCompactor.setupConf(conf, params.flushSize(), params.flushPerChanges(),
287+
MasterRegionFlusherAndCompactor.setupConf(conf, params.flushSize(), params.flushPerChanges(),
288288
params.flushIntervalMs());
289289
conf.setInt(AbstractFSWAL.MAX_LOGS, params.maxWals());
290290
if (params.useHsync() != null) {
291291
conf.setBoolean(HRegion.WAL_HSYNC_CONF_KEY, params.useHsync());
292292
}
293+
if (params.useMetaCellComparator() != null) {
294+
conf.setBoolean(HRegion.USE_META_CELL_COMPARATOR, params.useMetaCellComparator());
295+
}
293296
conf.setInt(AbstractFSWAL.RING_BUFFER_SLOT_COUNT,
294297
IntMath.ceilingPowerOfTwo(params.ringBufferSlotCount()));
295298

296-
LocalRegionWALRoller walRoller = LocalRegionWALRoller.create(td.getTableName() + "-WAL-Roller",
297-
conf, server, walFs, walRootDir, globalWALRootDir, params.archivedWalSuffix(),
298-
params.rollPeriodMs(), params.flushSize());
299+
MasterRegionWALRoller walRoller = MasterRegionWALRoller.create(
300+
td.getTableName() + "-WAL-Roller", conf, server, walFs, walRootDir, globalWALRootDir,
301+
params.archivedWalSuffix(), params.rollPeriodMs(), params.flushSize());
299302
walRoller.start();
300303

301304
WALFactory walFactory = new WALFactory(conf, server.getServerName().toString(), false);
@@ -311,7 +314,7 @@ public static LocalRegion create(LocalRegionParams params) throws IOException {
311314
server.getServerName().toString());
312315
}
313316
Path globalArchiveDir = HFileArchiveUtil.getArchivePath(baseConf);
314-
LocalRegionFlusherAndCompactor flusherAndCompactor = new LocalRegionFlusherAndCompactor(conf,
317+
MasterRegionFlusherAndCompactor flusherAndCompactor = new MasterRegionFlusherAndCompactor(conf,
315318
server, region, params.flushSize(), params.flushPerChanges(), params.flushIntervalMs(),
316319
params.compactMin(), globalArchiveDir, params.archivedHFileSuffix());
317320
walRoller.setFlusherAndCompactor(flusherAndCompactor);
@@ -320,6 +323,6 @@ public static LocalRegion create(LocalRegionParams params) throws IOException {
320323
LOG.warn("Failed to create archive directory {}. Usually this should not happen but it will" +
321324
" be created again when we actually archive the hfiles later, so continue", archiveDir);
322325
}
323-
return new LocalRegion(region, walFactory, flusherAndCompactor, walRoller);
326+
return new MasterRegion(region, walFactory, flusherAndCompactor, walRoller);
324327
}
325328
}

hbase-server/src/main/java/org/apache/hadoop/hbase/master/store/LocalStore.java renamed to hbase-server/src/main/java/org/apache/hadoop/hbase/master/region/MasterRegionFactory.java

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,24 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package org.apache.hadoop.hbase.master.store;
18+
package org.apache.hadoop.hbase.master.region;
1919

2020
import java.io.IOException;
2121
import java.util.concurrent.TimeUnit;
2222
import org.apache.hadoop.conf.Configuration;
2323
import org.apache.hadoop.hbase.Server;
2424
import org.apache.hadoop.hbase.TableName;
2525
import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
26-
import org.apache.hadoop.hbase.client.Get;
27-
import org.apache.hadoop.hbase.client.Result;
28-
import org.apache.hadoop.hbase.client.Scan;
2926
import org.apache.hadoop.hbase.client.TableDescriptor;
3027
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
31-
import org.apache.hadoop.hbase.regionserver.HRegion.FlushResult;
32-
import org.apache.hadoop.hbase.regionserver.RegionScanner;
3328
import org.apache.hadoop.hbase.util.Bytes;
3429
import org.apache.yetus.audience.InterfaceAudience;
3530

36-
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
37-
3831
/**
39-
* Used for storing data at master side. The data will be stored in a {@link LocalRegion}.
32+
* The factory class for creating a {@link MasterRegion}.
4033
*/
4134
@InterfaceAudience.Private
42-
public final class LocalStore {
35+
public final class MasterRegionFactory {
4336

4437
// Use the character $ to let the log cleaner know that this is not the normal wal file.
4538
public static final String ARCHIVED_WAL_SUFFIX = "$masterlocalwal$";
@@ -89,45 +82,8 @@ public final class LocalStore {
8982
private static final TableDescriptor TABLE_DESC = TableDescriptorBuilder.newBuilder(TABLE_NAME)
9083
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(PROC_FAMILY)).build();
9184

92-
private final LocalRegion region;
93-
94-
private LocalStore(LocalRegion region) {
95-
this.region = region;
96-
}
97-
98-
public void update(UpdateLocalRegion action) throws IOException {
99-
region.update(action);
100-
}
101-
102-
public Result get(Get get) throws IOException {
103-
return region.get(get);
104-
}
105-
106-
public RegionScanner getScanner(Scan scan) throws IOException {
107-
return region.getScanner(scan);
108-
}
109-
110-
public void close(boolean abort) {
111-
region.close(abort);
112-
}
113-
114-
@VisibleForTesting
115-
public FlushResult flush(boolean force) throws IOException {
116-
return region.flush(force);
117-
}
118-
119-
@VisibleForTesting
120-
public void requestRollAll() {
121-
region.requestRollAll();
122-
}
123-
124-
@VisibleForTesting
125-
public void waitUntilWalRollFinished() throws InterruptedException {
126-
region.waitUntilWalRollFinished();
127-
}
128-
129-
public static LocalStore create(Server server) throws IOException {
130-
LocalRegionParams params = new LocalRegionParams().server(server)
85+
public static MasterRegion create(Server server) throws IOException {
86+
MasterRegionParams params = new MasterRegionParams().server(server)
13187
.regionDirName(MASTER_STORE_DIR).tableDescriptor(TABLE_DESC);
13288
Configuration conf = server.getConfiguration();
13389
long flushSize = conf.getLong(FLUSH_SIZE_KEY, DEFAULT_FLUSH_SIZE);
@@ -145,7 +101,6 @@ public static LocalStore create(Server server) throws IOException {
145101
long rollPeriodMs = conf.getLong(ROLL_PERIOD_MS_KEY, DEFAULT_ROLL_PERIOD_MS);
146102
params.rollPeriodMs(rollPeriodMs).archivedWalSuffix(ARCHIVED_WAL_SUFFIX)
147103
.archivedHFileSuffix(ARCHIVED_HFILE_SUFFIX);
148-
LocalRegion region = LocalRegion.create(params);
149-
return new LocalStore(region);
104+
return MasterRegion.create(params);
150105
}
151106
}

0 commit comments

Comments
 (0)