diff --git a/src/main/java/org/apache/hadoop/hbase/HConstants.java b/src/main/java/org/apache/hadoop/hbase/HConstants.java
index 485006b..e85d4ee 100644
--- a/src/main/java/org/apache/hadoop/hbase/HConstants.java
+++ b/src/main/java/org/apache/hadoop/hbase/HConstants.java
@@ -66,6 +66,11 @@ public final class HConstants {
// Configuration parameters
+ /**
+ * Default block size for an HFile.
+ */
+ public final static int DEFAULT_BLOCKSIZE = 64 * 1024;
+
//TODO: Is having HBase homed on port 60k OK?
/** Cluster is in distributed mode or not */
diff --git a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 52dedc2..9cbdab7 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -107,6 +107,7 @@ import org.apache.hadoop.hbase.snapshot.SnapshotDescriptionUtils;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSTableDescriptors;
+import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.util.HFileArchiveUtil;
import org.apache.hadoop.hbase.util.HasThread;
import org.apache.hadoop.hbase.util.InfoServer;
@@ -268,6 +269,7 @@ Server {
this.conf = new Configuration(conf);
// Disable the block cache on the master
this.conf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0.0f);
+ FSUtils.setupShortCircuitRead(conf);
// Set how many times to retry talking to another server over HConnection.
HConnectionManager.setServerSideHConnectionRetries(this.conf, LOG);
// Server to handle client requests.
diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 003b351..10a550f 100644
--- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -208,7 +208,6 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
protected final AtomicBoolean haveRootRegion = new AtomicBoolean(false);
private HFileSystem fs;
- private boolean useHBaseChecksum; // verify hbase checksums?
private Path rootDir;
private final Random rand = new Random();
@@ -395,10 +394,7 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
this.isOnline = false;
checkCodecs(this.conf);
- // do we use checksum verfication in the hbase? If hbase checksum verification
- // is enabled, then we automatically switch off hdfs checksum verification.
- this.useHBaseChecksum = conf.getBoolean(
- HConstants.HBASE_CHECKSUM_VERIFICATION, false);
+ FSUtils.setupShortCircuitRead(this.conf);
// Config'ed params
this.numRetries = conf.getInt("hbase.client.retries.number", 10);
@@ -1061,8 +1057,10 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler,
// accessors will be going against wrong filesystem (unless all is set
// to defaults).
this.conf.set("fs.defaultFS", this.conf.get("hbase.rootdir"));
- // Get fs instance used by this RS
- this.fs = new HFileSystem(this.conf, this.useHBaseChecksum);
+ // Get fs instance used by this RS. Do we use checksum verification in the hbase? If hbase
+ // checksum verification enabled, then automatically switch off hdfs checksum verification.
+ boolean useHBaseChecksum = conf.getBoolean(HConstants.HBASE_CHECKSUM_VERIFICATION, true);
+ this.fs = new HFileSystem(this.conf, useHBaseChecksum);
this.rootDir = new Path(this.conf.get(HConstants.HBASE_DIR));
this.tableDescriptors = new FSTableDescriptors(this.fs, this.rootDir, true);
this.hlog = setupWALAndReplication();
diff --git a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
index 6ab6a1a..2c7ac6b 100644
--- a/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
+++ b/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
@@ -1385,4 +1385,40 @@ public abstract class FSUtils {
}
}
}
-}
+
+ /**
+ * Do our short circuit read setup.
+ * Checks buffer size to use and whether to do checksumming in hbase or hdfs.
+ * @param conf
+ */
+ public static void setupShortCircuitRead(final Configuration conf) {
+ // Check that the user has not set the "dfs.client.read.shortcircuit.skip.checksum" property.
+ boolean shortCircuitSkipChecksum =
+ conf.getBoolean("dfs.client.read.shortcircuit.skip.checksum", false);
+ boolean useHBaseChecksum = conf.getBoolean(HConstants.HBASE_CHECKSUM_VERIFICATION, true);
+ if (shortCircuitSkipChecksum) {
+ LOG.warn("Configuration \"dfs.client.read.shortcircuit.skip.checksum\" should not " +
+ "be set to true." + (useHBaseChecksum ? " HBase checksum doesn't require " +
+ "it, see https://issues.apache.org/jira/browse/HBASE-6868." : ""));
+ assert !shortCircuitSkipChecksum; //this will fail if assertions are on
+ }
+ checkShortCircuitReadBufferSize(conf);
+ }
+
+ /**
+ * Check if short circuit read buffer size is set and if not, set it to hbase value.
+ * @param conf
+ */
+ public static void checkShortCircuitReadBufferSize(final Configuration conf) {
+ final int defaultSize = HConstants.DEFAULT_BLOCKSIZE * 2;
+ final int notSet = -1;
+ // DFSConfigKeys.DFS_CLIENT_READ_SHORTCIRCUIT_BUFFER_SIZE_KEY is only defined in h2
+ final String dfsKey = "dfs.client.read.shortcircuit.buffer.size";
+ int size = conf.getInt(dfsKey, notSet);
+ // If a size is set, return -- we will use it.
+ if (size != notSet) return;
+ // But short circuit buffer size is normally not set. Put in place the hbase wanted size.
+ int hbaseSize = conf.getInt("hbase." + dfsKey, defaultSize);
+ conf.setIfUnset(dfsKey, Integer.toString(hbaseSize));
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/hbase-default.xml b/src/main/resources/hbase-default.xml
index b375ecf..856c46e 100644
--- a/src/main/resources/hbase-default.xml
+++ b/src/main/resources/hbase-default.xml
@@ -157,6 +157,20 @@
+ hbase.dfs.client.read.shortcircuit.buffer.size
+ 131072
+ If the DFSClient configuration
+ dfs.client.read.shortcircuit.buffer.size is unset, we will
+ use what is configured here as the short circuit read default
+ direct byte buffer size. DFSClient native default is 1MB; HBase
+ keeps its HDFS files open so number of file blocks * 1MB soon
+ starts to add up and threaten OOME because of a shortage of
+ direct memory. So, we set it down from the default. Make
+ it > the default hbase block size set in the HColumnDescriptor
+ which is usually 64k.
+
+
+
hbase.client.keyvalue.maxsize
10485760
Specifies the combined maximum allowed size of a KeyValue