You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2013/01/07 20:19:01 UTC
svn commit: r1429973 - in /hbase/branches/0.89-fb: bin/
src/main/java/org/apache/hadoop/hbase/
src/main/java/org/apache/hadoop/hbase/client/
src/main/java/org/apache/hadoop/hbase/ipc/
src/main/java/org/apache/hadoop/hbase/regionserver/
Author: liyin
Date: Mon Jan 7 19:19:01 2013
New Revision: 1429973
URL: http://svn.apache.org/viewvc?rev=1429973&view=rev
Log:
[89-fb] [HBASE-7509] Regionserver support to control quorum reads
Author: aaiyer
Summary:
It will be good to have the ability to control the
paramaters for quorum reads while the regionserver is still running.
We want to control:
1) the timeout that we wait for, before initiating the second read.
2) number of threads allocated for quorum reads
- setting this to 0 will disable quorum reads
Depends on the quorum diff in HDFS to add the DFSClient calls.
https://phabricator.fb.com/D615354
Will not commit this until alligator is updated. But, putting out
for review together.
Notes for Amit: (Will not be part of the commit)
b398400e7b11 remove src/main/java/org/apache/hadoop/hbase/client/ParallelHDFSReads.java
0ecb342447e2 lint errors
4e609ef08613 add a ruby script to manage quorum reads
d3e5cb243c06 control timeout as well
20bd6254ad8a revert HMasterInterface
7378e5e30541 rename function in setNumQuorumReadThreadsForHDFS -> setNumHDFSQuorumReadThreads
cf443b6c65f7 regionserver support
Test Plan: deploy to dev cluster and set the params on the fly
Reviewers: liyintang, kannan, kranganathan
Reviewed By: liyintang
CC: hbase-eng@, sdong, hkuang, hdfs-dev@
Differential Revision: https://phabricator.fb.com/D635914
Added:
hbase/branches/0.89-fb/bin/manage_dfs_quorum_reads.rb
Modified:
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Added: hbase/branches/0.89-fb/bin/manage_dfs_quorum_reads.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/bin/manage_dfs_quorum_reads.rb?rev=1429973&view=auto
==============================================================================
--- hbase/branches/0.89-fb/bin/manage_dfs_quorum_reads.rb (added)
+++ hbase/branches/0.89-fb/bin/manage_dfs_quorum_reads.rb Mon Jan 7 19:19:01 2013
@@ -0,0 +1,102 @@
+#
+# Copyright 2009 The Apache Software Foundation
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Script will be used to stop a regionserver and flag to the master that it is going down for a restart
+#
+# To see usage for this script, run:
+#
+# ${HBASE_HOME}/bin/hbase org.jruby.Main stop_regionserver_for_restart.rb
+#
+include Java
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.hbase.ClusterStatus
+import org.apache.hadoop.hbase.HBaseConfiguration
+import org.apache.hadoop.hbase.HServerInfo
+import org.apache.hadoop.hbase.HServerAddress
+import org.apache.hadoop.hbase.client.HBaseAdmin
+import org.apache.hadoop.hbase.util.Bytes
+import org.apache.hadoop.hbase.HConstants
+import org.apache.commons.logging.LogFactory
+import java.net.InetAddress
+
+# Name of this script
+NAME = "manage_dfs_quorum_reads"
+
+# Print usage for this script
+def usage
+ puts 'Usage: %s.rb' % NAME '<setNumThreads | setTimeout> <value>'
+ exit!
+end
+
+# Check arguments
+if ARGV.size != 2
+ usage
+end
+
+command = ARGV[0]
+value = ARGV[1]
+if command != 'setNumThreads' && command != 'setTimeout'
+ usage
+end
+
+# Get configuration to use.
+c = HBaseConfiguration.create()
+
+# Taken from add_table.rb script
+# Set hadoop filesystem configuration using the hbase.rootdir.
+# Otherwise, we'll always use localhost though the hbase.rootdir
+# might be pointing at hdfs location.
+c.set("fs.default.name", c.get(HConstants::HBASE_DIR))
+
+# Get a logger instance.
+LOG = LogFactory.getLog(NAME)
+
+# get the admin interface
+admin = HBaseAdmin.new(c)
+
+hostname = InetAddress.getLocalHost().getHostName()
+port = c.getInt("hbase.regionserver.port", 0)
+
+if port > 0
+ address = HServerAddress.new(hostname, port)
+else
+ address = nil
+
+ # get the cluster servers
+ servers = admin.getClusterStatus().getServerInfo()
+
+ servers.each do |server|
+ if server.getServerAddress().getHostname() == InetAddress.getLocalHost().getHostName()
+ address = server.getServerAddress()
+ break
+ end
+ end
+end
+
+if address == nil
+ puts "invalid server"
+ exit
+end
+
+if command == 'setNumThreads'
+ admin.setNumHDFSQuorumReadThreads(value)
+else
+ admin.setHDFSQuorumReadTimeoutMillis(value)
+end
+
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=1429973&r1=1429972&r2=1429973&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/HConstants.java Mon Jan 7 19:19:01 2013
@@ -274,6 +274,19 @@ public final class HConstants {
public static final String HREGIONSERVER_SPLITLOG_WORKERS_NUM =
"hbase.hregionserver.hlog.split.workers.num";
+ /**
+ * If using quorum reads from HDFS, the maximum size of the thread pool.
+ * value <= 0 disables quorum reads.
+ */
+ public static final String HDFS_QUORUM_READ_THREADS_MAX =
+ "hbase.dfsclient.quorum.reads.threads.max";
+
+ /**
+ * The default number for the size of thread pool used in quorum reads.
+ * value <= 0 disables quorum reads.
+ */
+ public static final int DEFAULT_HDFS_QUORUM_READ_THREADS_MAX = 50;
+
/** Default maximum file size */
public static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024;
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=1429973&r1=1429972&r2=1429973&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Mon Jan 7 19:19:01 2013
@@ -1269,6 +1269,44 @@ public class HBaseAdmin {
}
/**
+ * Set the number of threads to be used for HDFS quorum reads.
+ *
+ * @param hsa
+ * the address of the RegionServer to stop
+ * @param numThreads
+ * the number of threads to be used for HDFS quorum reads
+ * <= 0 will disable quorum Reads.
+ * @throws IOException
+ * if a remote or network exception occurs
+ */
+ public synchronized void setNumHDFSQuorumReadThreads(final HServerAddress hsa,
+ int numThreads) throws IOException {
+ HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+ LOG.info("Setting numHDFSQuorumReadThreads for RegionServer" + hsa.toString()
+ + " to " + numThreads);
+ rs.setNumHDFSQuorumReadThreads(numThreads);
+ }
+
+ /**
+ * Set the number of threads to be used for HDFS quorum reads.
+ *
+ * @param hsa
+ * the address of the RegionServer to stop
+ * @param numThreads
+ * the number of threads to be used for HDFS quorum reads
+ * <= 0 will disable quorum Reads.
+ * @throws IOException
+ * if a remote or network exception occurs
+ */
+ public synchronized void setHDFSQuorumReadTimeoutMillis(final HServerAddress hsa,
+ long timeoutMillis) throws IOException {
+ HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+ LOG.info("Setting quorumReadTimeout for RegionServer" + hsa.toString()
+ + " to " + timeoutMillis);
+ rs.setHDFSQuorumReadTimeoutMillis(timeoutMillis);
+ }
+
+ /**
* @return cluster status
* @throws IOException
* if a remote or network exception occurs
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=1429973&r1=1429972&r2=1429973&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Mon Jan 7 19:19:01 2013
@@ -410,4 +410,21 @@ public interface HRegionInterface extend
/** @return why we are stopping */
String getStopReason();
+
+ /**
+ * Set the number of threads to be used for HDFS Quorum reads
+ *
+ * @param maxThreads. quourm reads will be disabled if set to <= 0
+ *
+ */
+ public void setNumHDFSQuorumReadThreads(int maxThreads);
+
+ /**
+ * Set the amount of time we wait before initiating a second read when
+ * using HDFS Quorum reads
+ *
+ * @param timeoutMillis.
+ *
+ */
+ public void setHDFSQuorumReadTimeoutMillis(long timeoutMillis);
}
Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1429973&r1=1429972&r2=1429973&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Mon Jan 7 19:19:01 2013
@@ -142,6 +142,8 @@ import org.apache.hadoop.hbase.util.Runt
import org.apache.hadoop.hbase.util.Sleeper;
import org.apache.hadoop.hbase.util.Threads;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWrapper;
+import org.apache.hadoop.hdfs.DFSClient;
+import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.hadoop.io.BytesWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.MapWritable;
@@ -450,6 +452,11 @@ public class HRegionServer implements HR
return t;
}
});
+
+ int parallelHDFSReadPoolSize = conf.getInt(HConstants.HDFS_QUORUM_READ_THREADS_MAX,
+ HConstants.DEFAULT_HDFS_QUORUM_READ_THREADS_MAX);
+ LOG.debug("parallelHDFSReadPoolSize is (for quorum)" + parallelHDFSReadPoolSize);
+ this.setNumHDFSQuorumReadThreads(parallelHDFSReadPoolSize);
}
/**
@@ -2825,6 +2832,33 @@ public class HRegionServer implements HR
region.bulkLoadHFile(hfilePath, familyName, assignSeqNum);
}
+ @Override
+ public void setNumHDFSQuorumReadThreads(int maxThreads) {
+ LOG.debug("Setting setNumHDFSQuorumReadThreads to " + maxThreads);
+ DFSClient client = null;
+ if (this.fs instanceof DistributedFileSystem) {
+ client = ((DistributedFileSystem)fs).getClient();
+
+ if (maxThreads > 0) {
+ client.enableParallelReads();
+ client.setNumParallelThreadsForReads(maxThreads);
+ } else {
+ client.disableParallelReads();
+ }
+ }
+ }
+
+ @Override
+ public void setHDFSQuorumReadTimeoutMillis(long timeoutMillis) {
+ LOG.debug("Setting setHDFSQuorumReadTimeoutMillis to " + timeoutMillis + " ms.");
+ DFSClient client;
+ if (this.fs instanceof DistributedFileSystem) {
+ client = ((DistributedFileSystem)fs).getClient();
+
+ client.setQuorumReadTimeout(timeoutMillis);
+ }
+ }
+
Map<String, Integer> rowlocks =
new ConcurrentHashMap<String, Integer>();