Skip to content

Commit 33362aa

Browse files
author
Prathyusha Garre
committed
HBASE-29662 - Avoid regionDir/tableDir creation as part of .regioninfo file creation in HRegion initialize
1 parent 47f7e1d commit 33362aa

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ private static void writeRegionInfoFileContent(final Configuration conf, final F
764764
// First check to get the permissions
765765
FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);
766766
// Write the RegionInfo file content
767-
try (FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null)) {
767+
try (FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null, false)) {
768768
out.write(content);
769769
}
770770
}

hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,14 +212,44 @@ public static boolean deleteRegionDir(final Configuration conf, final RegionInfo
212212
*/
213213
public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path path,
214214
FsPermission perm, InetSocketAddress[] favoredNodes) throws IOException {
215+
return create(conf, fs, path, perm, favoredNodes, true);
216+
}
217+
218+
/**
219+
* Create the specified file on the filesystem. By default, this will:
220+
* <ol>
221+
* <li>overwrite the file if it exists</li>
222+
* <li>apply the umask in the configuration (if it is enabled)</li>
223+
* <li>use the fs configured buffer size (or 4096 if not set)</li>
224+
* <li>use the configured column family replication or default replication if
225+
* {@link ColumnFamilyDescriptorBuilder#DEFAULT_DFS_REPLICATION}</li>
226+
* <li>use the default block size</li>
227+
* <li>not track progress</li>
228+
* </ol>
229+
* @param conf configurations
230+
* @param fs {@link FileSystem} on which to write the file
231+
* @param path {@link Path} to the file to write
232+
* @param perm permissions
233+
* @param favoredNodes favored data nodes
234+
* @param isRecursiveCreate recursively create parent directories
235+
* @return output stream to the created file
236+
* @throws IOException if the file cannot be created
237+
*/
238+
public static FSDataOutputStream create(Configuration conf, FileSystem fs, Path path,
239+
FsPermission perm, InetSocketAddress[] favoredNodes, boolean isRecursiveCreate)
240+
throws IOException {
215241
if (fs instanceof HFileSystem) {
216242
FileSystem backingFs = ((HFileSystem) fs).getBackingFs();
217243
if (backingFs instanceof DistributedFileSystem) {
218244
short replication = Short.parseShort(conf.get(ColumnFamilyDescriptorBuilder.DFS_REPLICATION,
219245
String.valueOf(ColumnFamilyDescriptorBuilder.DEFAULT_DFS_REPLICATION)));
220-
DistributedFileSystem.HdfsDataOutputStreamBuilder builder =
221-
((DistributedFileSystem) backingFs).createFile(path).recursive().permission(perm)
222-
.create();
246+
DistributedFileSystem.HdfsDataOutputStreamBuilder builder = null;
247+
if (isRecursiveCreate) {
248+
builder = ((DistributedFileSystem) backingFs).createFile(path).recursive()
249+
.permission(perm).create();
250+
} else {
251+
builder = ((DistributedFileSystem) backingFs).createFile(path).permission(perm).create();
252+
}
223253
if (favoredNodes != null) {
224254
builder.favoredNodes(favoredNodes);
225255
}

0 commit comments

Comments
 (0)