You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/10/28 22:34:23 UTC

svn commit: r830768 - in /hadoop/hbase/trunk: conf/hbase-default.xml src/java/org/apache/hadoop/hbase/master/HMaster.java src/java/org/apache/hadoop/hbase/util/FSUtils.java

Author: stack
Date: Wed Oct 28 21:34:23 2009
New Revision: 830768

URL: http://svn.apache.org/viewvc?rev=830768&view=rev
Log:
HBASE-1816 Master Rewrite; redo how we check rootdir in HMaster constructor -- was broke when deploying on cluster

Modified:
    hadoop/hbase/trunk/conf/hbase-default.xml
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
    hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/FSUtils.java

Modified: hadoop/hbase/trunk/conf/hbase-default.xml
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/conf/hbase-default.xml?rev=830768&r1=830767&r2=830768&view=diff
==============================================================================
--- hadoop/hbase/trunk/conf/hbase-default.xml (original)
+++ hadoop/hbase/trunk/conf/hbase-default.xml Wed Oct 28 21:34:23 2009
@@ -404,9 +404,8 @@
     <name>zookeeper.retries</name>
     <value>5</value>
     <description>How many times to retry connections to ZooKeeper. Used for
-      reading/writing root region location, checking/writing out of safe mode.
-      Used together with ${zookeeper.pause} in an exponential backoff fashion
-      when making queries to ZooKeeper.
+      reading/writing root region location.  Used together with ${zookeeper.pause}
+      in an exponential backoff fashion when making queries to ZooKeeper.
     </description>
   </property>
   <property>
@@ -435,16 +434,6 @@
       this means the root location is stored at /hbase/root-region-server.
     </description>
   </property>
-  <property>
-    <name>zookeeper.znode.safemode</name>
-    <value>safe-mode</value>
-    <description>Path to ephemeral ZNode signifying cluster is out of safe mode.
-      This is created by the master when scanning is done. Clients wait for this
-      node before querying the cluster. If a relative path is given, the parent
-      folder will be ${zookeeper.znode.parent}. By default, this means the safe
-      mode flag is stored at /hbase/safe-mode.
-    </description>
-  </property>
 
   <!--
   The following three properties are used together to create the list of

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java?rev=830768&r1=830767&r2=830768&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/master/HMaster.java Wed Oct 28 21:34:23 2009
@@ -157,16 +157,18 @@
    */
   public HMaster(HBaseConfiguration conf) throws IOException {
     this.conf = conf;
-    this.fs = FileSystem.get(this.conf);
-    this.rootdir = getAndCheckRootDir(this.conf, this.fs);
-    // Set back into the configuration the qualified rootdir path.
-    this.conf.set(HConstants.HBASE_DIR, rootdir.toString());
-    // Set filesystem to be that of this.rootdir.
+    // Set filesystem to be that of this.rootdir else we get complaints about
+    // mismatched filesystems if hbase.rootdir is hdfs and fs.defaultFS is
+    // default localfs.  Presumption is that rootdir is fully-qualified before
+    // we get to here with appropriate fs scheme.
+    this.rootdir = FSUtils.getRootDir(this.conf);
     this.conf.set("fs.defaultFS", this.rootdir.toString());
+    this.fs = FileSystem.get(this.conf);
+    checkRootDir(this.rootdir, this.conf, this.fs);
 
     // Get my address and create an rpc server instance.  The rpc-server port
     // can be ephemeral...ensure we have the correct info
-    HServerAddress a = new HServerAddress(getMyAddress());
+    HServerAddress a = new HServerAddress(getMyAddress(this.conf));
     this.rpcServer = HBaseRPC.getServer(this, a.getBindAddress(),
       a.getPort(), conf.getInt("hbase.regionserver.handler.count", 10),
       false, conf);
@@ -198,19 +200,19 @@
   }
 
   /*
-   * Get the rootdir.  Make sure its wholesome before returning.
+   * Get the rootdir.  Make sure its wholesome and exists before returning.
+   * @param rd
    * @param conf
    * @param fs
-   * @return Fully qualified path to wholesome hbase root dir.
+   * @return hbase.rootdir (after checks for existence and bootstrapping if
+   * needed populating the directory with necessary bootup files).
    * @throws IOException
    */
