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 2013/03/08 23:37:20 UTC

svn commit: r1454607 [1/3] - in /hbase/trunk: hbase-client/src/main/java/org/apache/hadoop/hbase/ hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/ hbase-client/src/main/java/org/apache/hadoop/hbase/client/ hbase-client/src/main/java/org/apac...

Author: stack
Date: Fri Mar  8 22:37:19 2013
New Revision: 1454607

URL: http://svn.apache.org/r1454607
Log:
HBASE-3171 Drop ROOT and instead store META location(s) directly in ZooKeeper

Added:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaRegionTracker.java
Removed:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
    hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
    hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
    hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ClosedRegionHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
    hbase/trunk/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
    hbase/trunk/hbase-server/src/main/ruby/hbase/admin.rb
    hbase/trunk/hbase-server/src/main/ruby/hbase/table.rb
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaReaderEditor.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDistributedLogSplitting.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRollingRestart.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionInfo.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRSKilledWhenMasterInitializing.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFileBlockCacheSummary.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/rest/TestStatusResource.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsck.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestMergeTool.java
    hbase/trunk/hbase-server/src/test/ruby/hbase/admin_test.rb
    hbase/trunk/hbase-server/src/test/ruby/hbase/table_test.rb

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java Fri Mar  8 22:37:19 2013
@@ -99,7 +99,7 @@ public class HRegionInfo implements Comp
    *<p>
    * **NOTE**
    *
-   * ROOT, the first META region, and regions created by an older
+   * The first META region, and regions created by an older
    * version of HBase (0.20 or prior) will continue to use the
    * old region name format.
    */
@@ -142,7 +142,7 @@ public class HRegionInfo implements Comp
           regionName.length - MD5_HEX_LENGTH - 1,
           MD5_HEX_LENGTH);
     } else {
-      // old format region name. ROOT and first META region also
+      // old format region name. First META region also
       // use this format.EncodedName is the JenkinsHash value.
       int hashVal = Math.abs(JenkinsHash.getInstance().hash(regionName,
         regionName.length, 0));
@@ -154,14 +154,11 @@ public class HRegionInfo implements Comp
   /**
    * Use logging.
    * @param encodedRegionName The encoded regionname.
-   * @return <code>-ROOT-</code> if passed <code>70236052</code> or
-   * <code>.META.</code> if passed </code>1028785192</code> else returns
+   * @return <code>.META.</code> if passed </code>1028785192</code> else returns
    * <code>encodedRegionName</code>
    */
   public static String prettyPrint(final String encodedRegionName) {
-    if (encodedRegionName.equals("70236052")) {
-      return encodedRegionName + "/-ROOT-";
-    } else if (encodedRegionName.equals("1028785192")) {
+    if (encodedRegionName.equals("1028785192")) {
       return encodedRegionName + "/.META.";
     }
     return encodedRegionName;
@@ -206,14 +203,14 @@ public class HRegionInfo implements Comp
 
 
   /**
-   * Private constructor used constructing HRegionInfo for the catalog root and
+   * Private constructor used constructing HRegionInfo for the
    * first meta regions
    */
   private HRegionInfo(long regionId, byte[] tableName) {
     super();
     this.regionId = regionId;
     this.tableName = tableName.clone();
-    // Note: Root & First Meta regions names are still in old format
+    // Note: First Meta regions names are still in old format
     this.regionName = createRegionName(tableName, null,
                                        regionId, false);
     this.regionNameStr = Bytes.toStringBinary(this.regionName);
@@ -568,16 +565,11 @@ public class HRegionInfo implements Comp
        Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY));
   }
 
-  /** @return true if this is the root region */
-  public boolean isRootRegion() {
-    return Bytes.equals(tableName, HRegionInfo.ROOT_REGIONINFO.getTableName());
-  }
-
-  /** @return true if this region is from a table that is a meta table,
-   * either <code>.META.</code> or <code>-ROOT-</code>
+  /**
+   * @return true if this region is from .META.
    */
   public boolean isMetaTable() {
-    return isRootRegion() || isMetaRegion();
+    return isMetaRegion();
   }
 
   /** @return true if this region is a meta region */
@@ -804,7 +796,7 @@ public class HRegionInfo implements Comp
    * @return Comparator to use comparing {@link KeyValue}s.
    */
   public KVComparator getComparator() {
-    return isRootRegion()? KeyValue.ROOT_COMPARATOR: isMetaRegion()?
+    return isMetaRegion()?
       KeyValue.META_COMPARATOR: KeyValue.COMPARATOR;
   }
 
@@ -848,9 +840,7 @@ public class HRegionInfo implements Comp
   public static HRegionInfo convert(final RegionInfo proto) {
     if (proto == null) return null;
     byte [] tableName = proto.getTableName().toByteArray();
-    if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
-      return ROOT_REGIONINFO;
-    } else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
+    if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
       return FIRST_META_REGIONINFO;
     }
     long regionId = proto.getRegionId();

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java Fri Mar  8 22:37:19 2013
@@ -33,8 +33,7 @@ import org.apache.hadoop.hbase.exception
 import org.apache.hadoop.hbase.exceptions.ServerNotRunningYetException;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.zookeeper.MetaNodeTracker;
-import org.apache.hadoop.hbase.zookeeper.RootRegionTracker;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.ipc.RemoteException;
 
@@ -45,28 +44,26 @@ import java.net.NoRouteToHostException;
 import java.net.SocketException;
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
- * Tracks the availability of the catalog tables <code>-ROOT-</code> and
+ * Tracks the availability of the catalog tables
  * <code>.META.</code>.
  * 
  * This class is "read-only" in that the locations of the catalog tables cannot
  * be explicitly set.  Instead, ZooKeeper is used to learn of the availability
