From 9d594ac86ad815c50fce411f92ec6d37fddc428d Mon Sep 17 00:00:00 2001 From: jingyuntian Date: Fri, 3 Aug 2018 16:10:56 +0800 Subject: [PATCH] HBASE-20986 Separate the config of block size when we do log splitting and write Hlog Signed-off-by: Guanghao Zhang --- .../hadoop/hbase/regionserver/wal/WALUtil.java | 17 +++++++++++++++-- .../apache/hadoop/hbase/wal/FSHLogProvider.java | 5 ++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALUtil.java index 1b17adc90ca..09920896cfa 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALUtil.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALUtil.java @@ -176,7 +176,20 @@ public class WALUtil { */ public static long getWALBlockSize(Configuration conf, FileSystem fs, Path dir) throws IOException { - return conf.getLong("hbase.regionserver.hlog.blocksize", - CommonFSUtils.getDefaultBlockSize(fs, dir) * 2); + return getWALBlockSize(conf, fs, dir, false); + } + + /** + * Public because of FSHLog. Should be package-private + * @param isRecoverEdits the created writer is for recovered edits or WAL. For recovered edits, it + * is true and for WAL it is false. + */ + public static long getWALBlockSize(Configuration conf, FileSystem fs, Path dir, + boolean isRecoverEdits) throws IOException { + long defaultBlockSize = CommonFSUtils.getDefaultBlockSize(fs, dir) * 2; + if (isRecoverEdits) { + return conf.getLong("hbase.regionserver.recoverededits.blocksize", defaultBlockSize); + } + return conf.getLong("hbase.regionserver.hlog.blocksize", defaultBlockSize); } } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/FSHLogProvider.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/FSHLogProvider.java index 44f692d620f..7cd39ea788e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/FSHLogProvider.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/wal/FSHLogProvider.java @@ -55,10 +55,13 @@ public class FSHLogProvider extends AbstractFSWALProvider { /** * Public because of FSHLog. Should be package-private + * @param overwritable if the created writer can overwrite. For recovered edits, it is true and + * for WAL it is false. Thus we can distinguish WAL and recovered edits by this. */ public static Writer createWriter(final Configuration conf, final FileSystem fs, final Path path, final boolean overwritable) throws IOException { - return createWriter(conf, fs, path, overwritable, WALUtil.getWALBlockSize(conf, fs, path)); + return createWriter(conf, fs, path, overwritable, + WALUtil.getWALBlockSize(conf, fs, path, overwritable)); } /**