diff --git a/CHANGES.txt b/CHANGES.txt
index a4d6d8fcb8d..46e2a6afe23 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -440,6 +440,9 @@ Release 0.21.0 - Unreleased
edits ordered by sequenceid
HBASE-2843 Readd bloomfilter test over zealously removed by HBASE-2625
HBASE-2846 Make rest server be same as thrift and avro servers
+ HBASE-1511 Pseudo distributed mode in LocalHBaseCluster
+ (Nicolas Spiegelberg via Stack)
+
IMPROVEMENTS
HBASE-1760 Cleanup TODOs in HTable
diff --git a/bin/local-master-backup.sh b/bin/local-master-backup.sh
new file mode 100644
index 00000000000..e08a736d909
--- /dev/null
+++ b/bin/local-master-backup.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# This is used for starting multiple masters on the same machine.
+# run it from hbase-dir/ just like 'bin/hbase'
+# Supports up to 10 masters (limitation = overlapping ports)
+
+bin=`dirname "$0"`
+bin=`cd "$bin" >/dev/null && pwd`
+
+if [ $# -lt 2 ]; then
+ S=`basename $0`
+ echo "Usage: $S [start|stop] offset(s)"
+ echo ""
+ echo " e.g. $S start 1"
+ exit
+fi
+
+# sanity check: make sure your master opts don't use ports [i.e. JMX/DBG]
+export HBASE_MASTER_OPTS=" "
+
+run_master () {
+ DN=$2
+ export HBASE_IDENT_STRING="$USER-$DN"
+ HBASE_MASTER_ARGS="\
+ -D hbase.master.port=`expr 60000 + $DN` \
+ -D hbase.master.info.port=`expr 60010 + $DN`"
+ "$bin"/hbase-daemon.sh $1 master $HBASE_MASTER_ARGS
+}
+
+cmd=$1
+shift;
+
+for i in $*
+do
+ run_master $cmd $i
+done
diff --git a/bin/local-regionservers.sh b/bin/local-regionservers.sh
new file mode 100644
index 00000000000..d36d4da9d43
--- /dev/null
+++ b/bin/local-regionservers.sh
@@ -0,0 +1,35 @@
+#!/bin/sh
+# This is used for starting multiple regionservers on the same machine.
+# run it from hbase-dir/ just like 'bin/hbase'
+# Supports up to 100 regionservers (limitation = overlapping ports)
+
+bin=`dirname "$0"`
+bin=`cd "$bin" >/dev/null && pwd`
+
+if [ $# -lt 2 ]; then
+ S=`basename $0`
+ echo "Usage: $S [start|stop] offset(s)"
+ echo ""
+ echo " e.g. $S start 1 2"
+ exit
+fi
+
+# sanity check: make sure your regionserver opts don't use ports [i.e. JMX/DBG]
+export HBASE_REGIONSERVER_OPTS=" "
+
+run_regionserver () {
+ DN=$2
+ export HBASE_IDENT_STRING="$USER-$DN"
+ HBASE_REGIONSERVER_ARGS="\
+ -D hbase.regionserver.port=`expr 60200 + $DN` \
+ -D hbase.regionserver.info.port=`expr 60300 + $DN`"
+ "$bin"/hbase-daemon.sh $1 regionserver $HBASE_REGIONSERVER_ARGS
+}
+
+cmd=$1
+shift;
+
+for i in $*
+do
+ run_regionserver $cmd $i
+done
diff --git a/conf/hbase-site.xml.psuedo-distributed.template b/conf/hbase-site.xml.psuedo-distributed.template
new file mode 100644
index 00000000000..a960eb7b7da
--- /dev/null
+++ b/conf/hbase-site.xml.psuedo-distributed.template
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+ hbase.cluster.distributed
+ true
+ For psuedo-distributed, you want to set this to true.
+ false means that HBase tries to put Master + RegionServers in one process.
+ Pseudo-distributed = seperate processes/pids
+
+ hbase.regionserver.hlog.replication
+ 1
+ For HBase to offer good data durability, we roll logs if
+ filesystem replication falls below a certain amount. In psuedo-distributed
+ mode, you normally only have the local filesystem or 1 HDFS DataNode, so you
+ don't want to roll logs constantly.
+
+
+ hbase.tmp.dir
+ /tmp/hbase-testing
+ Temporary directory on the local filesystem.
+
+
+
+
+
+
+
+
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 83536e10f7e..b5a3b8f15ee 100644
--- a/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -37,6 +37,10 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -1199,6 +1203,7 @@ public class HMaster extends Thread implements HMasterInterface,
System.err.println(" stop Start cluster shutdown; Master signals RegionServer shutdown");
System.err.println(" where [opts] are:");
System.err.println(" --minServers= Minimum RegionServers needed to host user tables.");
+ System.err.println(" -D opt= Override HBase configuration settings.");
System.exit(0);
}
@@ -1250,20 +1255,34 @@ public class HMaster extends Thread implements HMasterInterface,
protected static void doMain(String [] args,
Class extends HMaster> masterClass) {
- if (args.length < 1) {
- printUsageAndExit();
- }
Configuration conf = HBaseConfiguration.create();
- // Process command-line args.
- for (String cmd: args) {
- if (cmd.startsWith("--minServers=")) {
+ Options opt = new Options();
+ opt.addOption("minServers", true, "Minimum RegionServers needed to host user tables");
+ opt.addOption("D", true, "Override HBase Configuration Settings");
+ try {
+ CommandLine cmd = new GnuParser().parse(opt, args);
+
+ if (cmd.hasOption("minServers")) {
+ String val = cmd.getOptionValue("minServers");
conf.setInt("hbase.regions.server.count.min",
- Integer.valueOf(cmd.substring(13)));
- continue;
+ Integer.valueOf(val));
+ LOG.debug("minServers set to " + val);
}
- if (cmd.equalsIgnoreCase("start")) {
+ if (cmd.hasOption("D")) {
+ for (String confOpt : cmd.getOptionValues("D")) {
+ String[] kv = confOpt.split("=", 2);
+ if (kv.length == 2) {
+ conf.set(kv[0], kv[1]);
+ LOG.debug("-D configuration override: " + kv[0] + "=" + kv[1]);
+ } else {
+ throw new ParseException("-D option format invalid: " + confOpt);
+ }
+ }
+ }
+
+ if (cmd.getArgList().contains("start")) {
try {
// Print out vm stats before starting up.
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
@@ -1312,10 +1331,7 @@ public class HMaster extends Thread implements HMasterInterface,
LOG.error("Failed to start master", t);
System.exit(-1);
}
- break;
- }
-
- if (cmd.equalsIgnoreCase("stop")) {
+ } else if (cmd.getArgList().contains("stop")) {
HBaseAdmin adm = null;
try {
adm = new HBaseAdmin(conf);
@@ -1329,10 +1345,12 @@ public class HMaster extends Thread implements HMasterInterface,
LOG.error("Failed to stop master", t);
System.exit(-1);
}
- break;
+ } else {
+ throw new ParseException("Unknown argument(s): " +
+ org.apache.commons.lang.StringUtils.join(cmd.getArgs(), " "));
}
-
- // Print out usage if we get to here.
+ } catch (ParseException e) {
+ LOG.error("Could not parse: ", e);
printUsageAndExit();
}
}
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 b5ad9d9d873..e6b365ea70b 100644
--- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -50,6 +50,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
@@ -2433,7 +2437,7 @@ public class HRegionServer implements HRegionInterface,
if (message != null) {
System.err.println(message);
}
- System.err.println("Usage: java org.apache.hbase.HRegionServer start|stop");
+ System.err.println("Usage: java org.apache.hbase.HRegionServer start|stop [-D ]");
System.exit(0);
}
@@ -2467,15 +2471,26 @@ public class HRegionServer implements HRegionInterface,
*/
protected static void doMain(final String [] args,
final Class extends HRegionServer> regionServerClass) {
- if (args.length < 1) {
- printUsageAndExit();
- }
Configuration conf = HBaseConfiguration.create();
- // Process command-line args. TODO: Better cmd-line processing
- // (but hopefully something not as painful as cli options).
- for (String cmd: args) {
- if (cmd.equals("start")) {
+ Options opt = new Options();
+ opt.addOption("D", true, "Override HBase Configuration Settings");
+ try {
+ CommandLine cmd = new GnuParser().parse(opt, args);
+
+ if (cmd.hasOption("D")) {
+ for (String confOpt : cmd.getOptionValues("D")) {
+ String[] kv = confOpt.split("=", 2);
+ if (kv.length == 2) {
+ conf.set(kv[0], kv[1]);
+ LOG.debug("-D configuration override: " + kv[0] + "=" + kv[1]);
+ } else {
+ throw new ParseException("-D option format invalid: " + confOpt);
+ }
+ }
+ }
+
+ if (cmd.getArgList().contains("start")) {
try {
// If 'local', don't start a region server here. Defer to
// LocalHBaseCluster. It manages 'local' clusters.
@@ -2493,17 +2508,18 @@ public class HRegionServer implements HRegionInterface,
} catch (Throwable t) {
LOG.error( "Can not start region server because "+
StringUtils.stringifyException(t) );
+ System.exit(-1);
}
- break;
+ } else if (cmd.getArgList().contains("stop")) {
+ throw new ParseException("To shutdown the regionserver run " +
+ "bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
+ "the regionserver pid");
+ } else {
+ throw new ParseException("Unknown argument(s): " +
+ org.apache.commons.lang.StringUtils.join(cmd.getArgs(), " "));
}
-
- if (cmd.equals("stop")) {
- printUsageAndExit("To shutdown the regionserver run " +
- "bin/hbase-daemon.sh stop regionserver or send a kill signal to" +
- "the regionserver pid");
- }
-
- // Print out usage if we get to here.
+ } catch (ParseException e) {
+ LOG.error("Could not parse", e);
printUsageAndExit();
}
}
diff --git a/src/site/site.xml b/src/site/site.xml
index 7f8ffa098da..716932b6a3c 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -36,6 +36,7 @@
+