HBASE-12848 Utilize Flash storage for WAL
This commit is contained in:
parent
da2a3827fa
commit
2e08bb3b47
|
@ -910,6 +910,16 @@ public final class HConstants {
|
|||
public static final String ENABLE_WAL_COMPRESSION =
|
||||
"hbase.regionserver.wal.enablecompression";
|
||||
|
||||
/** Configuration name of WAL storage policy
|
||||
* Valid values are:
|
||||
* NONE: no preference in destination of replicas
|
||||
* ONE_SSD: place only one replica in SSD and the remaining in default storage
|
||||
* and ALL_SSD: place all replica on SSD
|
||||
*
|
||||
* See http://hadoop.apache.org/docs/r2.6.0/hadoop-project-dist/hadoop-hdfs/ArchivalStorage.html*/
|
||||
public static final String WAL_STORAGE_POLICY = "hbase.wal.storage.policy";
|
||||
public static final String DEFAULT_WAL_STORAGE_POLICY = "NONE";
|
||||
|
||||
/** Region in Transition metrics threshold time */
|
||||
public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD="hbase.metrics.rit.stuck.warning.threshold";
|
||||
|
||||
|
|
|
@ -492,6 +492,8 @@ public class FSHLog implements WAL {
|
|||
throw new IllegalArgumentException("wal suffix must start with '" + WAL_FILE_NAME_DELIMITER +
|
||||
"' but instead was '" + suffix + "'");
|
||||
}
|
||||
FSUtils.setStoragePolicy(fs, conf, this.fullPathLogDir, HConstants.WAL_STORAGE_POLICY,
|
||||
HConstants.DEFAULT_WAL_STORAGE_POLICY);
|
||||
this.logFileSuffix = (suffix == null) ? "" : URLEncoder.encode(suffix, "UTF8");
|
||||
this.prefixPathStr = new Path(fullPathLogDir,
|
||||
logFilePrefix + WAL_FILE_NAME_DELIMITER).toString();
|
||||
|
|
|
@ -100,6 +100,45 @@ public abstract class FSUtils {
|
|||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets storage policy for given path according to config setting
|
||||
* @param fs
|
||||
* @param conf
|
||||
* @param path the Path whose storage policy is to be set
|
||||
* @param policyKey
|
||||
* @param defaultPolicy
|
||||
*/
|
||||
public static void setStoragePolicy(final FileSystem fs, final Configuration conf,
|
||||
final Path path, final String policyKey, final String defaultPolicy) {
|
||||
String storagePolicy = conf.get(policyKey, defaultPolicy).toUpperCase();
|
||||
if (!storagePolicy.equals(defaultPolicy) &&
|
||||
fs instanceof DistributedFileSystem) {
|
||||
DistributedFileSystem dfs = (DistributedFileSystem)fs;
|
||||
Class<? extends DistributedFileSystem> dfsClass = dfs.getClass();
|
||||
Method m = null;
|
||||
try {
|
||||
m = dfsClass.getDeclaredMethod("setStoragePolicy",
|
||||
new Class<?>[] { Path.class, String.class });
|
||||
m.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
LOG.info("FileSystem doesn't support"
|
||||
+ " setStoragePolicy; --HDFS-7228 not available");
|
||||
} catch (SecurityException e) {
|
||||
LOG.info("Doesn't have access to setStoragePolicy on "
|
||||
+ "FileSystems --HDFS-7228 not available", e);
|
||||
m = null; // could happen on setAccessible()
|
||||
}
|
||||
if (m != null) {
|
||||
try {
|
||||
m.invoke(dfs, path, storagePolicy);
|
||||
LOG.info("set " + storagePolicy + " for " + path);
|
||||
} catch (Exception e) {
|
||||
LOG.warn("Unable to set " + storagePolicy + " for " + path, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare of path component. Does not consider schema; i.e. if schemas different but <code>path
|
||||
* <code> starts with <code>rootPath<code>, then the function returns true
|
||||
|
|
Loading…
Reference in New Issue