HBASE-6783 Make read short circuit the default
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1388374 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
95661b40ed
commit
c49ee963e6
|
@ -481,6 +481,42 @@ public class HBaseTestingUtility {
|
||||||
createDirAndSetProperty("mapred_local", "mapred.local.dir");
|
createDirAndSetProperty("mapred_local", "mapred.local.dir");
|
||||||
createDirAndSetProperty("mapred_system", "mapred.system.dir");
|
createDirAndSetProperty("mapred_system", "mapred.system.dir");
|
||||||
createDirAndSetProperty("mapred_temp", "mapred.temp.dir");
|
createDirAndSetProperty("mapred_temp", "mapred.temp.dir");
|
||||||
|
enableShortCircuit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the HBase setting for dfs.client.read.shortcircuit from the conf or a system property.
|
||||||
|
* This allows to specify this parameter on the command line.
|
||||||
|
* If not set, default is true.
|
||||||
|
*/
|
||||||
|
public boolean isReadShortCircuitOn(){
|
||||||
|
final String propName = "hbase.tests.use.shortcircuit.reads";
|
||||||
|
String readOnProp = System.getProperty(propName);
|
||||||
|
if (readOnProp != null){
|
||||||
|
return Boolean.parseBoolean(readOnProp);
|
||||||
|
} else {
|
||||||
|
return conf.getBoolean(propName, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Enable the short circuit read, unless configured differently.
|
||||||
|
* Set both HBase and HDFS settings, including skipping the hdfs checksum checks.
|
||||||
|
*/
|
||||||
|
private void enableShortCircuit() {
|
||||||
|
if (isReadShortCircuitOn()) {
|
||||||
|
String curUser = System.getProperty("user.name");
|
||||||
|
LOG.info("read short circuit is ON for user " + curUser);
|
||||||
|
// read short circuit, for hdfs
|
||||||
|
conf.set("dfs.block.local-path-access.user", curUser);
|
||||||
|
// read short circuit, for hbase
|
||||||
|
conf.setBoolean("dfs.client.read.shortcircuit", true);
|
||||||
|
// Skip checking checksum, for the hdfs client and the datanode
|
||||||
|
conf.setBoolean("dfs.client.read.shortcircuit.skip.checksum", true);
|
||||||
|
} else {
|
||||||
|
LOG.info("read short circuit is OFF");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createDirAndSetProperty(final String relPath, String property) {
|
private String createDirAndSetProperty(final String relPath, String property) {
|
||||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.io.hfile.HFileScanner;
|
||||||
import org.apache.hadoop.hbase.io.hfile.NoOpDataBlockEncoder;
|
import org.apache.hadoop.hbase.io.hfile.NoOpDataBlockEncoder;
|
||||||
import org.apache.hadoop.hbase.regionserver.StoreFile.BloomType;
|
import org.apache.hadoop.hbase.regionserver.StoreFile.BloomType;
|
||||||
import org.apache.hadoop.hbase.util.Bytes;
|
import org.apache.hadoop.hbase.util.Bytes;
|
||||||
|
import org.junit.Assume;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
|
@ -163,6 +164,10 @@ public class TestFSErrorsExposed {
|
||||||
*/
|
*/
|
||||||
@Test(timeout=5 * 60 * 1000)
|
@Test(timeout=5 * 60 * 1000)
|
||||||
public void testFullSystemBubblesFSErrors() throws Exception {
|
public void testFullSystemBubblesFSErrors() throws Exception {
|
||||||
|
// We won't have an error if the datanode is not there if we use short circuit
|
||||||
|
// it's a known 'feature'.
|
||||||
|
Assume.assumeTrue(!util.isReadShortCircuitOn());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// We set it not to run or it will trigger server shutdown while sync'ing
|
// We set it not to run or it will trigger server shutdown while sync'ing
|
||||||
// because all the datanodes are bad
|
// because all the datanodes are bad
|
||||||
|
|
Loading…
Reference in New Issue