HBASE-20986 Separate the config of block size when we do log splitting and write Hlog

Signed-off-by: Guanghao Zhang <zghao@apache.org>
This commit is contained in:
jingyuntian 2018-08-03 16:10:56 +08:00 committed by Guanghao Zhang
parent bd30ca62ef
commit bd01fa7639
2 changed files with 19 additions and 3 deletions

View File

@ -180,8 +180,21 @@ public class WALUtil {
*/ */
public static long getWALBlockSize(Configuration conf, FileSystem fs, Path dir) public static long getWALBlockSize(Configuration conf, FileSystem fs, Path dir)
throws IOException { throws IOException {
return conf.getLong("hbase.regionserver.hlog.blocksize", return getWALBlockSize(conf, fs, dir, false);
CommonFSUtils.getDefaultBlockSize(fs, dir) * 2); }
/**
* 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);
} }
public static void filterCells(WALEdit edit, Function<Cell, Cell> mapper) { public static void filterCells(WALEdit edit, Function<Cell, Cell> mapper) {

View File

@ -55,10 +55,13 @@ public class FSHLogProvider extends AbstractFSWALProvider<FSHLog> {
/** /**
* Public because of FSHLog. Should be package-private * 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, public static Writer createWriter(final Configuration conf, final FileSystem fs, final Path path,
final boolean overwritable) throws IOException { 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));
} }
/** /**