- * and location of <code>-ROOT-</code>.  <code>-ROOT-</code> is used to learn of
- * the location of <code>.META.</code>  If not available in <code>-ROOT-</code>,
- * ZooKeeper is used to monitor for a new location of <code>.META.</code>.
+ * and location of <code>.META.</code>.
  *
  * <p>Call {@link #start()} to start up operation.  Call {@link #stop()}} to
  * interrupt waits and close up shop.
  */
 @InterfaceAudience.Private
 public class CatalogTracker {
+  // TODO JDC 11/30 We don't even have ROOT anymore, revisit
   // TODO: This class needs a rethink.  The original intent was that it would be
-  // the one-stop-shop for root and meta locations and that it would get this
+  // the one-stop-shop for meta locations and that it would get this
   // info from reading and watching zk state.  The class was to be used by
-  // servers when they needed to know of root and meta movement but also by
-  // client-side (inside in HTable) so rather than figure root and meta
+  // servers when they needed to know of meta movement but also by
+  // client-side (inside in HTable) so rather than figure meta
   // locations on fault, the client would instead get notifications out of zk.
   // 
   // But this original intent is frustrated by the fact that this class has to
@@ -109,9 +106,7 @@ public class CatalogTracker {
   private static final Log LOG = LogFactory.getLog(CatalogTracker.class);
   private final HConnection connection;
   private final ZooKeeperWatcher zookeeper;
-  private final RootRegionTracker rootRegionTracker;
-  private final MetaNodeTracker metaNodeTracker;
-  private final AtomicBoolean metaAvailable = new AtomicBoolean(false);
+  private final MetaRegionTracker metaRegionTracker;
   private boolean instantiatedzkw = false;
   private Abortable abortable;
 
@@ -124,8 +119,6 @@ public class CatalogTracker {
 
   private boolean stopped = false;
 
-  static final byte [] ROOT_REGION_NAME =
-    HRegionInfo.ROOT_REGIONINFO.getRegionName();
   static final byte [] META_REGION_NAME =
     HRegionInfo.FIRST_META_REGIONINFO.getRegionName();
 
@@ -192,15 +185,7 @@ public class CatalogTracker {
     } else {
       this.zookeeper = zk;
     }
-    this.rootRegionTracker = new RootRegionTracker(zookeeper, throwableAborter);
-    final CatalogTracker ct = this;
-    // Override nodeDeleted so we get notified when meta node deleted
-    this.metaNodeTracker = new MetaNodeTracker(zookeeper, throwableAborter) {
-      public void nodeDeleted(String path) {
-        if (!path.equals(node)) return;
-        ct.resetMetaLocation();
-      }
-    };
+    this.metaRegionTracker = new MetaRegionTracker(zookeeper, throwableAborter);
   }
 
   /**
@@ -213,12 +198,11 @@ public class CatalogTracker {
   public void start() throws IOException, InterruptedException {
     LOG.debug("Starting catalog tracker " + this);
     try {
-      this.rootRegionTracker.start();
-      this.metaNodeTracker.start();
+      this.metaRegionTracker.start();
     } catch (RuntimeException e) {
       Throwable t = e.getCause();
       this.abortable.abort(e.getMessage(), t);
-      throw new IOException("Attempt to start root/meta tracker failed.", t);
+      throw new IOException("Attempt to start meta tracker failed.", t);
     }
   }
 
@@ -230,8 +214,7 @@ public class CatalogTracker {
     if (!this.stopped) {
       LOG.debug("Stopping catalog tracker " + this);
       this.stopped = true;
-      this.rootRegionTracker.stop();
-      this.metaNodeTracker.stop();
+      this.metaRegionTracker.stop();
       try {
         if (this.connection != null) {
           this.connection.close();
@@ -244,61 +227,34 @@ public class CatalogTracker {
       if (this.instantiatedzkw) {
         this.zookeeper.close();
       }
-      // Call this and it will interrupt any ongoing waits on meta.
-      synchronized (this.metaAvailable) {
-        this.metaAvailable.notifyAll();
-      }
     }
   }
 
   /**
-   * Gets the current location for <code>-ROOT-</code> or null if location is
+   * Gets the current location for <code>.META.</code> or null if location is
    * not currently available.
-   * @return {@link ServerName} for server hosting <code>-ROOT-</code> or null
-   * if none available
-   * @throws InterruptedException 
-   */
-  public ServerName getRootLocation() throws InterruptedException {
-    return this.rootRegionTracker.getRootRegionLocation();
-  }
-
-  /**
    * @return {@link ServerName} for server hosting <code>.META.</code> or null
    * if none available
+   * @throws InterruptedException 
    */
-  public ServerName getMetaLocation() {
-    return this.metaLocation;
-  }
-
-  /**
-   * Method used by master on startup trying to figure state of cluster.
-   * Returns the current meta location unless its null.  In this latter case,
-   * it has not yet been set so go check whats up in <code>-ROOT-</code> and
-   * return that.
-   * @return {@link ServerName} for server hosting <code>.META.</code> or if null,
-   * we'll read the location that is up in <code>-ROOT-</code> table (which
-   * could be null or just plain stale).
-   * @throws IOException
-   */
-  public ServerName getMetaLocationOrReadLocationFromRoot() throws IOException {
-    ServerName sn = getMetaLocation();
-    return sn != null? sn: MetaReader.getMetaRegionLocation(this);
+  public ServerName getMetaLocation() throws InterruptedException {
+    return this.metaRegionTracker.getMetaRegionLocation();
   }
 
   /**
-   * Gets the current location for <code>-ROOT-</code> if available and waits
+   * Gets the current location for <code>.META.</code> if available and waits
    * for up to the specified timeout if not immediately available.  Returns null
    * if the timeout elapses before root is available.
    * @param timeout maximum time to wait for root availability, in milliseconds
-   * @return {@link ServerName} for server hosting <code>-ROOT-</code> or null
+   * @return {@link ServerName} for server hosting <code>.META.</code> or null
    * if none available
    * @throws InterruptedException if interrupted while waiting
-   * @throws NotAllMetaRegionsOnlineException if root not available before
+   * @throws NotAllMetaRegionsOnlineException if meta not available before
    * timeout
    */
-  public ServerName waitForRoot(final long timeout)
+  public ServerName waitForMeta(final long timeout)
   throws InterruptedException, NotAllMetaRegionsOnlineException {
-    ServerName sn = rootRegionTracker.waitRootRegionLocation(timeout);
+    ServerName sn = metaRegionTracker.waitMetaRegionLocation(timeout);
     if (sn == null) {
       throw new NotAllMetaRegionsOnlineException("Timed out; " + timeout + "ms");
     }
@@ -306,86 +262,35 @@ public class CatalogTracker {
   }
 
   /**
-   * Gets a connection to the server hosting root, as reported by ZooKeeper,
+   * Gets a connection to the server hosting meta, as reported by ZooKeeper,
    * waiting up to the specified timeout for availability.
-   * @param timeout How long to wait on root location
-   * @see #waitForRoot(long) for additional information
-   * @return connection to server hosting root
+   * @param timeout How long to wait on meta location
+   * @see #waitForMeta for additional information
+   * @return connection to server hosting meta
    * @throws InterruptedException
    * @throws NotAllMetaRegionsOnlineException if timed out waiting
    * @throws IOException
-   * @deprecated Use #getRootServerConnection(long)
+   * @deprecated Use #getMetaServerConnection(long)
    */
-  public AdminProtocol waitForRootServerConnection(long timeout)
+  public AdminProtocol waitForMetaServerConnection(long timeout)
   throws InterruptedException, NotAllMetaRegionsOnlineException, IOException {
-    return getRootServerConnection(timeout);
+    return getMetaServerConnection(timeout);
   }
 
   /**
-   * Gets a connection to the server hosting root, as reported by ZooKeeper,
+   * Gets a connection to the server hosting meta, as reported by ZooKeeper,
    * waiting up to the specified timeout for availability.
    * <p>WARNING: Does not retry.  Use an {@link HTable} instead.
-   * @param timeout How long to wait on root location
-   * @see #waitForRoot(long) for additional information
-   * @return connection to server hosting root
+   * @param timeout How long to wait on meta location
+   * @see #waitForMeta for additional information
+   * @return connection to server hosting meta
    * @throws InterruptedException
    * @throws NotAllMetaRegionsOnlineException if timed out waiting
    * @throws IOException
    */
-  AdminProtocol getRootServerConnection(long timeout)
+  AdminProtocol getMetaServerConnection(long timeout)
   throws InterruptedException, NotAllMetaRegionsOnlineException, IOException {
-    return getCachedConnection(waitForRoot(timeout));
-  }
-
-  /**
-   * Gets a connection to the server currently hosting <code>.META.</code> or
-   * null if location is not currently available.
-   * <p>
-   * If a location is known, a connection to the cached location is returned.
-   * If refresh is true, the cached connection is verified first before
-   * returning.  If the connection is not valid, it is reset and rechecked.
-   * <p>
-   * If no location for meta is currently known, method checks ROOT for a new
-   * location, verifies META is currently there, and returns a cached connection
-   * to the server hosting META.
-   *
-   * @return connection to server hosting meta, null if location not available
-   * @throws IOException
-   * @throws InterruptedException
-   */
-  private AdminProtocol getMetaServerConnection()
-  throws IOException, InterruptedException {
-    synchronized (metaAvailable) {
-      if (metaAvailable.get()) {
-        AdminProtocol current = getCachedConnection(this.metaLocation);
-        // If we are to refresh, verify we have a good connection by making
-        // an invocation on it.
-        if (verifyRegionLocation(current, this.metaLocation, META_REGION_NAME)) {
-          return current;
-        }
-        resetMetaLocation();
-      }
-      // We got here because there is no meta available or because whats
-      // available is bad.
-
-      // Now read the current .META. content from -ROOT-.  Note: This goes via
-      // an HConnection.  It has its own way of figuring root and meta locations
-      // which we have to wait on.
-      ServerName newLocation = MetaReader.getMetaRegionLocation(this);
-      if (newLocation == null) return null;
-
-      AdminProtocol newConnection = getCachedConnection(newLocation);
-      if (verifyRegionLocation(newConnection, newLocation, META_REGION_NAME)) {
-        setMetaLocation(newLocation);
-        return newConnection;
-      } else {
-        if (LOG.isTraceEnabled()) {
-          LOG.trace("New .META. server: " + newLocation + " isn't valid." +
-            " Cached .META. server: " + this.metaLocation);
-        }
-      }
-      return null;
-    }
+    return getCachedConnection(waitForMeta(timeout));
   }
 
   /**
@@ -411,79 +316,6 @@ public class CatalogTracker {
   }
 
   /**
-   * Gets the current location for <code>.META.</code> if available and waits
-   * for up to the specified timeout if not immediately available.  Throws an
-   * exception if timed out waiting.  This method differs from {@link #waitForMeta()}
-   * in that it will go ahead and verify the location gotten from ZooKeeper and
-   * -ROOT- region by trying to use returned connection.
-   * @param timeout maximum time to wait for meta availability, in milliseconds
-   * @return {@link ServerName} for server hosting <code>.META.</code> or null
-   * if none available
-   * @throws InterruptedException if interrupted while waiting
-   * @throws IOException unexpected exception connecting to meta server
-   * @throws NotAllMetaRegionsOnlineException if meta not available before
-   * timeout
-   */
-  public ServerName waitForMeta(long timeout)
-  throws InterruptedException, IOException, NotAllMetaRegionsOnlineException {
-    long stop = timeout == 0 ? Long.MAX_VALUE : System.currentTimeMillis() + timeout;
-    long waitTime = Math.min(50, timeout);
-    synchronized (metaAvailable) {
-      while(!stopped && System.currentTimeMillis() < stop) {
-        if (getMetaServerConnection() != null) {
-          return metaLocation;
-        }
-        // perhaps -ROOT- region isn't available, let us wait a bit and retry.
-        metaAvailable.wait(waitTime);
-      }
-      if (getMetaServerConnection() == null) {
-        throw new NotAllMetaRegionsOnlineException("Timed out (" + timeout + "ms)");
-      }
-      return metaLocation;
-    }
-  }
-
-  /**
-   * Gets a connection to the server hosting meta, as reported by ZooKeeper,
-   * waiting up to the specified timeout for availability.
-   * @see #waitForMeta(long) for additional information
-   * @return connection to server hosting meta
-   * @throws InterruptedException
-   * @throws NotAllMetaRegionsOnlineException if timed out waiting
-   * @throws IOException
-   * @deprecated Does not retry; use an HTable instance instead.
-   */
-  public AdminProtocol waitForMetaServerConnection(long timeout)
-  throws InterruptedException, NotAllMetaRegionsOnlineException, IOException {
-    return getCachedConnection(waitForMeta(timeout));
-  }
-
-  /**
-   * Called when we figure current meta is off (called from zk callback).
-   */
-  public void resetMetaLocation() {
-    LOG.debug("Current cached META location, " + metaLocation +
-      ", is not valid, resetting");
-    synchronized(this.metaAvailable) {
-      this.metaAvailable.set(false);
-      this.metaAvailable.notifyAll();
-    }
-  }
-
-  /**
-   * @param metaLocation
-   */
-  void setMetaLocation(final ServerName metaLocation) {
-    LOG.debug("Set new cached META location: " + metaLocation);
-    synchronized (this.metaAvailable) {
-      this.metaLocation = metaLocation;
-      this.metaAvailable.set(true);
-      // no synchronization because these are private and already under lock
-      this.metaAvailable.notifyAll();
-    }
-  }
-
-  /**
    * @param sn ServerName to get a connection against.
    * @return The AdminProtocol we got when we connected to <code>sn</code>
    * May have come from cache, may not be good, may have been setup by this
@@ -533,7 +365,7 @@ public class CatalogTracker {
    * Verify we can connect to <code>hostingServer</code> and that its carrying
    * <code>regionName</code>.
    * @param hostingServer Interface to the server hosting <code>regionName</code>
-   * @param serverName The servername that goes with the <code>metaServer</code>
+   * @param address The servername that goes with the <code>metaServer</code>
    * Interface.  Used logging.
    * @param regionName The regionname we are interested in.
    * @return True if we were able to verify the region located at other side of
@@ -579,18 +411,18 @@ public class CatalogTracker {
   }
 
   /**
-   * Verify <code>-ROOT-</code> is deployed and accessible.
-   * @param timeout How long to wait on zk for root address (passed through to
-   * the internal call to {@link #waitForRootServerConnection(long)}.
-   * @return True if the <code>-ROOT-</code> location is healthy.
+   * Verify <code>.META.</code> is deployed and accessible.
+   * @param timeout How long to wait on zk for meta address (passed through to
+   * the internal call to {@link #waitForMetaServerConnection(long)}.
+   * @return True if the <code>.META.</code> location is healthy.
    * @throws IOException
    * @throws InterruptedException 
    */
-  public boolean verifyRootRegionLocation(final long timeout)
+  public boolean verifyMetaRegionLocation(final long timeout)
   throws InterruptedException, IOException {
     AdminProtocol connection = null;
     try {
-      connection = waitForRootServerConnection(timeout);
+      connection = waitForMetaServerConnection(timeout);
     } catch (NotAllMetaRegionsOnlineException e) {
       // Pass
     } catch (ServerNotRunningYetException e) {
@@ -600,38 +432,7 @@ public class CatalogTracker {
     }
     return (connection == null)? false:
       verifyRegionLocation(connection,
-        this.rootRegionTracker.getRootRegionLocation(), ROOT_REGION_NAME);
-  }
-
-  /**
-   * Verify <code>.META.</code> is deployed and accessible.
-   * @param timeout How long to wait on zk for <code>.META.</code> address
-   * (passed through to the internal call to {@link #waitForMetaServerConnection(long)}.
-   * @return True if the <code>.META.</code> location is healthy.
-   * @throws IOException Some unexpected IOE.
-   * @throws InterruptedException
-   */
-  public boolean verifyMetaRegionLocation(final long timeout)
-  throws InterruptedException, IOException {
-    AdminProtocol connection = null;
-    try {
-      connection = waitForMetaServerConnection(timeout);
-    } catch (NotAllMetaRegionsOnlineException e) {
-      // Pass
-    } catch (ServerNotRunningYetException e) {
-      // Pass -- remote server is not up so can't be carrying .META.
-    } catch (UnknownHostException e) {
-      // Pass -- server name doesn't resolve so it can't be assigned anything.
-    } catch (RetriesExhaustedException e) {
-      // Pass -- failed after bunch of retries.
-      LOG.debug("Failed verify meta region location after retries", e);
-    }
-    return connection != null;
-  }
-
-  // Used by tests.
-  MetaNodeTracker getMetaNodeTracker() {
-    return this.metaNodeTracker;
+          this.metaRegionTracker.getMetaRegionLocation(), META_REGION_NAME);
   }
 
   public HConnection getConnection() {

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/catalog/MetaReader.java Fri Mar  8 22:37:19 2013
@@ -62,21 +62,6 @@ public class MetaReader {
   }
 
   /**
-   * @param row
-   * @return True if <code>row</code> is row of <code>-ROOT-</code> table.
-   */
-  private static boolean isRootTableRow(final byte [] row) {
-    if (row.length < META_REGION_PREFIX.length + 2 /* ',', + '1' */) {
-      // Can't be meta table region.
-      return false;
-    }
-    // Compare the prefix of row.  If it matches META_REGION_PREFIX prefix,
-    // then this is row from -ROOT_ table.
-    return Bytes.equals(row, 0, META_REGION_PREFIX.length,
-      META_REGION_PREFIX, 0, META_REGION_PREFIX.length);
-  }
-
-  /**
    * Performs a full scan of <code>.META.</code>, skipping regions from any
    * tables in the specified set of disabled tables.
    * @param catalogTracker
@@ -143,14 +128,14 @@ public class MetaReader {
   }
 
   /**
-   * Performs a full scan of a <code>-ROOT-</code> table.
+   * Performs a full scan of a <code>.META.</code> table.
    * @return List of {@link Result}
    * @throws IOException
    */
-  public static List<Result> fullScanOfRoot(CatalogTracker catalogTracker)
+  public static List<Result> fullScanOfMeta(CatalogTracker catalogTracker)
   throws IOException {
     CollectAllVisitor v = new CollectAllVisitor();
-    fullScan(catalogTracker, v, null, true);
+    fullScan(catalogTracker, v, null);
     return v.getResults();
   }
 
@@ -167,21 +152,6 @@ public class MetaReader {
   }
 
   /**
-   * Performs a full scan of <code>.META.</code>.
-   * @param catalogTracker
-   * @param visitor Visitor invoked against each row.
-   * @param startrow Where to start the scan. Pass null if want to begin scan
-   * at first row (The visitor will stop the Scan when its done so no need to
-   * pass a stoprow).
-   * @throws IOException
-   */
-  public static void fullScan(CatalogTracker catalogTracker,
-      final Visitor visitor, final byte [] startrow)
-  throws IOException {
-    fullScan(catalogTracker, visitor, startrow, false);
-  }
-
-  /**
    * Callers should call close on the returned {@link HTable} instance.
    * @param catalogTracker We'll use this catalogtracker's connection
    * @param tableName Table to get an {@link HTable} against.
@@ -201,16 +171,12 @@ public class MetaReader {
   /**
    * Callers should call close on the returned {@link HTable} instance.
    * @param catalogTracker
-   * @param row Row we are putting
    * @return
    * @throws IOException
    */
-  static HTable getCatalogHTable(final CatalogTracker catalogTracker,
-      final byte [] row)
+  static HTable getCatalogHTable(final CatalogTracker catalogTracker)
   throws IOException {
-    return isRootTableRow(row)?
-      getRootHTable(catalogTracker):
-      getMetaHTable(catalogTracker);
+    return getMetaHTable(catalogTracker);
   }
 
   /**
@@ -225,17 +191,6 @@ public class MetaReader {
   }
 
   /**
-   * Callers should call close on the returned {@link HTable} instance.
-   * @param ct
-   * @return An {@link HTable} for <code>-ROOT-</code>
-   * @throws IOException
-   */
-  static HTable getRootHTable(final CatalogTracker ct)
-  throws IOException {
-    return getHTable(ct, HConstants.ROOT_TABLE_NAME);
-  }
-
-  /**
    * @param t Table to use (will be closed when done).
    * @param g Get to run
    * @throws IOException
@@ -249,19 +204,6 @@ public class MetaReader {
   }
 
   /**
-   * Gets the location of <code>.META.</code> region by reading content of
-   * <code>-ROOT-</code>.
-   * @param ct
-   * @return location of <code>.META.</code> region as a {@link ServerName} or
-   * null if not found
-   * @throws IOException
-   */
-  static ServerName getMetaRegionLocation(final CatalogTracker ct)
-  throws IOException {
-    return MetaReader.readRegionLocation(ct, CatalogTracker.META_REGION_NAME);
-  }
-
-  /**
    * Reads the location of the specified region
    * @param catalogTracker
    * @param regionName region whose location we are after
@@ -287,7 +229,7 @@ public class MetaReader {
   throws IOException {
     Get get = new Get(regionName);
     get.addFamily(HConstants.CATALOG_FAMILY);
-    Result r = get(getCatalogHTable(catalogTracker, regionName), get);
+    Result r = get(getCatalogHTable(catalogTracker), get);
     return (r == null || r.isEmpty())? null: HRegionInfo.getHRegionInfoAndServerName(r);
   }
 
@@ -302,8 +244,7 @@ public class MetaReader {
   public static boolean tableExists(CatalogTracker catalogTracker,
       String tableName)
   throws IOException {
-    if (tableName.equals(HTableDescriptor.ROOT_TABLEDESC.getNameAsString()) ||
-        tableName.equals(HTableDescriptor.META_TABLEDESC.getNameAsString())) {
+    if (tableName.equals(HTableDescriptor.META_TABLEDESC.getNameAsString())) {
       // Catalog tables always exist.
       return true;
     }
@@ -451,13 +392,13 @@ public class MetaReader {
   getTableRegionsAndLocations(final CatalogTracker catalogTracker,
       final byte [] tableName, final boolean excludeOfflinedSplitParents)
   throws IOException, InterruptedException {
-    if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
-      // If root, do a bit of special handling.
-      ServerName serverName = catalogTracker.getRootLocation();
+    if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
+      // If meta, do a bit of special handling.
+      ServerName serverName = catalogTracker.getMetaLocation();
       List<Pair<HRegionInfo, ServerName>> list =
-        new ArrayList<Pair<HRegionInfo, ServerName>>();
-      list.add(new Pair<HRegionInfo, ServerName>(HRegionInfo.ROOT_REGIONINFO,
-        serverName));
+          new ArrayList<Pair<HRegionInfo, ServerName>>();
+      list.add(new Pair<HRegionInfo, ServerName>(HRegionInfo.FIRST_META_REGIONINFO,
+          serverName));
       return list;
     }
     // Make a version of CollectingVisitor that collects HRegionInfo and ServerAddress
@@ -487,8 +428,7 @@ public class MetaReader {
         this.results.add(this.current);
       }
     };
-    fullScan(catalogTracker, visitor, getTableStartRowForMeta(tableName),
-      Bytes.equals(tableName, HConstants.META_TABLE_NAME));
+    fullScan(catalogTracker, visitor, getTableStartRowForMeta(tableName));
     return visitor.getResults();
   }
 
@@ -546,23 +486,21 @@ public class MetaReader {
    * @param visitor Visitor invoked against each row.
    * @param startrow Where to start the scan. Pass null if want to begin scan
    * at first row.
-   * @param scanRoot True if we are to scan <code>-ROOT-</code> rather than
    * <code>.META.</code>, the default (pass false to scan .META.)
    * @throws IOException
    */
-  static void fullScan(CatalogTracker catalogTracker,
-    final Visitor visitor, final byte [] startrow, final boolean scanRoot)
+  public static void fullScan(CatalogTracker catalogTracker,
+    final Visitor visitor, final byte [] startrow)
   throws IOException {
     Scan scan = new Scan();
     if (startrow != null) scan.setStartRow(startrow);
-    if (startrow == null && !scanRoot) {
+    if (startrow == null) {
       int caching = catalogTracker.getConnection().getConfiguration()
           .getInt(HConstants.HBASE_META_SCANNER_CACHING, 100);
       scan.setCaching(caching);
     }
     scan.addFamily(HConstants.CATALOG_FAMILY);
-    HTable metaTable = scanRoot?
-      getRootHTable(catalogTracker): getMetaHTable(catalogTracker);
+    HTable metaTable = getMetaHTable(catalogTracker);
     ResultScanner scanner = metaTable.getScanner(scan);
     try {
       Result data;

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java Fri Mar  8 22:37:19 2013
@@ -60,12 +60,8 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.SoftValueSortedMap;
 import org.apache.hadoop.hbase.util.Triple;
-import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
-import org.apache.hadoop.hbase.zookeeper.RootRegionTracker;
-import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
-import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
-import org.apache.hadoop.hbase.zookeeper.ZKUtil;
-import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.*;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.zookeeper.KeeperException;
 
@@ -107,7 +103,7 @@ import java.util.concurrent.atomic.Atomi
  * instance does not change its object identity).  Sharing {@link HConnection}
  * instances is usually what you want; all clients of the {@link HConnection}
  * instances share the HConnections' cache of Region locations rather than each
- * having to discover for itself the location of meta, root, etc.  It makes
+ * having to discover for itself the location of meta, etc.  It makes
  * sense for the likes of the pool of HTables class {@link HTablePool}, for
  * instance (If concerned that a single {@link HConnection} is insufficient
  * for sharing amongst clients in say an heavily-multithreaded environment,
@@ -873,10 +869,6 @@ public class HConnectionManager {
      */
     private boolean testTableOnlineState(byte [] tableName, boolean enabled)
     throws IOException {
-      if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
-        // The root region is always enabled
-        return enabled;
-      }
       String tableNameStr = Bytes.toString(tableName);
       ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
       try {
@@ -946,27 +938,24 @@ public class HConnectionManager {
             "table name cannot be null or zero length");
       }
 
-      if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
+      if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
         ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
         try {
-          LOG.debug("Looking up root region location in ZK," +
+          LOG.debug("Looking up meta region location in ZK," +
             " connection=" + this);
           ServerName servername =
-            RootRegionTracker.blockUntilAvailable(zkw, this.rpcTimeout);
+            MetaRegionTracker.blockUntilAvailable(zkw, this.rpcTimeout);
 
-          LOG.debug("Looked up root region location, connection=" + this +
+          LOG.debug("Looked up meta region location, connection=" + this +
             "; serverName=" + ((servername == null) ? "null" : servername));
           if (servername == null) return null;
-          return new HRegionLocation(HRegionInfo.ROOT_REGIONINFO, servername, 0);
+          return new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, servername, 0);
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
           return null;
         } finally {
           zkw.close();
         }
-      } else if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
-        return locateRegionInMeta(HConstants.ROOT_TABLE_NAME, tableName, row,
-          useCache, metaRegionLock, retry);
       } else {
         // Region not in the cache - have to go to the meta RS
         return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
@@ -1025,7 +1014,7 @@ public class HConnectionManager {
     }
 
     /*
-      * Search one of the meta tables (-ROOT- or .META.) for the HRegionLocation
+      * Search the .META. table for the HRegionLocation
       * info that contains the table and row we're seeking.
       */
     private HRegionLocation locateRegionInMeta(final byte [] parentTable,
@@ -1055,7 +1044,7 @@ public class HConnectionManager {
 
         HRegionLocation metaLocation = null;
         try {
-          // locate the root or meta region
+          // locate the meta region
           metaLocation = locateRegion(parentTable, metaKey, true, false);
           // If null still, go around again.
           if (metaLocation == null) continue;
@@ -1087,7 +1076,7 @@ public class HConnectionManager {
               forceDeleteCachedLocation(tableName, row);
             }
 
-            // Query the root or meta region for the location of the meta region
+            // Query the meta region for the location of the meta region
             regionInfoRow = ProtobufUtil.getRowOrBefore(server,
               metaLocation.getRegionInfo().getRegionName(), metaKey,
               HConstants.CATALOG_FAMILY);
@@ -2436,9 +2425,6 @@ public class HConnectionManager {
     public HTableDescriptor getHTableDescriptor(final byte[] tableName)
     throws IOException {
       if (tableName == null || tableName.length == 0) return null;
-      if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
-        return new UnmodifyableHTableDescriptor(HTableDescriptor.ROOT_TABLEDESC);
-      }
       if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
         return HTableDescriptor.META_TABLEDESC;
       }

Added: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaRegionTracker.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaRegionTracker.java?rev=1454607&view=auto
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaRegionTracker.java (added)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/MetaRegionTracker.java Fri Mar  8 22:37:19 2013
@@ -0,0 +1,184 @@
+/**
+ * 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.zookeeper;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.Abortable;
+import org.apache.hadoop.hbase.exceptions.DeserializationException;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
+import org.apache.zookeeper.KeeperException;
+
+/**
+ * Tracks the meta region server location node in zookeeper.
+ * Meta region location is set by <code>RegionServerServices</code>.
+ * This class has a watcher on the meta location and notices changes.
+ */
+@InterfaceAudience.Private
+public class MetaRegionTracker extends ZooKeeperNodeTracker {
+  /**
+   * Creates a meta region location tracker.
+   *
+   * <p>After construction, use {@link #start} to kick off tracking.
+   *
+   * @param watcher
+   * @param abortable
+   */
+  public MetaRegionTracker(ZooKeeperWatcher watcher, Abortable abortable) {
+    super(watcher, watcher.metaServerZNode, abortable);
+  }
+
+  /**
+   * Checks if the meta region location is available.
+   * @return true if meta region location is available, false if not
+   */
+  public boolean isLocationAvailable() {
+    return super.getData(true) != null;
+  }
+
+  /**
+   * Gets the meta region location, if available.  Does not block.  Sets a watcher.
+   * @return server name or null if we failed to get the data.
+   * @throws InterruptedException
+   */
+  public ServerName getMetaRegionLocation() throws InterruptedException {
+    try {
+      return ServerName.parseFrom(super.getData(true));
+    } catch (DeserializationException e) {
+      LOG.warn("Failed parse", e);
+      return null;
+    }
+  }
+
+  /**
+   * Gets the meta region location, if available.  Does not block.  Does not set
+   * a watcher (In this regard it differs from {@link #getMetaRegionLocation}.
+   * @param zkw
+   * @return server name or null if we failed to get the data.
+   * @throws KeeperException
+   */
+  public static ServerName getMetaRegionLocation(final ZooKeeperWatcher zkw)
+  throws KeeperException {
+    try {
+      return ServerName.parseFrom(ZKUtil.getData(zkw, zkw.metaServerZNode));
+    } catch (DeserializationException e) {
+      throw ZKUtil.convert(e);
+    }
+  }
+
+  /**
+   * Gets the meta region location, if available, and waits for up to the
+   * specified timeout if not immediately available.
+   * Given the zookeeper notification could be delayed, we will try to
+   * get the latest data.
+   * @param timeout maximum time to wait, in millis
+   * @return server name for server hosting meta region formatted as per
+   * {@link ServerName}, or null if none available
+   * @throws InterruptedException if interrupted while waiting
+   */
+  public ServerName waitMetaRegionLocation(long timeout)
+  throws InterruptedException {
+    if (false == checkIfBaseNodeAvailable()) {
+      String errorMsg = "Check the value configured in 'zookeeper.znode.parent'. "
+          + "There could be a mismatch with the one configured in the master.";
+      LOG.error(errorMsg);
+      throw new IllegalArgumentException(errorMsg);
+    }
+    try {
+      return ServerName.parseFrom(super.blockUntilAvailable(timeout, true));
+    } catch (DeserializationException e) {
+      LOG.warn("Failed parse", e);
+      return null;
+    }
+  }
+
+  /**
+   * Sets the location of <code>.META.</code> in ZooKeeper to the
+   * specified server address.
+   * @param zookeeper zookeeper reference
+   * @param location The server hosting <code>.META.</code>
+   * @throws KeeperException unexpected zookeeper exception
+   */
+  public static void setMetaLocation(ZooKeeperWatcher zookeeper,
+                                     final ServerName location)
+  throws KeeperException {
+    LOG.info("Setting META region location in ZooKeeper as " + location);
+    // Make the MetaRegionServer pb and then get its bytes and save this as
+    // the znode content.
+    byte [] data = toByteArray(location);
+    try {
+      ZKUtil.createAndWatch(zookeeper, zookeeper.metaServerZNode, data);
+    } catch(KeeperException.NodeExistsException nee) {
+      LOG.debug("META region location already existed, updated location");
+      ZKUtil.setData(zookeeper, zookeeper.metaServerZNode, data);
+    }
+  }
+
+  /**
+   * Build up the znode content.
+   * @param sn What to put into the znode.
+   * @return The content of the meta-region-server znode
+   */
+  static byte [] toByteArray(final ServerName sn) {
+    // ZNode content is a pb message preceeded by some pb magic.
+    HBaseProtos.ServerName pbsn =
+      HBaseProtos.ServerName.newBuilder().setHostName(sn.getHostname()).
+      setPort(sn.getPort()).setStartCode(sn.getStartcode()).build();
+    ZooKeeperProtos.RootRegionServer pbrsr =
+      ZooKeeperProtos.RootRegionServer.newBuilder().setServer(pbsn).build();
+    return ProtobufUtil.prependPBMagic(pbrsr.toByteArray());
+  }
+
+  /**
+   * Deletes the location of <code>.META.</code> in ZooKeeper.
+   * @param zookeeper zookeeper reference
+   * @throws KeeperException unexpected zookeeper exception
+   */
+  public static void deleteMetaLocation(ZooKeeperWatcher zookeeper)
+  throws KeeperException {
+    LOG.info("Unsetting META region location in ZooKeeper");
+    try {
+      // Just delete the node.  Don't need any watches.
+      ZKUtil.deleteNode(zookeeper, zookeeper.metaServerZNode);
+    } catch(KeeperException.NoNodeException nne) {
+      // Has already been deleted
+    }
+  }
+
+  /**
+   * Wait until the meta region is available.
+   * @param zkw
+   * @param timeout
+   * @return ServerName or null if we timed out.
+   * @throws InterruptedException
+   */
+  public static ServerName blockUntilAvailable(final ZooKeeperWatcher zkw,
+      final long timeout)
+  throws InterruptedException {
+    byte [] data = ZKUtil.blockUntilAvailable(zkw, zkw.metaServerZNode, timeout);
+    if (data == null) return null;
+    try {
+      return ServerName.parseFrom(data);
+    } catch (DeserializationException e) {
+      LOG.warn("Failed parse", e);
+      return null;
+    }
+  }
+}

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKUtil.java Fri Mar  8 22:37:19 2013
@@ -949,7 +949,7 @@ public class ZKUtil {
       // Certain znodes are accessed directly by the client,
       // so they must be readable by non-authenticated clients
       if ((node.equals(zkw.baseZNode) == true) ||
-          (node.equals(zkw.rootServerZNode) == true) ||
+          (node.equals(zkw.metaServerZNode) == true) ||
           (node.equals(zkw.getMasterAddressZNode()) == true) ||
           (node.equals(zkw.clusterIdZNode) == true) ||
           (node.equals(zkw.rsZNode) == true) ||
@@ -1579,7 +1579,7 @@ public class ZKUtil {
                                               zkw.backupMasterAddressesZNode)) {
         sb.append("\n ").append(child);
       }
-      sb.append("\nRegion server holding ROOT: " + RootRegionTracker.getRootRegionLocation(zkw));
+      sb.append("\nRegion server holding .META.: " + MetaRegionTracker.getMetaRegionLocation(zkw));
       sb.append("\nRegion servers:");
       for (String child : listChildrenNoWatch(zkw, zkw.rsZNode)) {
         sb.append("\n ").append(child);
@@ -1685,7 +1685,7 @@ public class ZKUtil {
       (data == null? "null": data.length == 0? "empty": (
           znode.startsWith(zkw.assignmentZNode)?
             ZKAssign.toString(data): // We should not be doing this reaching into another class
-          znode.startsWith(zkw.rootServerZNode)?
+          znode.startsWith(zkw.metaServerZNode)?
             getServerNameOrEmptyString(data):
           znode.startsWith(zkw.backupMasterAddressesZNode)?
             getServerNameOrEmptyString(data):

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/zookeeper/ZooKeeperWatcher.java Fri Mar  8 22:37:19 2013
@@ -81,8 +81,8 @@ public class ZooKeeperWatcher implements
 
   // base znode for this cluster
   public String baseZNode;
-  // znode containing location of server hosting root region
-  public String rootServerZNode;
+  // znode containing location of server hosting meta region
+  public String metaServerZNode;
   // znode containing ephemeral nodes of the regionservers
   public String rsZNode;
   // znode containing ephemeral nodes of the draining regionservers
@@ -196,8 +196,8 @@ public class ZooKeeperWatcher implements
   private void setNodeNames(Configuration conf) {
     baseZNode = conf.get(HConstants.ZOOKEEPER_ZNODE_PARENT,
         HConstants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-    rootServerZNode = ZKUtil.joinZNode(baseZNode,
-        conf.get("zookeeper.znode.rootserver", "root-region-server"));
+    metaServerZNode = ZKUtil.joinZNode(baseZNode,
+        conf.get("zookeeper.znode.metaserver", "meta-region-server"));
     rsZNode = ZKUtil.joinZNode(baseZNode,
         conf.get("zookeeper.znode.rs", "rs"));
     drainingZNode = ZKUtil.joinZNode(baseZNode,

Modified: hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon (original)
+++ hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon Fri Mar  8 22:37:19 2013
@@ -61,8 +61,7 @@ if (toRemove > 0) {
     Map.Entry<String, RegionState> e = it.next();
     if (HRegionInfo.FIRST_META_REGIONINFO.getEncodedName().equals(
           e.getKey()) ||
-        HRegionInfo.ROOT_REGIONINFO.getEncodedName().equals(
-          e.getKey()) || regionIDForOldestRIT.equals(e.getKey())) {
+         regionIDForOldestRIT.equals(e.getKey())) {
       // don't remove the meta & the oldest rit regions, they're too interesting!
       continue;
     } 

Modified: hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon (original)
+++ hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon Fri Mar  8 22:37:19 2013
@@ -20,7 +20,6 @@ limitations under the License.
 HMaster master;
 HBaseAdmin admin;
 Map<String, Integer> frags = null;
-ServerName rootLocation = null;
 ServerName metaLocation = null;
 List<ServerName> servers = null;
 Set<ServerName> deadServers = null;
@@ -159,7 +158,7 @@ org.apache.hadoop.hbase.protobuf.generat
                         </%if>
                     </div>
                     <div class="tab-pane" id="tab_catalogTables">
-                        <%if (rootLocation != null) %>
+                        <%if (metaLocation != null) %>
                             <& catalogTables &>
                         </%if>
                     </div>
@@ -222,7 +221,7 @@ org.apache.hadoop.hbase.protobuf.generat
                 <tr>
                     <td>Fragmentation</td>
                     <td><% frags.get("-TOTAL-") != null ? frags.get("-TOTAL-").intValue() + "%" : "n/a" %></td>
-                    <td>Overall fragmentation of all tables, including .META. and -ROOT-.</td>
+                    <td>Overall fragmentation of all tables, including .META.</td>
                 </tr>
                 </%if>
                 <tr>
@@ -267,13 +266,6 @@ org.apache.hadoop.hbase.protobuf.generat
     </%if>
     <th>Description</th>
 </tr>
-<tr>
-    <td><a href="table.jsp?name=<% Bytes.toString(HConstants.ROOT_TABLE_NAME) %>"><% Bytes.toString(HConstants.ROOT_TABLE_NAME) %></a></td>
-  <%if (frags != null)%>
-        <td align="center"><% frags.get("-ROOT-") != null ? frags.get("-ROOT-").intValue() + "%" : "n/a" %></td>
-  </%if>
-    <td>The -ROOT- table holds references to all .META. regions.</td>
-</tr>
   <%if (metaLocation != null) %>
 <tr>
     <td><a href="table.jsp?name=<% Bytes.toString(HConstants.META_TABLE_NAME) %>"><% Bytes.toString(HConstants.META_TABLE_NAME) %></a></td>

Modified: hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon (original)
+++ hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon Fri Mar  8 22:37:19 2013
@@ -64,10 +64,9 @@
     the region named
     <em>domains,apache.org,5464829424211263407</em> is party to the table
     <em>domains</em>, has an id of <em>5464829424211263407</em> and the first key
-    in the region is <em>apache.org</em>.  The <em>-ROOT-</em>
-    and <em>.META.</em> 'tables' are internal sytem tables (or 'catalog' tables in db-speak).
-    The -ROOT- keeps a list of all regions in the .META. table.  The .META. table
-    keeps a list of all regions in the system. The empty key is used to denote
+    in the region is <em>apache.org</em>.  The <em>.META.</em> 'table' is an internal
+    system table (or 'catalog' tables in db-speak).
+    The .META. table keeps a list of all regions in the system. The empty key is used to denote
     table start and table end.  A region with an empty start key is the first region in a table.
     If region has both an empty start and an empty end key, its the only region in the table.  See
     <a href="http://hbase.org">HBase Home</a> for further explication.<p>

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java Fri Mar  8 22:37:19 2013
@@ -90,17 +90,6 @@ public class MetaEditor {
   }
 
   /**
-   * Put the passed <code>p</code> to the <code>.META.</code> table.
-   * @param ct CatalogTracker on whose back we will ride the edit.
-   * @param p Put to add to .META.
-   * @throws IOException
-   */
-  static void putToRootTable(final CatalogTracker ct, final Put p)
-  throws IOException {
-    put(MetaReader.getRootHTable(ct), p);
-  }
-
-  /**
    * Put the passed <code>p</code> to a catalog table.
    * @param ct CatalogTracker on whose back we will ride the edit.
    * @param p Put to add
@@ -108,7 +97,7 @@ public class MetaEditor {
    */
   static void putToCatalogTable(final CatalogTracker ct, final Put p)
   throws IOException {
-    HTable t = MetaReader.getCatalogHTable(ct, p.getRow());
+    HTable t = MetaReader.getCatalogHTable(ct);
     put(t, p);
   }
 

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/catalog/MetaMigrationConvertingToPB.java Fri Mar  8 22:37:19 2013
@@ -164,7 +164,7 @@ public class MetaMigrationConvertingToPB
   throws IOException {
     LOG.info("Starting update of ROOT");
     ConvertToPBMetaVisitor v = new ConvertToPBMetaVisitor(masterServices);
-    MetaReader.fullScan(masterServices.getCatalogTracker(), v, null, true);
+    MetaReader.fullScan(masterServices.getCatalogTracker(), v, null);
     LOG.info("Finished update of ROOT. Total rows updated:" + v.numMigratedRows);
     return v.numMigratedRows;
   }
@@ -177,7 +177,7 @@ public class MetaMigrationConvertingToPB
     LOG.info("Starting update of META");
     ConvertToPBMetaVisitor v = new ConvertToPBMetaVisitor(masterServices);
     MetaReader.fullScan(masterServices.getCatalogTracker(), v);
-    updateRootWithMetaMigrationStatus(masterServices.getCatalogTracker());
+    //updateRootWithMetaMigrationStatus(masterServices.getCatalogTracker());
     LOG.info("Finished update of META. Total rows updated:" + v.numMigratedRows);
     return v.numMigratedRows;
   }
@@ -192,7 +192,8 @@ public class MetaMigrationConvertingToPB
     Put p = new Put(HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
     p.add(HConstants.CATALOG_FAMILY, HConstants.META_VERSION_QUALIFIER,
         Bytes.toBytes(HConstants.META_VERSION));
-    MetaEditor.putToRootTable(catalogTracker, p);
+    // TODO so wrong
+    //MetaEditor.putToRootTable(catalogTracker, p);
     LOG.info("Updated -ROOT- meta version=" + HConstants.META_VERSION);
   }
 
@@ -202,7 +203,7 @@ public class MetaMigrationConvertingToPB
    * @throws IOException
    */
   static boolean isMetaHRIUpdated(final CatalogTracker catalogTracker) throws IOException {
-    List<Result> results = MetaReader.fullScanOfRoot(catalogTracker);
+    List<Result> results = MetaReader.fullScanOfMeta(catalogTracker);
     if (results == null || results.isEmpty()) {
       LOG.info(".META. is not migrated");
       return false;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Fri Mar  8 22:37:19 2013
@@ -73,7 +73,7 @@ import org.apache.hadoop.hbase.util.Envi
 import org.apache.hadoop.hbase.util.KeyLocker;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Threads;
-import org.apache.hadoop.hbase.zookeeper.RootRegionTracker;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
 import org.apache.hadoop.hbase.zookeeper.ZKTable;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
@@ -501,7 +501,7 @@ public class AssignmentManager extends Z
   }
 
   /**
-   * This call is invoked only (1) master assign root and meta;
+   * This call is invoked only (1) master assign meta;
    * (2) during failover mode startup, zk assignment node processing.
    * The locker is set in the caller.
    *
@@ -2144,30 +2144,17 @@ public class AssignmentManager extends Z
   }
 
   /**
-   * Assigns the ROOT region.
-   * <p>
-   * Assumes that ROOT is currently closed and is not being actively served by
-   * any RegionServer.
-   * <p>
-   * Forcibly unsets the current root region location in ZooKeeper and assigns
-   * ROOT to a random RegionServer.
-   * @throws KeeperException
-   */
-  public void assignRoot() throws KeeperException {
-    RootRegionTracker.deleteRootLocation(this.watcher);
-    assign(HRegionInfo.ROOT_REGIONINFO, true);
-  }
-
-  /**
    * Assigns the META region.
    * <p>
    * Assumes that META is currently closed and is not being actively served by
    * any RegionServer.
    * <p>
-   * Forcibly assigns META to a random RegionServer.
+   * Forcibly unsets the current meta region location in ZooKeeper and assigns
+   * META to a random RegionServer.
+   * @throws KeeperException
    */
-  public void assignMeta() {
-    // Force assignment to a random server
+  public void assignMeta() throws KeeperException {
+    MetaRegionTracker.deleteMetaLocation(this.watcher);
     assign(HRegionInfo.FIRST_META_REGIONINFO, true);
   }
 
@@ -2747,10 +2734,6 @@ public class AssignmentManager extends Z
     threadPoolExecutorService.submit(new UnAssignCallable(this, regionInfo));
   }
 
-  public boolean isCarryingRoot(ServerName serverName) {
-    return isCarryingRegion(serverName, HRegionInfo.ROOT_REGIONINFO);
-  }
-
   public boolean isCarryingMeta(ServerName serverName) {
     return isCarryingRegion(serverName, HRegionInfo.FIRST_META_REGIONINFO);
   }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Fri Mar  8 22:37:19 2013
@@ -296,7 +296,7 @@ Server {
   private volatile boolean isActiveMaster = false;
   // flag set after we complete initialization once active (used for testing)
   private volatile boolean initialized = false;
-  // flag set after we complete assignRootAndMeta.
+  // flag set after we complete assignMeta.
   private volatile boolean serverShutdownHandlerEnabled = false;
 
   // Instance of the hbase executor service.
@@ -652,7 +652,7 @@ Server {
    * <li>Set cluster as UP in ZooKeeper</li>
    * <li>Wait for RegionServers to check-in</li>
    * <li>Split logs and perform data recovery, if necessary</li>
-   * <li>Ensure assignment of root and meta regions<li>
+   * <li>Ensure assignment of meta regions<li>
    * <li>Handle either fresh cluster start or master failover</li>
    * </ol>
    *
@@ -734,8 +734,8 @@ Server {
     status.setStatus("Splitting logs after master startup");
     splitLogAfterStartup(this.fileSystemManager);
 
-    // Make sure root and meta assigned before proceeding.
-    if (!assignRootAndMeta(status)) return;
+    // Make sure meta assigned before proceeding.
+    if (!assignMeta(status)) return;
     enableServerShutdownHandler();
 
     // Update meta with new PB serialization if required. i.e migrate all HRI
@@ -826,76 +826,43 @@ Server {
   }
 
   /**
-   * Check <code>-ROOT-</code> and <code>.META.</code> are assigned.  If not,
+   * Check <code>.META.</code> are assigned.  If not,
    * assign them.
    * @throws InterruptedException
    * @throws IOException
    * @throws KeeperException
-   * @return True if root and meta are healthy, assigned
+   * @return True if meta is healthy, assigned
    */
-  boolean assignRootAndMeta(MonitoredTask status)
+  boolean assignMeta(MonitoredTask status)
   throws InterruptedException, IOException, KeeperException {
     int assigned = 0;
     long timeout = this.conf.getLong("hbase.catalog.verification.timeout", 1000);
 
-    // Work on ROOT region.  Is it in zk in transition?
-    status.setStatus("Assigning ROOT region");
-    assignmentManager.getRegionStates().createRegionState(
-      HRegionInfo.ROOT_REGIONINFO);
-    boolean rit = this.assignmentManager.
-      processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.ROOT_REGIONINFO);
-    ServerName currentRootServer = null;
-    boolean rootRegionLocation = catalogTracker.verifyRootRegionLocation(timeout);
-    if (!rit && !rootRegionLocation) {
-      currentRootServer = this.catalogTracker.getRootLocation();
-      splitLogAndExpireIfOnline(currentRootServer);
-      this.assignmentManager.assignRoot();
-      // Make sure a -ROOT- location is set.
-      if (!isRootLocation()) return false;
-      // This guarantees that the transition assigning -ROOT- has completed
-      this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO);
-      assigned++;
-    } else if (rit && !rootRegionLocation) {
-      // Make sure a -ROOT- location is set.
-      if (!isRootLocation()) return false;
-      // This guarantees that the transition assigning -ROOT- has completed
-      this.assignmentManager.waitForAssignment(HRegionInfo.ROOT_REGIONINFO);
-      assigned++;
-    } else if (rootRegionLocation) {
-      // Region already assigned.  We didn't assign it.  Add to in-memory state.
-      this.assignmentManager.regionOnline(HRegionInfo.ROOT_REGIONINFO,
-        this.catalogTracker.getRootLocation());
-    }
-    // Enable the ROOT table if on process fail over the RS containing ROOT
-    // was active.
-    enableCatalogTables(Bytes.toString(HConstants.ROOT_TABLE_NAME));
-    // Check for stopped, just in case
-    if (this.stopped) return false;
-    LOG.info("-ROOT- assigned=" + assigned + ", rit=" + rit +
-      ", location=" + catalogTracker.getRootLocation());
-
-    // Work on meta region
+    // Work on .META. region.  Is it in zk in transition?
     status.setStatus("Assigning META region");
     assignmentManager.getRegionStates().createRegionState(
       HRegionInfo.FIRST_META_REGIONINFO);
-    rit = this.assignmentManager.
+    boolean rit = this.assignmentManager.
       processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO);
-    boolean metaRegionLocation = this.catalogTracker.verifyMetaRegionLocation(timeout);
+    ServerName currentMetaServer = null;
+    boolean metaRegionLocation = catalogTracker.verifyMetaRegionLocation(timeout);
     if (!rit && !metaRegionLocation) {
-      ServerName currentMetaServer =
-        this.catalogTracker.getMetaLocationOrReadLocationFromRoot();
-      if (currentMetaServer != null
-          && !currentMetaServer.equals(currentRootServer)) {
-        splitLogAndExpireIfOnline(currentMetaServer);
-      }
-      assignmentManager.assignMeta();
+      currentMetaServer = this.catalogTracker.getMetaLocation();
+      splitLogAndExpireIfOnline(currentMetaServer);
+      this.assignmentManager.assignMeta();
       enableSSHandWaitForMeta();
+      // Make sure a .META. location is set.
+      if (!isMetaLocation()) return false;
+      // This guarantees that the transition assigning .META. has completed
+      this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
       assigned++;
     } else if (rit && !metaRegionLocation) {
-      // Wait until META region added to region server onlineRegions. See HBASE-5875.
-      enableSSHandWaitForMeta();
+      // Make sure a .META. location is set.
+      if (!isMetaLocation()) return false;
+      // This guarantees that the transition assigning .META. has completed
+      this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
       assigned++;
-    } else {
+    } else if (metaRegionLocation) {
       // Region already assigned.  We didn't assign it.  Add to in-memory state.
       this.assignmentManager.regionOnline(HRegionInfo.FIRST_META_REGIONINFO,
         this.catalogTracker.getMetaLocation());
@@ -903,7 +870,7 @@ Server {
     enableCatalogTables(Bytes.toString(HConstants.META_TABLE_NAME));
     LOG.info(".META. assigned=" + assigned + ", rit=" + rit +
       ", location=" + catalogTracker.getMetaLocation());
-    status.setStatus("META and ROOT assigned.");
+    status.setStatus("META assigned.");
     return true;
   }
 
@@ -916,17 +883,17 @@ Server {
   }
 
   /**
-   * @return True if there a root available
+   * @return True if there a meta available
    * @throws InterruptedException
    */
-  private boolean isRootLocation() throws InterruptedException {
+  private boolean isMetaLocation() throws InterruptedException {
     // Cycle up here in master rather than down in catalogtracker so we can
     // check the master stopped flag every so often.
     while (!this.stopped) {
       try {
-        if (this.catalogTracker.waitForRoot(100) != null) break;
+        if (this.catalogTracker.waitForMeta(100) != null) break;
       } catch (NotAllMetaRegionsOnlineException e) {
-        // Ignore.  I know -ROOT- is not online yet.
+        // Ignore.  I know .META. is not online yet.
       }
     }
     // We got here because we came of above loop.
@@ -1537,8 +1504,7 @@ Server {
   }
 
   private static boolean isCatalogTable(final byte [] tableName) {
-    return Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME) ||
-           Bytes.equals(tableName, HConstants.META_TABLE_NAME);
+    return Bytes.equals(tableName, HConstants.META_TABLE_NAME);
   }
 
   @Override
@@ -1928,7 +1894,7 @@ Server {
    * 1. Create a new ZK session. (since our current one is expired)
    * 2. Try to become a primary master again
    * 3. Initialize all ZK based system trackers.
-   * 4. Assign root and meta. (they are already assigned, but we need to update our
+   * 4. Assign meta. (they are already assigned, but we need to update our
    * internal memory state to reflect it)
    * 5. Process any RIT if any during the process of our recovery.
    *
@@ -2146,8 +2112,8 @@ Server {
 
   /**
    * ServerShutdownHandlerEnabled is set false before completing
-   * assignRootAndMeta to prevent processing of ServerShutdownHandler.
-   * @return true if assignRootAndMeta has completed;
+   * assignMeta to prevent processing of ServerShutdownHandler.
+   * @return true if assignMeta has completed;
    */
   public boolean isServerShutdownHandlerEnabled() {
     return this.serverShutdownHandlerEnabled;

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterFileSystem.java Fri Mar  8 22:37:19 2013
@@ -136,8 +136,8 @@ public class MasterFileSystem {
   /**
    * Create initial layout in filesystem.
    * <ol>
-   * <li>Check if the root region exists and is readable, if not create it.
-   * Create hbase.version and the -ROOT- directory if not one.
+   * <li>Check if the meta region exists and is readable, if not create it.
+   * Create hbase.version and the .META. directory if not one.
    * </li>
    * <li>Create a log archive directory for RS to put archived logs</li>
    * </ol>
@@ -438,14 +438,12 @@ public class MasterFileSystem {
     }
     clusterId = FSUtils.getClusterId(fs, rd);
 
-    // Make sure the root region directory exists!
-    if (!FSUtils.rootRegionExists(fs, rd)) {
+    // Make sure the meta region directory exists!
+    if (!FSUtils.metaRegionExists(fs, rd)) {
       bootstrap(rd, c);
     }
 
-    // Create tableinfo-s for ROOT and META if not already there. This also updates the
-    //descriptors if they are older versions.
-    FSTableDescriptors.createTableDescriptor(fs, rd, HTableDescriptor.ROOT_TABLEDESC, false);
+    // Create tableinfo-s for META if not already there.
     FSTableDescriptors.createTableDescriptor(fs, rd, HTableDescriptor.META_TABLEDESC, false);
 
     return rd;
@@ -479,25 +477,17 @@ public class MasterFileSystem {
 
   private static void bootstrap(final Path rd, final Configuration c)
   throws IOException {
-    LOG.info("BOOTSTRAP: creating ROOT and first META regions");
+    LOG.info("BOOTSTRAP: creating first META region");
     try {
       // Bootstrapping, make sure blockcache is off.  Else, one will be
       // created here in bootstap and it'll need to be cleaned up.  Better to
       // not make it in first place.  Turn off block caching for bootstrap.
       // Enable after.
-      HRegionInfo rootHRI = new HRegionInfo(HRegionInfo.ROOT_REGIONINFO);
-      setInfoFamilyCachingForRoot(false);
       HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
       setInfoFamilyCachingForMeta(false);
-      HRegion root = HRegion.createHRegion(rootHRI, rd, c,
-          HTableDescriptor.ROOT_TABLEDESC);
       HRegion meta = HRegion.createHRegion(metaHRI, rd, c,
           HTableDescriptor.META_TABLEDESC);
-      setInfoFamilyCachingForRoot(true);
       setInfoFamilyCachingForMeta(true);
-      // Add first region from the META table to the ROOT region.
-      HRegion.addRegionToMETA(root, meta);
-      HRegion.closeHRegion(root);
       HRegion.closeHRegion(meta);
     } catch (IOException e) {
       e = RemoteExceptionHandler.checkIOException(e);
@@ -507,19 +497,6 @@ public class MasterFileSystem {
   }
 
   /**
-   * Enable in-memory caching for -ROOT-
-   */
-  public static void setInfoFamilyCachingForRoot(final boolean b) {
-    for (HColumnDescriptor hcd:
-        HTableDescriptor.ROOT_TABLEDESC.getColumnFamilies()) {
-       if (Bytes.equals(hcd.getName(), HConstants.CATALOG_FAMILY)) {
-         hcd.setBlockCacheEnabled(b);
-         hcd.setInMemory(b);
-     }
-    }
-  }
-
-  /**
    * Enable in memory caching for .META.
    */
   public static void setInfoFamilyCachingForMeta(final boolean b) {

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java Fri Mar  8 22:37:19 2013
@@ -60,8 +60,8 @@ public class MasterStatusServlet extends
         
     Map<String, Integer> frags = getFragmentationInfo(master, conf);
     
-    ServerName rootLocation = getRootLocationOrNull(master);
-    ServerName metaLocation = master.getCatalogTracker().getMetaLocation();
+    ServerName metaLocation = getMetaLocationOrNull(master);
+    //ServerName metaLocation = master.getCatalogTracker().getMetaLocation();
     List<ServerName> servers = master.getServerManager().getOnlineServersList();
     Set<ServerName> deadServers = master.getServerManager().getDeadServers().copyServerNames();
 
@@ -71,7 +71,6 @@ public class MasterStatusServlet extends
        tmpl = new MasterStatusTmpl()
       .setFrags(frags)
       .setShowAppendWarning(shouldShowAppendWarning(conf))
-      .setRootLocation(rootLocation)
       .setMetaLocation(metaLocation)
       .setServers(servers)
       .setDeadServers(deadServers)
@@ -88,11 +87,11 @@ public class MasterStatusServlet extends
           master, admin);
   }
 
-  private ServerName getRootLocationOrNull(HMaster master) {
+  private ServerName getMetaLocationOrNull(HMaster master) {
     try {
-      return master.getCatalogTracker().getRootLocation();
+      return master.getCatalogTracker().getMetaLocation();
     } catch (InterruptedException e) {
-      LOG.warn("Unable to get root location", e);
+      LOG.warn("Unable to get meta location", e);
       return null;
     }
   }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java Fri Mar  8 22:37:19 2013
@@ -468,7 +468,7 @@ public class RegionStates {
       } else {
         for (Map.Entry<ServerName, Set<HRegionInfo>> e: serverHoldings.entrySet()) {
           for (HRegionInfo hri: e.getValue()) {
-            if (hri.isMetaRegion() || hri.isRootRegion()) continue;
+            if (hri.isMetaRegion()) continue;
             String tablename = hri.getTableNameAsString();
             Map<ServerName, List<HRegionInfo>> svrToRegions = result.get(tablename);
             if (svrToRegions == null) {

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Fri Mar  8 22:37:19 2013
@@ -164,7 +164,7 @@ public class ServerManager {
    * For all the region servers in this set, HLog split is already completed.
    * <p>
    * ServerShutdownHandler processes a dead server submitted to the handler after
-   * the handler is enabled. It may not be able to complete the processing because root/meta
+   * the handler is enabled. It may not be able to complete the processing because meta
    * is not yet online or master is currently in startup mode.  In this case, the dead
    * server will be parked in this set temporarily.
    */
@@ -484,28 +484,26 @@ public class ServerManager {
       return;
     }
 
-    boolean carryingRoot = services.getAssignmentManager().isCarryingRoot(serverName);
     boolean carryingMeta = services.getAssignmentManager().isCarryingMeta(serverName);
-    if (carryingRoot || carryingMeta) {
+    if (carryingMeta) {
       this.services.getExecutorService().submit(new MetaServerShutdownHandler(this.master,
-        this.services, this.deadservers, serverName, carryingRoot, carryingMeta));
+        this.services, this.deadservers, serverName, carryingMeta));
     } else {
       this.services.getExecutorService().submit(new ServerShutdownHandler(this.master,
         this.services, this.deadservers, serverName, true));
     }
     LOG.debug("Added=" + serverName +
-      " to dead servers, submitted shutdown handler to be executed, root=" +
-        carryingRoot + ", meta=" + carryingMeta);
+      " to dead servers, submitted shutdown handler to be executed meta=" + carryingMeta);
   }
 
   public synchronized void processDeadServer(final ServerName serverName) {
     // When assignment manager is cleaning up the zookeeper nodes and rebuilding the
-    // in-memory region states, region servers could be down. Root/meta table can and
+    // in-memory region states, region servers could be down. Meta table can and
     // should be re-assigned, log splitting can be done too. However, it is better to
     // wait till the cleanup is done before re-assigning user regions.
     //
     // We should not wait in the server shutdown handler thread since it can clog
-    // the handler threads and root/meta table could not be re-assigned in case
+    // the handler threads and meta table could not be re-assigned in case
     // the corresponding server is down. So we queue them up here instead.
     if (!services.getAssignmentManager().isFailoverCleanupDone()) {
       requeuedDeadServers.add(serverName);
@@ -519,7 +517,7 @@ public class ServerManager {
 
   /**
    * Process the servers which died during master's initialization. It will be
-   * called after HMaster#assignRootAndMeta and AssignmentManager#joinCluster.
+   * called after HMaster#assignMeta and AssignmentManager#joinCluster.
    * */
   synchronized void processQueuedDeadServers() {
     if (!services.isServerShutdownHandlerEnabled()) {

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java Fri Mar  8 22:37:19 2013
@@ -376,7 +376,7 @@ public class StochasticLoadBalancer exte
 
       // If this is a special region we always try not to move it.
       // so clear out r.  try again
-      if (r.isMetaRegion() || r.isRootRegion() ) {
+      if (r.isMetaRegion()) {
         r = null;
       }
     }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ClosedRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ClosedRegionHandler.java?rev=1454607&r1=1454606&r2=1454607&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ClosedRegionHandler.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ClosedRegionHandler.java Fri Mar  8 22:37:19 2013
@@ -44,9 +44,8 @@ public class ClosedRegionHandler extends
   private final ClosedPriority priority;
 
   private enum ClosedPriority {
-    ROOT (1),
-    META (2),
-    USER (3);
+    META (1),
+    USER (2);
 
     private final int value;
     ClosedPriority(int value) {
@@ -62,9 +61,7 @@ public class ClosedRegionHandler extends
     super(server, EventType.RS_ZK_REGION_CLOSED);
     this.assignmentManager = assignmentManager;
     this.regionInfo = regionInfo;
-    if(regionInfo.isRootRegion()) {
-      priority = ClosedPriority.ROOT;
-    } else if(regionInfo.isMetaRegion()) {
+    if(regionInfo.isMetaRegion()) {
       priority = ClosedPriority.META;
     } else {
       priority = ClosedPriority.USER;