-  private Path getAndCheckRootDir(final HBaseConfiguration c,
+  private static Path checkRootDir(final Path rd, final HBaseConfiguration c,
     final FileSystem fs)
   throws IOException {
-    Path rd = FSUtils.verifyAndQualifyRootDir(c);
     // If FS is in safe mode wait till out of it.
     FSUtils.waitOnSafeMode(c, c.getInt(THREAD_WAKE_FREQUENCY, 10 * 1000));
-
     // Filesystem is good. Go ahead and check for hbase.rootdir.
     if (!fs.exists(rd)) {
       fs.mkdirs(rd);
@@ -225,21 +227,7 @@
     return rd;
   }
 
-  /*
-   * @return This masters' address.
-   * @throws UnknownHostException
-   */
-  private String getMyAddress() throws UnknownHostException {
-    // Find out our address up in DNS.
-    String addressStr = DNS.getDefaultHost(
-      conf.get("hbase.master.dns.interface","default"),
-      conf.get("hbase.master.dns.nameserver","default"));
-    addressStr += ":" +
-      this.conf.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
-    return addressStr;
-  }
-
-  private void bootstrap(final Path rd, final HBaseConfiguration c)
+  private static void bootstrap(final Path rd, final HBaseConfiguration c)
   throws IOException {
     LOG.info("BOOTSTRAP: creating ROOT and first META regions");
     try {
@@ -271,12 +259,25 @@
    * @param hri Set all family block caching to <code>b</code>
    * @param b
    */
-  private void setBlockCaching(final HRegionInfo hri, final boolean b) {
+  private static void setBlockCaching(final HRegionInfo hri, final boolean b) {
     for (HColumnDescriptor hcd: hri.getTableDesc().families.values()) {
       hcd.setBlockCacheEnabled(b);
     }
   }
 
+  /*
+   * @return This masters' address.
+   * @throws UnknownHostException
+   */
+  private static String getMyAddress(final HBaseConfiguration c)
+  throws UnknownHostException {
+    // Find out our address up in DNS.
+    String s = DNS.getDefaultHost(c.get("hbase.master.dns.interface","default"),
+      c.get("hbase.master.dns.nameserver","default"));
+    s += ":" + c.get(MASTER_PORT, Integer.toString(DEFAULT_MASTER_PORT));
+    return s;
+  }
+
   /**
    * Checks to see if the file system is still accessible.
    * If not, sets closed

Modified: hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=830768&r1=830767&r2=830768&view=diff
==============================================================================
--- hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hadoop/hbase/trunk/src/java/org/apache/hadoop/hbase/util/FSUtils.java Wed Oct 28 21:34:23 2009
@@ -238,19 +238,6 @@
   }
 
   /**
-   * Verify and qualify rootdir in <code>conf</code>.  Does not test for
-   * existence of the rootdir.
-   * @param conf.
-   * @return Verified and qualified rootdir.
-   * @throws IOException
-   */
-  public static Path verifyAndQualifyRootDir(final HBaseConfiguration conf)
-  throws IOException {
-    Path dir = FSUtils.getRootDir(conf, false);
-    return FileSystem.get(conf).makeQualified(FSUtils.validateRootPath(dir));
-  }
-
-  /**
    * If DFS, check safe mode and if so, wait until we clear it.
    * @param conf
    * @param wait Sleep between retries
@@ -290,36 +277,15 @@
 
   /**
    * @param c
-   * @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> as a
-   * Path.
+   * @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> from
+   * configuration as a Path.
    * @throws IOException 
    */
   public static Path getRootDir(final HBaseConfiguration c) throws IOException {
-    return getRootDir(c, true);
+    return new Path(c.get(HConstants.HBASE_DIR));
   }
 
   /**
-   * @param c
-   * @param test If true, test for presence and throw exception if not present.
-   * @return Path to hbase root directory: i.e. <code>hbase.rootdir</code> as a
-   * Path.
-   * @throws IOException 
-   */
-  public static Path getRootDir(final HBaseConfiguration c, final boolean test)
-  throws IOException {
-    FileSystem fs = FileSystem.get(c);
-    // Get root directory of HBase installation
-    Path rootdir = fs.makeQualified(new Path(c.get(HConstants.HBASE_DIR)));
-    if (test && !fs.exists(rootdir)) {
-      String message = "HBase root directory " + rootdir.toString() +
-        " does not exist.";
-      LOG.error(message);
-      throw new FileNotFoundException(message);
-    }
-    return rootdir;
-  }
-  
-  /**
    * Checks if root region exists
    * 
    * @param fs file system