hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raw...@apache.org
Subject svn commit: r925560 - in /hadoop/hbase/branches/0.20: ./ bin/ src/java/org/apache/hadoop/hbase/ src/java/org/apache/hadoop/hbase/master/ src/test/org/apache/hadoop/hbase/
Date Sat, 20 Mar 2010 07:22:54 GMT
Author: rawson
Date: Sat Mar 20 07:22:53 2010
New Revision: 925560

URL: http://svn.apache.org/viewvc?rev=925560&view=rev
Log:
HBASE-2147  run zookeeper in the same jvm as master during non-distributed mode


Added:
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfTool.java
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
      - copied, changed from r925559, hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
Removed:
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/bin/start-hbase.sh
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=925560&r1=925559&r2=925560&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Sat Mar 20 07:22:53 2010
@@ -72,6 +72,7 @@ Release 0.20.4 - Unreleased
    HBASE-2174  Stop from resolving HRegionServer addresses to names using DNS
                on every heartbeat (Karthik Ranganathan via Stack)
    HBASE-2327  [EC2] Allocate elastic IP addresses for ZK and master nodes
+   HBASE-2147  run zookeeper in the same jvm as master during non-distributed mode
 
   NEW FEATURES
    HBASE-2257  [stargate] multiuser mode

Modified: hadoop/hbase/branches/0.20/bin/start-hbase.sh
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/bin/start-hbase.sh?rev=925560&r1=925559&r2=925560&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/bin/start-hbase.sh (original)
+++ hadoop/hbase/branches/0.20/bin/start-hbase.sh Sat Mar 20 07:22:53 2010
@@ -39,7 +39,16 @@ then
   exit $errCode
 fi
 
+distMode=`$bin/hbase org.apache.hadoop.hbase.HBaseConfTool hbase.cluster.distributed`
+
+
+if [ $distMode == 'false' ] 
+then
+  echo "Non distributed mode startup"
+  "$bin"/hbase-daemon.sh start master
+else
 "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" start zookeeper
 "$bin"/hbase-daemon.sh --config "${HBASE_CONF_DIR}" start master 
 "$bin"/hbase-daemons.sh --config "${HBASE_CONF_DIR}" \
   --hosts "${HBASE_REGIONSERVERS}" start regionserver
+fi

Added: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfTool.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfTool.java?rev=925560&view=auto
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfTool.java (added)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/HBaseConfTool.java Sat Mar
20 07:22:53 2010
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010 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.
+ */
+
+package org.apache.hadoop.hbase;
+
+import org.apache.hadoop.conf.Configuration;
+
+public class HBaseConfTool {
+
+  public static void main(String args[]) {
+    if (args.length < 1)
+      return;
+
+    Configuration conf = new HBaseConfiguration();
+    System.out.println(conf.get(args[0]));
+  }
+}

Copied: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
(from r925559, hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/MiniZooKeeperCluster.java)
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/MiniZooKeeperCluster.java?p2=hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/MiniZooKeeperCluster.java&p1=hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/MiniZooKeeperCluster.java&r1=925559&r2=925560&rev=925560&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/MiniZooKeeperCluster.java
Sat Mar 20 07:22:53 2010
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright 2009 The Apache Software Foundation
  *
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -44,7 +44,6 @@ import org.apache.zookeeper.server.persi
 public class MiniZooKeeperCluster {
   private static final Log LOG = LogFactory.getLog(MiniZooKeeperCluster.class);
 
-  // TODO: make this more configurable?
   private static final int TICK_TIME = 2000;
   private static final int CONNECTION_TIMEOUT = 30000;
 
@@ -52,12 +51,21 @@ public class MiniZooKeeperCluster {
   private int clientPort = 21810; // use non-standard port
 
   private NIOServerCnxn.Factory standaloneServerFactory;
+  private int tickTime = 0;
 
   /** Create mini ZooKeeper cluster. */
   public MiniZooKeeperCluster() {
     this.started = false;
   }
 
+  public void setClientPort(int clientPort) {
+    this.clientPort = clientPort;
+  }
+
+  public void setTickTime(int tickTime) {
+    this.tickTime = tickTime;
+  }
+
   // / XXX: From o.a.zk.t.ClientBase
   private static void setupTestEnv() {
     // during the tests we run with 100K prealloc in the logs.
@@ -76,6 +84,7 @@ public class MiniZooKeeperCluster {
    */
   public int startup(File baseDir) throws IOException,
       InterruptedException {
+
     setupTestEnv();
 
     shutdown();
@@ -83,7 +92,13 @@ public class MiniZooKeeperCluster {
     File dir = new File(baseDir, "zookeeper").getAbsoluteFile();
     recreateDir(dir);
 
-    ZooKeeperServer server = new ZooKeeperServer(dir, dir, TICK_TIME);
+    int tickTimeToUse;
+    if (this.tickTime > 0) {
+      tickTimeToUse = this.tickTime;
+    } else {
+      tickTimeToUse = TICK_TIME;
+    }
+    ZooKeeperServer server = new ZooKeeperServer(dir, dir, tickTimeToUse);
     while (true) {
       try {
         standaloneServerFactory = new NIOServerCnxn.Factory(clientPort);

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=925560&r1=925559&r2=925560&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/master/HMaster.java Sat Mar
20 07:22:53 2010
@@ -20,6 +20,7 @@
 package org.apache.hadoop.hbase.master;
 
 import java.io.IOException;
+import java.io.File;
 import java.lang.management.ManagementFactory;
 import java.lang.management.RuntimeMXBean;
 import java.lang.reflect.Constructor;
@@ -57,6 +58,7 @@ import org.apache.hadoop.hbase.LocalHBas
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.TableExistsException;
+import org.apache.hadoop.hbase.MiniZooKeeperCluster;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.Result;
@@ -1234,6 +1236,25 @@ public class HMaster extends Thread impl
           }
           // If 'local', defer to LocalHBaseCluster instance.
           if (LocalHBaseCluster.isLocal(conf)) {
+            // TODO make zookeepercluster a field and do an orderly shutdown
+            MiniZooKeeperCluster zooKeeperCluster = new MiniZooKeeperCluster();
+            File zkDataPath = new File(conf.get("hbase.zookeeper.property.dataDir"));
+            int zkClientPort = conf.getInt("hbase.zookeeper.property.clientPort", 0);
+            if (zkClientPort == 0) {
+              throw new IOException("No config value for hbase.zookeeper.property.clientPort");
+            }
+
+            zooKeeperCluster.setTickTime(conf.getInt("hbase.zookeeper.property.tickTime",
3000));
+            zooKeeperCluster.setClientPort(zkClientPort);
+            int clientPort = zooKeeperCluster.startup(zkDataPath);
+            if (clientPort != zkClientPort) {
+              String errorMsg = "Couldnt start ZK at requested address of " +
+                  zkClientPort + ", instead got: " + clientPort + ". Aborting. Why? " +
+                  "Because clients (eg shell) wont be able to find this ZK quorum";
+              System.err.println(errorMsg);
+              throw new IOException(errorMsg);
+            }
+            conf.set("hbase.zookeeper.property.clientPort", Integer.toString(clientPort));
             (new LocalHBaseCluster(conf)).startup();
           } else {
             Constructor<? extends HMaster> c =



Mime
View raw message