HBASE-24086 Disable output stream capability enforcement when running on LocalFileSystem

Signed-off-by: stack <stack@apache.org>
Signed-off-by: Bharath Vissapragada <bharathv@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>

Backport to branch-1

Co-authored-by: Andrew Purtell <apurtell@apache.org>
This commit is contained in:
Nick Dimiduk 2020-04-01 11:25:39 -07:00 committed by Andrew Purtell
parent b644e3ccd8
commit 03d73f151b
No known key found for this signature in database
GPG Key ID: 8597754DD5365CCD
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/**
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@ -39,6 +39,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.LocatedFileStatus;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.PathFilter;
@ -346,11 +347,20 @@ public abstract class CommonFSUtils {
public static FileSystem getWALFileSystem(final Configuration c) throws IOException {
Path p = getWALRootDir(c);
FileSystem fs = p.getFileSystem(c);
// hadoop-core does fs caching, so need to propogate this if set
// hadoop-core does fs caching, so need to propagate this if set
String enforceStreamCapability = c.get(UNSAFE_STREAM_CAPABILITY_ENFORCE);
if (enforceStreamCapability != null) {
fs.getConf().set(UNSAFE_STREAM_CAPABILITY_ENFORCE, enforceStreamCapability);
}
if (fs instanceof LocalFileSystem) {
// running on LocalFileSystem, which does not support the required capabilities `HSYNC`
// and `HFLUSH`. disable enforcement.
final boolean value = false;
LOG.warn("Cannot enforce durability guarantees while running on " + fs.getUri()
+ ". Setting " + UNSAFE_STREAM_CAPABILITY_ENFORCE + "=" + value
+ " for this FileSystem.");
fs.getConf().setBoolean(UNSAFE_STREAM_CAPABILITY_ENFORCE, value);
}
return fs;
}