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
2020import static org .apache .hadoop .hbase .HConstants .HREGION_LOGDIR_NAME ;
2121
5454import 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 *
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}
0 commit comments