You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by nk...@apache.org on 2012/09/21 10:40:24 UTC
svn commit: r1388374 - in
/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase:
HBaseTestingUtility.java regionserver/TestFSErrorsExposed.java
Author: nkeywal
Date: Fri Sep 21 08:40:23 2012
New Revision: 1388374
URL: http://svn.apache.org/viewvc?rev=1388374&view=rev
Log:
HBASE-6783 Make read short circuit the default
Modified:
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=1388374&r1=1388373&r2=1388374&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Fri Sep 21 08:40:23 2012
@@ -481,6 +481,42 @@ public class HBaseTestingUtility {
createDirAndSetProperty("mapred_local", "mapred.local.dir");
createDirAndSetProperty("mapred_system", "mapred.system.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) {
Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java?rev=1388374&r1=1388373&r2=1388374&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java (original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java Fri Sep 21 08:40:23 2012
@@ -46,6 +46,7 @@ import org.apache.hadoop.hbase.io.hfile.
import org.apache.hadoop.hbase.io.hfile.NoOpDataBlockEncoder;
import org.apache.hadoop.hbase.regionserver.StoreFile.BloomType;
import org.apache.hadoop.hbase.util.Bytes;
+import org.junit.Assume;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -163,6 +164,10 @@ public class TestFSErrorsExposed {
*/
@Test(timeout=5 * 60 * 1000)
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 {
// We set it not to run or it will trigger server shutdown while sync'ing
// because all the datanodes are bad