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:46:17 UTC

svn commit: r1454613 [2/3] - in /hbase/branches/0.95: 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/...

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java Fri Mar  8 22:46:16 2013
@@ -37,16 +37,14 @@ import org.apache.zookeeper.KeeperExcept
  */
 @InterfaceAudience.Private
 public class MetaServerShutdownHandler extends ServerShutdownHandler {
-  private final boolean carryingRoot;
   private final boolean carryingMeta;
   private static final Log LOG = LogFactory.getLog(MetaServerShutdownHandler.class);
   public MetaServerShutdownHandler(final Server server,
       final MasterServices services,
       final DeadServer deadServers, final ServerName serverName,
-      final boolean carryingRoot, final boolean carryingMeta) {
+      final boolean carryingMeta) {
     super(server, services, deadServers, serverName,
       EventType.M_META_SERVER_SHUTDOWN, true);
-    this.carryingRoot = carryingRoot;
     this.carryingMeta = carryingMeta;
   }
 
@@ -65,22 +63,7 @@ public class MetaServerShutdownHandler e
     }
 
     // Assign root and meta if we were carrying them.
-    if (isCarryingRoot()) { // -ROOT-
-      // Check again: region may be assigned to other where because of RIT
-      // timeout
-      if (this.services.getAssignmentManager().isCarryingRoot(serverName)) {
-        LOG.info("Server " + serverName
-            + " was carrying ROOT. Trying to assign.");
-        this.services.getAssignmentManager().regionOffline(
-            HRegionInfo.ROOT_REGIONINFO);
-        verifyAndAssignRootWithRetries();
-      } else {
-        LOG.info("ROOT has been assigned to otherwhere, skip assigning.");
-      }
-    }
-
-    // Carrying meta?
-    if (isCarryingMeta()) {
+    if (isCarryingMeta()) { // .META.
       // Check again: region may be assigned to other where because of RIT
       // timeout
       if (this.services.getAssignmentManager().isCarryingMeta(serverName)) {
@@ -88,37 +71,37 @@ public class MetaServerShutdownHandler e
             + " was carrying META. Trying to assign.");
         this.services.getAssignmentManager().regionOffline(
             HRegionInfo.FIRST_META_REGIONINFO);
-        this.services.getAssignmentManager().assignMeta();
+        verifyAndAssignMetaWithRetries();
       } else {
         LOG.info("META has been assigned to otherwhere, skip assigning.");
       }
-
     }
     super.process();
   }
+
   /**
-   * Before assign the ROOT region, ensure it haven't
+   * Before assign the META region, ensure it haven't
    *  been assigned by other place
    * <p>
-   * Under some scenarios, the ROOT region can be opened twice, so it seemed online
+   * Under some scenarios, the META region can be opened twice, so it seemed online
    * in two regionserver at the same time.
-   * If the ROOT region has been assigned, so the operation can be canceled.
+   * If the META region has been assigned, so the operation can be canceled.
    * @throws InterruptedException
    * @throws IOException
    * @throws KeeperException
    */
-  private void verifyAndAssignRoot()
-  throws InterruptedException, IOException, KeeperException {
+  private void verifyAndAssignMeta()
+      throws InterruptedException, IOException, KeeperException {
     long timeout = this.server.getConfiguration().
-      getLong("hbase.catalog.verification.timeout", 1000);
-    if (!this.server.getCatalogTracker().verifyRootRegionLocation(timeout)) {
-      this.services.getAssignmentManager().assignRoot();
-    } else if (serverName.equals(server.getCatalogTracker().getRootLocation())) {
+        getLong("hbase.catalog.verification.timeout", 1000);
+    if (!this.server.getCatalogTracker().verifyMetaRegionLocation(timeout)) {
+      this.services.getAssignmentManager().assignMeta();
+    } else if (serverName.equals(server.getCatalogTracker().getMetaLocation())) {
       throw new IOException("-ROOT- is onlined on the dead server "
           + serverName);
     } else {
       LOG.info("Skip assigning -ROOT-, because it is online on the "
-          + server.getCatalogTracker().getRootLocation());
+          + server.getCatalogTracker().getMetaLocation());
     }
   }
 
@@ -126,7 +109,7 @@ public class MetaServerShutdownHandler e
    * Failed many times, shutdown processing
    * @throws IOException
    */
-  private void verifyAndAssignRootWithRetries() throws IOException {
+  private void verifyAndAssignMetaWithRetries() throws IOException {
     int iTimes = this.server.getConfiguration().getInt(
         "hbase.catalog.verification.retries", 10);
 
@@ -136,14 +119,14 @@ public class MetaServerShutdownHandler e
     int iFlag = 0;
     while (true) {
       try {
-        verifyAndAssignRoot();
+        verifyAndAssignMeta();
         break;
       } catch (KeeperException e) {
-        this.server.abort("In server shutdown processing, assigning root", e);
+        this.server.abort("In server shutdown processing, assigning meta", e);
         throw new IOException("Aborting", e);
       } catch (Exception e) {
         if (iFlag >= iTimes) {
-          this.server.abort("verifyAndAssignRoot failed after" + iTimes
+          this.server.abort("verifyAndAssignMeta failed after" + iTimes
               + " times retries, aborting", e);
           throw new IOException("Aborting", e);
         }
@@ -159,10 +142,6 @@ public class MetaServerShutdownHandler e
     }
   }
 
-  boolean isCarryingRoot() {
-    return this.carryingRoot;
-  }
-
   boolean isCarryingMeta() {
     return this.carryingMeta;
   }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java Fri Mar  8 22:46:16 2013
@@ -45,9 +45,8 @@ public class OpenedRegionHandler extends
   private final int expectedVersion;
 
   private enum OpenedPriority {
-    ROOT (1),
-    META (2),
-    USER (3);
+    META (1),
+    USER (2);
 
     private final int value;
     OpenedPriority(int value) {
@@ -66,9 +65,7 @@ public class OpenedRegionHandler extends
     this.regionInfo = regionInfo;
     this.sn = sn;
     this.expectedVersion = expectedVersion;
-    if(regionInfo.isRootRegion()) {
-      priority = OpenedPriority.ROOT;
-    } else if(regionInfo.isMetaRegion()) {
+    if(regionInfo.isMetaRegion()) {
       priority = OpenedPriority.META;
     } else {
       priority = OpenedPriority.USER;

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java Fri Mar  8 22:46:16 2013
@@ -88,13 +88,6 @@ public class ServerShutdownHandler exten
   }
 
   /**
-   * @return True if the server we are processing was carrying <code>-ROOT-</code>
-   */
-  boolean isCarryingRoot() {
-    return false;
-  }
-
-  /**
    * @return True if the server we are processing was carrying <code>.META.</code>
    */
   boolean isCarryingMeta() {
@@ -130,8 +123,8 @@ public class ServerShutdownHandler exten
           serverName + ", will retry", ioe);
       }
       // We don't want worker thread in the MetaServerShutdownHandler
-      // executor pool to block by waiting availability of -ROOT-
-      // and .META. server. Otherwise, it could run into the following issue:
+      // executor pool to block by waiting availability of .META.
+      // Otherwise, it could run into the following issue:
       // 1. The current MetaServerShutdownHandler instance For RS1 waits for the .META.
       //    to come online.
       // 2. The newly assigned .META. region server RS2 was shutdown right after
@@ -150,7 +143,7 @@ public class ServerShutdownHandler exten
       // If AssignmentManager hasn't finished rebuilding user regions,
       // we are not ready to assign dead regions either. So we re-queue up
       // the dead server for further processing too.
-      if (isCarryingRoot() || isCarryingMeta() // -ROOT- or .META.
+      if (isCarryingMeta() // .META.
           || !services.getAssignmentManager().isFailoverCleanupDone()) {
         this.services.getServerManager().processDeadServer(serverName);
         return;

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java Fri Mar  8 22:46:16 2013
@@ -487,7 +487,7 @@ public class HRegion implements HeapSize
     // When hbase.regionserver.optionallogflushinterval <= 0 , deferred log sync is disabled.
     this.deferredLogSyncDisabled = conf.getLong("hbase.regionserver.optionallogflushinterval",
         1 * 1000) <= 0;
-    
+
     if (rsServices != null) {
       this.rsAccounting = this.rsServices.getRegionServerAccounting();
       // don't initialize coprocessors if not running within a regionserver
@@ -2202,8 +2202,8 @@ public class HRegion implements HeapSize
 
       // calling the pre CP hook for batch mutation
       if (coprocessorHost != null) {
-        MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp = 
-          new MiniBatchOperationInProgress<Pair<Mutation, Integer>>(batchOp.operations, 
+        MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp =
+          new MiniBatchOperationInProgress<Pair<Mutation, Integer>>(batchOp.operations,
           batchOp.retCodeDetails, batchOp.walEditsFromCoprocessors, firstIndex, lastIndexExclusive);
         if (coprocessorHost.preBatchMutate(miniBatchOp)) return 0L;
       }
@@ -2284,8 +2284,8 @@ public class HRegion implements HeapSize
       walSyncSuccessful = true;
       // calling the post CP hook for batch mutation
       if (coprocessorHost != null) {
-        MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp = 
-          new MiniBatchOperationInProgress<Pair<Mutation, Integer>>(batchOp.operations, 
+        MiniBatchOperationInProgress<Pair<Mutation, Integer>> miniBatchOp =
+          new MiniBatchOperationInProgress<Pair<Mutation, Integer>>(batchOp.operations,
           batchOp.retCodeDetails, batchOp.walEditsFromCoprocessors, firstIndex, lastIndexExclusive);
         coprocessorHost.postBatchMutate(miniBatchOp);
       }
@@ -4225,13 +4225,14 @@ public class HRegion implements HeapSize
   /**
    * Inserts a new region's meta information into the passed
    * <code>meta</code> region. Used by the HMaster bootstrap code adding
-   * new table to ROOT table.
+   * new table to META table.
    *
    * @param meta META HRegion to be updated
    * @param r HRegion to add to <code>meta</code>
    *
    * @throws IOException
    */
+  // TODO remove since only test and merge use this
   public static void addRegionToMETA(HRegion meta, HRegion r)
   throws IOException {
     meta.checkResources();
@@ -5271,13 +5272,9 @@ public class HRegion implements HeapSize
       final boolean majorCompact)
   throws IOException {
     HRegion region = null;
-    String rootStr = Bytes.toString(HConstants.ROOT_TABLE_NAME);
     String metaStr = Bytes.toString(HConstants.META_TABLE_NAME);
     // Currently expects tables have one region only.
-    if (p.getName().startsWith(rootStr)) {
-      region = HRegion.newHRegion(p, log, fs, c, HRegionInfo.ROOT_REGIONINFO,
-        HTableDescriptor.ROOT_TABLEDESC, null);
-    } else if (p.getName().startsWith(metaStr)) {
+    if (p.getName().startsWith(metaStr)) {
       region = HRegion.newHRegion(p, log, fs, c,
         HRegionInfo.FIRST_META_REGIONINFO, HTableDescriptor.META_TABLEDESC, null);
     } else {
@@ -5344,10 +5341,10 @@ public class HRegion implements HeapSize
    * is based on the size of the store.
    */
   public byte[] checkSplit() {
-    // Can't split ROOT/META
+    // Can't split META
     if (this.regionInfo.isMetaTable()) {
       if (shouldForceSplit()) {
-        LOG.warn("Cannot split root/meta regions in HBase 0.20 and above");
+        LOG.warn("Cannot split meta region in HBase 0.20 and above");
       }
       return null;
     }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Fri Mar  8 22:46:16 2013
@@ -46,7 +46,6 @@ import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import javax.management.ObjectName;
@@ -179,10 +178,8 @@ import org.apache.hadoop.hbase.regionser
 import org.apache.hadoop.hbase.regionserver.compactions.CompactionProgress;
 import org.apache.hadoop.hbase.regionserver.handler.CloseMetaHandler;
 import org.apache.hadoop.hbase.regionserver.handler.CloseRegionHandler;
-import org.apache.hadoop.hbase.regionserver.handler.CloseRootHandler;
 import org.apache.hadoop.hbase.regionserver.handler.OpenMetaHandler;
 import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler;
-import org.apache.hadoop.hbase.regionserver.handler.OpenRootHandler;
 import org.apache.hadoop.hbase.regionserver.snapshot.RegionServerSnapshotManager;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.regionserver.wal.HLogFactory;
@@ -202,11 +199,11 @@ import org.apache.hadoop.hbase.util.Thre
 import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker;
 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.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperNodeTracker;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.ipc.RemoteException;
 import org.apache.hadoop.metrics.util.MBeanUtil;
 import org.apache.hadoop.net.DNS;
@@ -312,7 +309,6 @@ public class HRegionServer implements Cl
 
   protected final Configuration conf;
 
-  protected final AtomicBoolean haveRootRegion = new AtomicBoolean(false);
   private boolean useHBaseChecksum; // verify hbase checksums?
   private Path rootDir;
 
@@ -567,7 +563,7 @@ public class HRegionServer implements Cl
 
   /**
    * Utility used ensuring higher quality of service for priority rpcs; e.g.
-   * rpcs to .META. and -ROOT-, etc.
+   * rpcs to .META., etc.
    */
   class QosFunction implements Function<RpcRequestBody,Integer> {
     private final Map<String, Integer> annotatedQos;
@@ -968,7 +964,7 @@ public class HRegionServer implements Cl
       LOG.info("stopping server " + this.serverNameFromMasterPOV);
     }
     // Interrupt catalog tracker here in case any regions being opened out in
-    // handlers are stuck waiting on meta or root.
+    // handlers are stuck waiting on meta.
     if (this.catalogTracker != null) this.catalogTracker.stop();
 
     // stop the snapshot handler, forcefully killing all running tasks
@@ -1027,8 +1023,7 @@ public class HRegionServer implements Cl
   }
 
   private boolean containsMetaTableRegions() {
-    return onlineRegions.containsKey(HRegionInfo.ROOT_REGIONINFO.getEncodedName())
-        || onlineRegions.containsKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
+    return onlineRegions.containsKey(HRegionInfo.FIRST_META_REGIONINFO.getEncodedName());
   }
 
   private boolean areAllUserRegionsOffline() {
@@ -1534,14 +1529,10 @@ public class HRegionServer implements Cl
     this.service = new ExecutorService(getServerName().toString());
     this.service.startExecutorService(ExecutorType.RS_OPEN_REGION,
       conf.getInt("hbase.regionserver.executor.openregion.threads", 3));
-    this.service.startExecutorService(ExecutorType.RS_OPEN_ROOT,
-      conf.getInt("hbase.regionserver.executor.openroot.threads", 1));
     this.service.startExecutorService(ExecutorType.RS_OPEN_META,
       conf.getInt("hbase.regionserver.executor.openmeta.threads", 1));
     this.service.startExecutorService(ExecutorType.RS_CLOSE_REGION,
       conf.getInt("hbase.regionserver.executor.closeregion.threads", 3));
-    this.service.startExecutorService(ExecutorType.RS_CLOSE_ROOT,
-      conf.getInt("hbase.regionserver.executor.closeroot.threads", 1));
     this.service.startExecutorService(ExecutorType.RS_CLOSE_META,
       conf.getInt("hbase.regionserver.executor.closemeta.threads", 1));
     if (conf.getBoolean(StoreScanner.STORESCANNER_PARALLEL_SEEK_ENABLE, false)) {
@@ -1708,13 +1699,10 @@ public class HRegionServer implements Cl
       LOG.error("No sequence number found when opening " + r.getRegionNameAsString());
       openSeqNum = 0;
     }
-    // Update ZK, ROOT or META
-    if (r.getRegionInfo().isRootRegion()) {
-      RootRegionTracker.setRootLocation(getZooKeeper(),
-       this.serverNameFromMasterPOV);
-    } else if (r.getRegionInfo().isMetaRegion()) {
-      MetaEditor.updateMetaLocation(ct, r.getRegionInfo(),
-        this.serverNameFromMasterPOV, openSeqNum);
+    // Update ZK, or META
+    if (r.getRegionInfo().isMetaRegion()) {
+      MetaRegionTracker.setMetaLocation(getZooKeeper(),
+          this.serverNameFromMasterPOV);
     } else {
       MetaEditor.updateRegionLocation(ct, r.getRegionInfo(),
         this.serverNameFromMasterPOV, openSeqNum);
@@ -1974,28 +1962,24 @@ public class HRegionServer implements Cl
   }
 
   /**
-   * Close root and meta regions if we carry them
+   * Close meta region if we carry it
    * @param abort Whether we're running an abort.
    */
   void closeMetaTableRegions(final boolean abort) {
     HRegion meta = null;
-    HRegion root = null;
     this.lock.writeLock().lock();
     try {
       for (Map.Entry<String, HRegion> e: onlineRegions.entrySet()) {
         HRegionInfo hri = e.getValue().getRegionInfo();
-        if (hri.isRootRegion()) {
-          root = e.getValue();
-        } else if (hri.isMetaRegion()) {
+        if (hri.isMetaRegion()) {
           meta = e.getValue();
         }
-        if (meta != null && root != null) break;
+        if (meta != null) break;
       }
     } finally {
       this.lock.writeLock().unlock();
     }
     if (meta != null) closeRegionIgnoreErrors(meta.getRegionInfo(), abort);
-    if (root != null) closeRegionIgnoreErrors(root.getRegionInfo(), abort);
   }
 
   /**
@@ -2490,9 +2474,7 @@ public class HRegionServer implements Cl
 
     CloseRegionHandler crh;
     final HRegionInfo hri = actualRegion.getRegionInfo();
-    if (hri.isRootRegion()) {
-      crh = new CloseRootHandler(this, this, hri, abort, zk, versionOfClosingNode);
-    } else if (hri.isMetaRegion()) {
+    if (hri.isMetaRegion()) {
       crh = new CloseMetaHandler(this, this, hri, abort, zk, versionOfClosingNode);
     } else {
       crh = new CloseRegionHandler(this, this, hri, abort, zk, versionOfClosingNode, sn);
@@ -3487,10 +3469,7 @@ public class HRegionServer implements Cl
         if (previous == null) {
           // If there is no action in progress, we can submit a specific handler.
           // Need to pass the expected version in the constructor.
-          if (region.isRootRegion()) {
-            this.service.submit(new OpenRootHandler(this, this, region, htd,
-                versionOfOfflineNode));
-          } else if (region.isMetaRegion()) {
+          if (region.isMetaRegion()) {
             this.service.submit(new OpenMetaHandler(this, this, region, htd,
                 versionOfOfflineNode));
           } else {

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java Fri Mar  8 22:46:16 2013
@@ -218,7 +218,7 @@ public class OpenRegionHandler extends E
   }
 
   /**
-   * Update ZK, ROOT or META.  This can take a while if for example the
+   * Update ZK or META.  This can take a while if for example the
    * .META. is not available -- if server hosting .META. crashed and we are
    * waiting on it to come back -- so run in a thread and keep updating znode
    * state meantime so master doesn't timeout our region-in-transition.

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java Fri Mar  8 22:46:16 2013
@@ -205,9 +205,9 @@ public class AccessController extends Ba
     HRegionInfo hri = e.getRegion().getRegionInfo();
     byte[] tableName = hri.getTableName();
 
-    // 1. All users need read access to .META. and -ROOT- tables.
+    // 1. All users need read access to .META. table.
     // this is a very common operation, so deal with it quickly.
-    if (hri.isRootRegion() || hri.isMetaRegion()) {
+    if (hri.isMetaRegion()) {
       if (permRequest == Permission.Action.READ) {
         return AuthResult.allow(request, "All users allowed", user,
           permRequest, tableName, families);
@@ -225,7 +225,7 @@ public class AccessController extends Ba
     // e.g. When a table is removed an entry is removed from .META. and _acl_
     // and the user need to be allowed to write on both tables.
     if (permRequest == Permission.Action.WRITE &&
-       (hri.isRootRegion() || hri.isMetaRegion() ||
+       (hri.isMetaRegion() ||
         Bytes.equals(tableName, AccessControlLists.ACL_GLOBAL_NAME)) &&
        (authManager.authorize(user, Permission.Action.CREATE) ||
         authManager.authorize(user, Permission.Action.ADMIN)))

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/FSUtils.java Fri Mar  8 22:46:16 2013
@@ -452,7 +452,7 @@ public abstract class FSUtils {
   throws IOException, DeserializationException {
     String version = getVersion(fs, rootdir);
     if (version == null) {
-      if (!rootRegionExists(fs, rootdir)) {
+      if (!metaRegionExists(fs, rootdir)) {
         // rootDir is empty (no version file and no root region)
         // just create new version file (HBASE-1195)
         setVersion(fs, rootdir, wait, retries);
@@ -768,10 +768,10 @@ public abstract class FSUtils {
    * @return true if exists
    * @throws IOException e
    */
-  public static boolean rootRegionExists(FileSystem fs, Path rootdir)
+  public static boolean metaRegionExists(FileSystem fs, Path rootdir)
   throws IOException {
     Path rootRegionDir =
-      HRegion.getRegionDir(rootdir, HRegionInfo.ROOT_REGIONINFO);
+      HRegion.getRegionDir(rootdir, HRegionInfo.FIRST_META_REGIONINFO);
     return fs.exists(rootRegionDir);
   }
 

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java Fri Mar  8 22:46:16 2013
@@ -93,7 +93,7 @@ import org.apache.hadoop.hbase.util.HBas
 import org.apache.hadoop.hbase.util.hbck.HFileCorruptionChecker;
 import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandler;
 import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandlerImpl;
-import org.apache.hadoop.hbase.zookeeper.RootRegionTracker;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.security.AccessControlException;
@@ -196,7 +196,7 @@ public class HBaseFsck extends Configure
   private boolean fixReferenceFiles = false; // fix lingering reference store file
 
   // limit checking/fixes to listed tables, if empty attempt to check/fix all
-  // -ROOT- and .META. are always checked
+  // .META. are always checked
   private Set<String> tablesIncluded = new HashSet<String>();
   private int maxMerge = DEFAULT_MAX_MERGE; // maximum number of overlapping regions to merge
   private int maxOverlapsToSideline = DEFAULT_OVERLAPS_TO_SIDELINE; // maximum number of overlapping regions to sideline
@@ -233,7 +233,7 @@ public class HBaseFsck extends Configure
    * If tablesIncluded is empty, this map contains all tables.
    * Otherwise, it contains only meta tables and tables in tablesIncluded,
    * unless checkMetaOnly is specified, in which case, it contains only
-   * the meta tables (.META. and -ROOT-).
+   * the meta table
    */
   private SortedMap<String, TableInfo> tablesInfo = new ConcurrentSkipListMap<String,TableInfo>();
 
@@ -257,7 +257,7 @@ public class HBaseFsck extends Configure
     errors = getErrorReporter(conf);
 
     int numThreads = conf.getInt("hbasefsck.numthreads", MAX_NUM_THREADS);
-    executor = new ScheduledThreadPoolExecutor(numThreads);
+    executor = new ScheduledThreadPoolExecutor(numThreads, Threads.newDaemonThreadFactory("hbasefsck"));
   }
 
   /**
@@ -691,8 +691,7 @@ public class HBaseFsck extends Configure
         String tableName = td.getNameAsString();
         errors.detail("  Table: " + tableName + "\t" +
                            (td.isReadOnly() ? "ro" : "rw") + "\t" +
-                           (td.isRootRegion() ? "ROOT" :
-                            (td.isMetaRegion() ? "META" : "    ")) + "\t" +
+                            (td.isMetaRegion() ? "META" : "    ") + "\t" +
                            " families: " + td.getFamilies().size());
       }
     }
@@ -915,23 +914,14 @@ public class HBaseFsck extends Configure
    *
    * @return an open .META. HRegion
    */
-  private HRegion createNewRootAndMeta() throws IOException {
-    Path rootdir = new Path(getConf().get(HConstants.HBASE_DIR));
+  private HRegion createNewMeta() throws IOException {
+    Path rootdir = FSUtils.getRootDir(getConf());
     Configuration c = getConf();
-    HRegionInfo rootHRI = new HRegionInfo(HRegionInfo.ROOT_REGIONINFO);
-    MasterFileSystem.setInfoFamilyCachingForRoot(false);
     HRegionInfo metaHRI = new HRegionInfo(HRegionInfo.FIRST_META_REGIONINFO);
     MasterFileSystem.setInfoFamilyCachingForMeta(false);
-    HRegion root = HRegion.createHRegion(rootHRI, rootdir, c,
-        HTableDescriptor.ROOT_TABLEDESC);
     HRegion meta = HRegion.createHRegion(metaHRI, rootdir, c,
         HTableDescriptor.META_TABLEDESC);
-    MasterFileSystem.setInfoFamilyCachingForRoot(true);
     MasterFileSystem.setInfoFamilyCachingForMeta(true);
-
-    // Add first region from the META table to the ROOT region.
-    HRegion.addRegionToMETA(root, meta);
-    HRegion.closeHRegion(root);
     return meta;
   }
 
@@ -947,9 +937,8 @@ public class HBaseFsck extends Configure
     for (Entry<String, TableInfo> e : tablesInfo.entrySet()) {
       String name = e.getKey();
 
-      // skip "-ROOT-" and ".META."
-      if (Bytes.compareTo(Bytes.toBytes(name), HConstants.ROOT_TABLE_NAME) == 0
-          || Bytes.compareTo(Bytes.toBytes(name), HConstants.META_TABLE_NAME) == 0) {
+      // skip ".META."
+      if (Bytes.compareTo(Bytes.toBytes(name), HConstants.META_TABLE_NAME) == 0) {
         continue;
       }
 
@@ -1029,24 +1018,24 @@ public class HBaseFsck extends Configure
       }
     }
 
-    // we can rebuild, move old root and meta out of the way and start
+    // we can rebuild, move old meta out of the way and start
     LOG.info("HDFS regioninfo's seems good.  Sidelining old .META.");
-    Path backupDir = sidelineOldRootAndMeta();
+    Path backupDir = sidelineOldMeta();
 
     LOG.info("Creating new .META.");
-    HRegion meta = createNewRootAndMeta();
+    HRegion meta = createNewMeta();
 
     // populate meta
     List<Put> puts = generatePuts(tablesInfo);
     if (puts == null) {
       LOG.fatal("Problem encountered when creating new .META. entries.  " +
-        "You may need to restore the previously sidelined -ROOT- and .META.");
+        "You may need to restore the previously sidelined .META.");
       return false;
     }
     meta.put(puts.toArray(new Put[0]));
     HRegion.closeHRegion(meta);
     LOG.info("Success! .META. table rebuilt.");
-    LOG.info("Old -ROOT- and .META. are moved into " + backupDir);
+    LOG.info("Old .META. is moved into " + backupDir);
     return true;
   }
 
@@ -1186,29 +1175,18 @@ public class HBaseFsck extends Configure
   /**
    * @return Path to backup of original directory
    */
-  Path sidelineOldRootAndMeta() throws IOException {
-    // put current -ROOT- and .META. aside.
+  Path sidelineOldMeta() throws IOException {
+    // put current .META. aside.
     Path hbaseDir = new Path(getConf().get(HConstants.HBASE_DIR));
     FileSystem fs = hbaseDir.getFileSystem(getConf());
     Path backupDir = getSidelineDir();
     fs.mkdirs(backupDir);
-
-    sidelineTable(fs, HConstants.ROOT_TABLE_NAME, hbaseDir, backupDir);
     try {
       sidelineTable(fs, HConstants.META_TABLE_NAME, hbaseDir, backupDir);
     } catch (IOException e) {
-      LOG.error("Attempt to sideline meta failed, attempt to revert...", e);
-      try {
-        // move it back.
-        sidelineTable(fs, HConstants.ROOT_TABLE_NAME, backupDir, hbaseDir);
-        LOG.warn("... revert succeed.  -ROOT- and .META. still in "
-            + "original state.");
-      } catch (IOException ioe) {
-        LOG.fatal("... failed to sideline root and meta and failed to restore "
-            + "prevoius state.  Currently in inconsistent state.  To restore "
-            + "try to rename -ROOT- in " + backupDir.getName() + " to "
-            + hbaseDir.getName() + ".", ioe);
-      }
+      LOG.fatal("... failed to sideline meta. Currently in inconsistent state.  To restore "
+      + "try to rename .META. in " + backupDir.getName() + " to "
+      + hbaseDir.getName() + ".", e);
       throw e; // throw original exception
     }
     return backupDir;
@@ -1265,7 +1243,6 @@ public class HBaseFsck extends Configure
         foundVersionFile = true;
       } else {
         if ((!checkMetaOnly && isTableIncluded(dirName)) ||
-            dirName.equals("-ROOT-") ||
             dirName.equals(".META.")) {
           tableDirs.add(file);
         }
@@ -1309,31 +1286,29 @@ public class HBaseFsck extends Configure
   }
 
   /**
-   * Record the location of the ROOT region as found in ZooKeeper,
-   * as if it were in a META table. This is so that we can check
-   * deployment of ROOT.
-   */
-  private boolean recordRootRegion() throws IOException {
-    HRegionLocation rootLocation = connection.locateRegion(
-      HConstants.ROOT_TABLE_NAME, HConstants.EMPTY_START_ROW);
-
-    // Check if Root region is valid and existing
-    if (rootLocation == null || rootLocation.getRegionInfo() == null ||
-        rootLocation.getHostname() == null) {
-      errors.reportError(ERROR_CODE.NULL_ROOT_REGION,
-        "Root Region or some of its attributes are null.");
+   * Record the location of the META region as found in ZooKeeper.
+   */
+  private boolean recordMetaRegion() throws IOException {
+    HRegionLocation metaLocation = connection.locateRegion(
+      HConstants.META_TABLE_NAME, HConstants.EMPTY_START_ROW);
+
+    // Check if Meta region is valid and existing
+    if (metaLocation == null || metaLocation.getRegionInfo() == null ||
+        metaLocation.getHostname() == null) {
+      errors.reportError(ERROR_CODE.NULL_META_REGION,
+        "META region or some of its attributes are null.");
       return false;
     }
     ServerName sn;
     try {
-      sn = getRootRegionServerName();
+      sn = getMetaRegionServerName();
     } catch (KeeperException e) {
       throw new IOException(e);
     }
     MetaEntry m =
-      new MetaEntry(rootLocation.getRegionInfo(), sn, System.currentTimeMillis());
+      new MetaEntry(metaLocation.getRegionInfo(), sn, System.currentTimeMillis());
     HbckInfo hbInfo = new HbckInfo(m);
-    regionInfoMap.put(rootLocation.getRegionInfo().getEncodedName(), hbInfo);
+    regionInfoMap.put(metaLocation.getRegionInfo().getEncodedName(), hbInfo);
     return true;
   }
 
@@ -1353,12 +1328,12 @@ public class HBaseFsck extends Configure
     });
   }
 
-  private ServerName getRootRegionServerName()
+  private ServerName getMetaRegionServerName()
   throws IOException, KeeperException {
     ZooKeeperWatcher zkw = createZooKeeperWatcher();
     ServerName sn = null;
     try {
-      sn = RootRegionTracker.getRootRegionLocation(zkw);
+      sn = MetaRegionTracker.getMetaRegionLocation(zkw);
     } finally {
       zkw.close();
     }
@@ -2521,14 +2496,14 @@ public class HBaseFsck extends Configure
   }
 
   /**
-   * Scan .META. and -ROOT-, adding all regions found to the regionInfo map.
+   * Scan .META., adding all regions found to the regionInfo map.
    * @throws IOException if an error is encountered
    */
   boolean loadMetaEntries() throws IOException {
 
     // get a list of all regions from the master. This involves
     // scanning the META table
-    if (!recordRootRegion()) {
+    if (!recordMetaRegion()) {
       // Will remove later if we can fix it
       errors.reportError("Fatal error: unable to get root region location. Exiting...");
       return false;
@@ -2560,7 +2535,7 @@ public class HBaseFsck extends Configure
           }
           HRegionInfo hri = pair.getFirst();
           if (!(isTableIncluded(hri.getTableNameAsString())
-              || hri.isMetaRegion() || hri.isRootRegion())) {
+              || hri.isMetaRegion())) {
             return true;
           }
           PairOfSameType<HRegionInfo> daughters = HRegionInfo.getDaughterRegions(result);
@@ -2583,11 +2558,6 @@ public class HBaseFsck extends Configure
         }
       }
     };
-
-    // Scan -ROOT- to pick up META regions
-    MetaScanner.metaScan(getConf(), visitor, null, null,
-      Integer.MAX_VALUE, HConstants.ROOT_TABLE_NAME);
-
     if (!checkMetaOnly) {
       // Scan .META. to pick up user regions
       MetaScanner.metaScan(getConf(), visitor);
@@ -2871,7 +2841,7 @@ public class HBaseFsck extends Configure
 
   public interface ErrorReporter {
     public static enum ERROR_CODE {
-      UNKNOWN, NO_META_REGION, NULL_ROOT_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META,
+      UNKNOWN, NO_META_REGION, NULL_META_REGION, NO_VERSION_FILE, NOT_IN_META_HDFS, NOT_IN_META,
       NOT_IN_META_OR_DEPLOYED, NOT_IN_HDFS_OR_DEPLOYED, NOT_IN_HDFS, SERVER_DOES_NOT_MATCH_META, NOT_DEPLOYED,
       MULTI_DEPLOYED, SHOULD_NOT_BE_DEPLOYED, MULTI_META_REGION, RS_CONNECT_FAILURE,
       FIRST_REGION_STARTKEY_NOT_EMPTY, LAST_REGION_ENDKEY_NOT_EMPTY, DUPE_STARTKEYS,
@@ -3416,8 +3386,8 @@ public class HBaseFsck extends Configure
     out.println("   -sleepBeforeRerun <timeInSeconds> Sleep this many seconds" +
         " before checking if the fix worked if run with -fix");
     out.println("   -summary Print only summary of the tables and status.");
-    out.println("   -metaonly Only check the state of ROOT and META tables.");
-    out.println("   -sidelineDir <hdfs://> HDFS path to backup existing meta and root.");
+    out.println("   -metaonly Only check the state of the .META. table.");
+    out.println("   -sidelineDir <hdfs://> HDFS path to backup existing meta.");
 
     out.println("");
     out.println("  Metadata Repair options: (expert features, use with caution!)");

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HMerge.java Fri Mar  8 22:46:16 2013
@@ -121,7 +121,7 @@ class HMerge {
         throw new IllegalStateException(
             "Can not compact META table if instance is on-line");
       }
-      new OfflineMerger(conf, fs).process();
+      // TODO reenable new OfflineMerger(conf, fs).process();
     } else {
       if(!masterIsRunning) {
         throw new IllegalStateException(
@@ -333,90 +333,4 @@ class HMerge {
       }
     }
   }
-
-  /** Instantiated to compact the meta region */
-  private static class OfflineMerger extends Merger {
-    private final List<HRegionInfo> metaRegions = new ArrayList<HRegionInfo>();
-    private final HRegion root;
-
-    OfflineMerger(Configuration conf, FileSystem fs)
-        throws IOException {
-      super(conf, fs, HConstants.META_TABLE_NAME);
-
-      Path rootDir = FSUtils.getRootDir(conf);
-
-      // Scan root region to find all the meta regions
-      root = HRegion.openHRegion(conf, fs, rootDir, HRegionInfo.ROOT_REGIONINFO,
-          HTableDescriptor.ROOT_TABLEDESC, hlog);
-
-      Scan scan = new Scan();
-      scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-      InternalScanner rootScanner = root.getScanner(scan);
-
-      try {
-        List<KeyValue> results = new ArrayList<KeyValue>();
-        boolean hasMore;
-        do {
-          hasMore = rootScanner.next(results);
-          for(KeyValue kv: results) {
-            HRegionInfo info = HRegionInfo.parseFromOrNull(kv.getValue());
-            if (info != null) {
-              metaRegions.add(info);
-            }
-          }
-        } while (hasMore);
-      } finally {
-        rootScanner.close();
-        try {
-          root.close();
-
-        } catch(IOException e) {
-          LOG.error(e);
-        }
-      }
-    }
-
-    @Override
-    protected HRegionInfo[] next() {
-      HRegionInfo[] results = null;
-      if (metaRegions.size() > 0) {
-        results = metaRegions.toArray(new HRegionInfo[metaRegions.size()]);
-        metaRegions.clear();
-      }
-      return results;
-    }
-
-    @Override
-    protected void updateMeta(final byte [] oldRegion1,
-      final byte [] oldRegion2, HRegion newRegion)
-    throws IOException {
-      byte[][] regionsToDelete = {oldRegion1, oldRegion2};
-      for(int r = 0; r < regionsToDelete.length; r++) {
-        Delete delete = new Delete(regionsToDelete[r]);
-        delete.deleteColumns(HConstants.CATALOG_FAMILY,
-            HConstants.REGIONINFO_QUALIFIER);
-        delete.deleteColumns(HConstants.CATALOG_FAMILY,
-            HConstants.SERVER_QUALIFIER);
-        delete.deleteColumns(HConstants.CATALOG_FAMILY,
-            HConstants.STARTCODE_QUALIFIER);
-        delete.deleteColumns(HConstants.CATALOG_FAMILY,
-            HConstants.SPLITA_QUALIFIER);
-        delete.deleteColumns(HConstants.CATALOG_FAMILY,
-            HConstants.SPLITB_QUALIFIER);
-        root.delete(delete, true);
-
-        if(LOG.isDebugEnabled()) {
-          LOG.debug("updated columns in row: " + Bytes.toStringBinary(regionsToDelete[r]));
-        }
-      }
-      HRegionInfo newInfo = newRegion.getRegionInfo();
-      newInfo.setOffline(true);
-
-      Put put = MetaEditor.makePutFromRegionInfo(newInfo);
-      root.put(put);
-      if(LOG.isDebugEnabled()) {
-        LOG.debug("updated columns in row: " + Bytes.toStringBinary(newRegion.getRegionName()));
-      }
-    }
-  }
 }

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/Merge.java Fri Mar  8 22:46:16 2013
@@ -109,23 +109,10 @@ public class Merge extends Configured im
     this.utils = new MetaUtils(getConf());
     this.rootdir = FSUtils.getRootDir(getConf());
     try {
-      if (isMetaTable) {
-        mergeTwoMetaRegions();
-      } else {
-        mergeTwoRegions();
-      }
+      mergeTwoRegions();
       return 0;
     } catch (Exception e) {
       LOG.fatal("Merge failed", e);
-      utils.scanMetaRegion(HRegionInfo.FIRST_META_REGIONINFO,
-          new MetaUtils.ScannerListener() {
-            public boolean processRow(HRegionInfo info) {
-              System.err.println(info.toString());
-              return true;
-            }
-          }
-      );
-
       return -1;
 
     } finally {
@@ -141,155 +128,56 @@ public class Merge extends Configured im
   }
 
   /*
-   * Merge two meta regions. This is unlikely to be needed soon as we have only
-   * seend the meta table split once and that was with 64MB regions. With 256MB
-   * regions, it will be some time before someone has enough data in HBase to
-   * split the meta region and even less likely that a merge of two meta
-   * regions will be needed, but it is included for completeness.
-   */
-  private void mergeTwoMetaRegions() throws IOException {
-    HRegion rootRegion = utils.getRootRegion();
-    Get get = new Get(region1);
-    get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    Result result1 =  rootRegion.get(get);
-    Preconditions.checkState(!result1.isEmpty(), "First region cells can not be null");
-    HRegionInfo info1 = HRegionInfo.getHRegionInfo(result1);
-
-    get = new Get(region2);
-    get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    Result result2 =  rootRegion.get(get);
-    Preconditions.checkState(!result2.isEmpty(), "Second region cells can not be null");
-    HRegionInfo info2 = HRegionInfo.getHRegionInfo(result2);
-    HRegion merged = merge(HTableDescriptor.META_TABLEDESC, info1, rootRegion, info2, rootRegion);
-    LOG.info("Adding " + merged.getRegionInfo() + " to " +
-        rootRegion.getRegionInfo());
-    HRegion.addRegionToMETA(rootRegion, merged);
-    merged.close();
-  }
-
-  private static class MetaScannerListener
-  implements MetaUtils.ScannerListener {
-    private final byte [] region1;
-    private final byte [] region2;
-    private HRegionInfo meta1 = null;
-    private HRegionInfo meta2 = null;
-
-    MetaScannerListener(final byte [] region1, final byte [] region2) {
-      this.region1 = region1;
-      this.region2 = region2;
-    }
-
-    public boolean processRow(HRegionInfo info) {
-      if (meta1 == null && HRegion.rowIsInRange(info, region1)) {
-        meta1 = info;
-      }
-      if (region2 != null && meta2 == null &&
-          HRegion.rowIsInRange(info, region2)) {
-        meta2 = info;
-      }
-      return meta1 == null || (region2 != null && meta2 == null);
-    }
-
-    HRegionInfo getMeta1() {
-      return meta1;
-    }
-
-    HRegionInfo getMeta2() {
-      return meta2;
-    }
-  }
-
-  /*
    * Merges two regions from a user table.
    */
   private void mergeTwoRegions() throws IOException {
     LOG.info("Merging regions " + Bytes.toStringBinary(this.region1) + " and " +
         Bytes.toStringBinary(this.region2) + " in table " + Bytes.toString(this.tableName));
-    // Scan the root region for all the meta regions that contain the regions
-    // we're merging.
-    MetaScannerListener listener = new MetaScannerListener(region1, region2);
-    this.utils.scanRootRegion(listener);
-    HRegionInfo meta1 = listener.getMeta1();
-    if (meta1 == null) {
-      throw new IOException("Could not find meta region for " + Bytes.toStringBinary(region1));
-    }
-    HRegionInfo meta2 = listener.getMeta2();
-    if (meta2 == null) {
-      throw new IOException("Could not find meta region for " + Bytes.toStringBinary(region2));
-    }
-    LOG.info("Found meta for region1 " + Bytes.toStringBinary(meta1.getRegionName()) +
-      ", meta for region2 " + Bytes.toStringBinary(meta2.getRegionName()));
-    HRegion metaRegion1 = this.utils.getMetaRegion(meta1);
+    HRegion meta = this.utils.getMetaRegion();
     Get get = new Get(region1);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    Result result1 =  metaRegion1.get(get);
+    Result result1 =  meta.get(get);
     Preconditions.checkState(!result1.isEmpty(),
         "First region cells can not be null");
     HRegionInfo info1 = HRegionInfo.getHRegionInfo(result1);
     if (info1 == null) {
       throw new NullPointerException("info1 is null using key " +
-          Bytes.toStringBinary(region1) + " in " + meta1);
-    }
-
-    HRegion metaRegion2;
-    if (Bytes.equals(meta1.getRegionName(), meta2.getRegionName())) {
-      metaRegion2 = metaRegion1;
-    } else {
-      metaRegion2 = utils.getMetaRegion(meta2);
+          Bytes.toStringBinary(region1) + " in " + meta);
     }
     get = new Get(region2);
     get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    Result result2 =  metaRegion2.get(get);
+    Result result2 =  meta.get(get);
     Preconditions.checkState(!result2.isEmpty(),
         "Second region cells can not be null");
     HRegionInfo info2 = HRegionInfo.getHRegionInfo(result2);
     if (info2 == null) {
-      throw new NullPointerException("info2 is null using key " + meta2);
+      throw new NullPointerException("info2 is null using key " + meta);
     }
     HTableDescriptor htd = FSTableDescriptors.getTableDescriptor(FileSystem.get(getConf()),
       this.rootdir, this.tableName);
-    HRegion merged = merge(htd, info1, metaRegion1, info2, metaRegion2);
-
-    // Now find the meta region which will contain the newly merged region
+    HRegion merged = merge(htd, meta, info1, info2);
 
-    listener = new MetaScannerListener(merged.getRegionName(), null);
-    utils.scanRootRegion(listener);
-    HRegionInfo mergedInfo = listener.getMeta1();
-    if (mergedInfo == null) {
-      throw new IOException("Could not find meta region for " +
-          Bytes.toStringBinary(merged.getRegionName()));
-    }
-    HRegion mergeMeta;
-    if (Bytes.equals(mergedInfo.getRegionName(), meta1.getRegionName())) {
-      mergeMeta = metaRegion1;
-    } else if (Bytes.equals(mergedInfo.getRegionName(), meta2.getRegionName())) {
-      mergeMeta = metaRegion2;
-    } else {
-      mergeMeta = utils.getMetaRegion(mergedInfo);
-    }
     LOG.info("Adding " + merged.getRegionInfo() + " to " +
-        mergeMeta.getRegionInfo());
+        meta.getRegionInfo());
 
-    HRegion.addRegionToMETA(mergeMeta, merged);
+    HRegion.addRegionToMETA(meta, merged);
     merged.close();
   }
 
   /*
    * Actually merge two regions and update their info in the meta region(s)
-   * If the meta is split, meta1 may be different from meta2. (and we may have
-   * to scan the meta if the resulting merged region does not go in either)
    * Returns HRegion object for newly merged region
    */
-  private HRegion merge(final HTableDescriptor htd, HRegionInfo info1,
-      HRegion meta1, HRegionInfo info2, HRegion meta2)
+  private HRegion merge(final HTableDescriptor htd, HRegion meta,
+                        HRegionInfo info1, HRegionInfo info2)
   throws IOException {
     if (info1 == null) {
       throw new IOException("Could not find " + Bytes.toStringBinary(region1) + " in " +
-          Bytes.toStringBinary(meta1.getRegionName()));
+          Bytes.toStringBinary(meta.getRegionName()));
     }
     if (info2 == null) {
       throw new IOException("Cound not find " + Bytes.toStringBinary(region2) + " in " +
-          Bytes.toStringBinary(meta2.getRegionName()));
+          Bytes.toStringBinary(meta.getRegionName()));
     }
     HRegion merged = null;
     HLog log = utils.getLog();
@@ -312,8 +200,8 @@ public class Merge extends Configured im
     // Remove the old regions from meta.
     // HRegion.merge has already deleted their files
 
-    removeRegionFromMeta(meta1, info1);
-    removeRegionFromMeta(meta2, info2);
+    removeRegionFromMeta(meta, info1);
+    removeRegionFromMeta(meta, info2);
 
     this.mergeInfo = merged.getRegionInfo();
     return merged;

Modified: hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java (original)
+++ hbase/branches/0.95/hbase-server/src/main/java/org/apache/hadoop/hbase/util/MetaUtils.java Fri Mar  8 22:46:16 2013
@@ -31,7 +31,6 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -62,7 +61,7 @@ public class MetaUtils {
   private final Configuration conf;
   private FileSystem fs;
   private HLog log;
-  private HRegion rootRegion;
+  private HRegion metaRegion;
   private Map<byte [], HRegion> metaRegions = Collections.synchronizedSortedMap(
     new TreeMap<byte [], HRegion>(Bytes.BYTES_COMPARATOR));
 
@@ -80,7 +79,7 @@ public class MetaUtils {
   public MetaUtils(Configuration conf) throws IOException {
     this.conf = conf;
     conf.setInt("hbase.client.retries.number", 1);
-    this.rootRegion = null;
+    this.metaRegion = null;
     initialize();
   }
 
@@ -107,31 +106,14 @@ public class MetaUtils {
   }
 
   /**
-   * @return HRegion for root region
+   * @return HRegion for meta region
    * @throws IOException e
    */
-  public HRegion getRootRegion() throws IOException {
-    if (this.rootRegion == null) {
-      openRootRegion();
+  public HRegion getMetaRegion() throws IOException {
+    if (this.metaRegion == null) {
+      openMetaRegion();
     }
-    return this.rootRegion;
-  }
-
-  /**
-   * Open or return cached opened meta region
-   *
-   * @param metaInfo HRegionInfo for meta region
-   * @return meta HRegion
-   * @throws IOException e
-   */
-  public HRegion getMetaRegion(HRegionInfo metaInfo) throws IOException {
-    HRegion meta = metaRegions.get(metaInfo.getRegionName());
-    if (meta == null) {
-      meta = openMetaRegion(metaInfo);
-      LOG.info("OPENING META " + meta.toString());
-      this.metaRegions.put(metaInfo.getRegionName(), meta);
-    }
-    return meta;
+    return this.metaRegion;
   }
 
   /**
@@ -140,13 +122,13 @@ public class MetaUtils {
    * MetaUtils edit session.
    */
   public void shutdown() {
-    if (this.rootRegion != null) {
+    if (this.metaRegion != null) {
       try {
-        this.rootRegion.close();
+        this.metaRegion.close();
       } catch (IOException e) {
-        LOG.error("closing root region", e);
+        LOG.error("closing meta region", e);
       } finally {
-        this.rootRegion = null;
+        this.metaRegion = null;
       }
     }
     try {
@@ -171,229 +153,14 @@ public class MetaUtils {
     }
   }
 
-  /**
-   * Used by scanRootRegion and scanMetaRegion to call back the caller so it
-   * can process the data for a row.
-   */
-  public interface ScannerListener {
-    /**
-     * Callback so client of scanner can process row contents
-     *
-     * @param info HRegionInfo for row
-     * @return false to terminate the scan
-     * @throws IOException e
-     */
-    public boolean processRow(HRegionInfo info) throws IOException;
-  }
-
-  /**
-   * Scans the root region. For every meta region found, calls the listener with
-   * the HRegionInfo of the meta region.
-   *
-   * @param listener method to be called for each meta region found
-   * @throws IOException e
-   */
-  public void scanRootRegion(ScannerListener listener) throws IOException {
-    // Open root region so we can scan it
-    if (this.rootRegion == null) {
-      openRootRegion();
+  private synchronized HRegion openMetaRegion() throws IOException {
+    if (this.metaRegion != null) {
+      return this.metaRegion;
     }
-    scanMetaRegion(this.rootRegion, listener);
-  }
-
-  /**
-   * Scan the passed in metaregion <code>m</code> invoking the passed
-   * <code>listener</code> per row found.
-   * @param r region
-   * @param listener scanner listener
-   * @throws IOException e
-   */
-  public void scanMetaRegion(final HRegion r, final ScannerListener listener)
-  throws IOException {
-    Scan scan = new Scan();
-    scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    InternalScanner s = r.getScanner(scan);
-    try {
-      List<KeyValue> results = new ArrayList<KeyValue>();
-      boolean hasNext = true;
-      do {
-        hasNext = s.next(results);
-        HRegionInfo info = null;
-        for (KeyValue kv: results) {
-          info = HRegionInfo.parseFromOrNull(kv.getValue());
-          if (info == null) {
-            LOG.warn("Region info is null for row " +
-              Bytes.toStringBinary(kv.getRow()) + " in table " +
-              r.getTableDesc().getNameAsString());
-          }
-          continue;
-        }
-        if (!listener.processRow(info)) {
-          break;
-        }
-        results.clear();
-      } while (hasNext);
-    } finally {
-      s.close();
-    }
-  }
-
-  /**
-   * Scans a meta region. For every region found, calls the listener with
-   * the HRegionInfo of the region.
-   * TODO: Use Visitor rather than Listener pattern.  Allow multiple Visitors.
-   * Use this everywhere we scan meta regions: e.g. in metascanners, in close
-   * handling, etc.  Have it pass in the whole row, not just HRegionInfo.
-   * <p>Use for reading meta only.  Does not close region when done.
-   * Use {@link #getMetaRegion(HRegionInfo)} instead if writing.  Adds
-   * meta region to list that will get a close on {@link #shutdown()}.
-   *
-   * @param metaRegionInfo HRegionInfo for meta region
-   * @param listener method to be called for each meta region found
-   * @throws IOException e
-   */
-  public void scanMetaRegion(HRegionInfo metaRegionInfo,
-    ScannerListener listener)
-  throws IOException {
-    // Open meta region so we can scan it
-    HRegion metaRegion = openMetaRegion(metaRegionInfo);
-    scanMetaRegion(metaRegion, listener);
-  }
-
-  private synchronized HRegion openRootRegion() throws IOException {
-    if (this.rootRegion != null) {
-      return this.rootRegion;
-    }
-    this.rootRegion = HRegion.openHRegion(HRegionInfo.ROOT_REGIONINFO,
-      HTableDescriptor.ROOT_TABLEDESC, getLog(),
+    this.metaRegion = HRegion.openHRegion(HRegionInfo.FIRST_META_REGIONINFO,
+      HTableDescriptor.META_TABLEDESC, getLog(),
       this.conf);
-    this.rootRegion.compactStores();
-    return this.rootRegion;
-  }
-
-  private HRegion openMetaRegion(HRegionInfo metaInfo) throws IOException {
-    HRegion meta = HRegion.openHRegion(metaInfo, HTableDescriptor.META_TABLEDESC,
-      getLog(), this.conf);
-    meta.compactStores();
-    return meta;
-  }
-
-  /**
-   * Set a single region on/offline.
-   * This is a tool to repair tables that have offlined tables in their midst.
-   * Can happen on occasion.  Use at your own risk.  Call from a bit of java
-   * or jython script.  This method is 'expensive' in that it creates a
-   * {@link HTable} instance per invocation to go against <code>.META.</code>
-   * @param c A configuration that has its <code>hbase.master</code>
-   * properly set.
-   * @param row Row in the catalog .META. table whose HRegionInfo's offline
-   * status we want to change.
-   * @param onlineOffline Pass <code>true</code> to OFFLINE the region.
-   * @throws IOException e
-   */
-  public static void changeOnlineStatus (final Configuration c,
-      final byte [] row, final boolean onlineOffline)
-  throws IOException {
-    HTable t = new HTable(c, HConstants.META_TABLE_NAME);
-    Get get = new Get(row);
-    get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-    Result res = t.get(get);
-    KeyValue [] kvs = res.raw();
-    if(kvs.length <= 0) {
-      throw new IOException("no information for row " + Bytes.toString(row));
-    }
-    HRegionInfo info = HRegionInfo.getHRegionInfo(res);
-    if (info == null) {
-      throw new IOException("no information for row " + Bytes.toString(row));
-    }
-
-    info.setOffline(onlineOffline);
-    MetaEditor.addRegionToMeta(t, info);
-
-    Delete delete = new Delete(row);
-    delete.deleteColumns(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
-    delete.deleteColumns(HConstants.CATALOG_FAMILY,
-        HConstants.STARTCODE_QUALIFIER);
-
-    t.delete(delete);
-  }
-
-  /**
-   * Update COL_REGIONINFO in meta region r with HRegionInfo hri
-   *
-   * @param r region
-   * @param hri region info
-   * @throws IOException e
-   */
-  public void updateMETARegionInfo(HRegion r, final HRegionInfo hri)
-  throws IOException {
-    if (LOG.isDebugEnabled()) {
-      Get get = new Get(hri.getRegionName());
-      get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-      Result res = r.get(get);
-      KeyValue [] kvs = res.raw();
-      if(kvs.length <= 0) {
-        return;
-      }
-
-      HRegionInfo h = HRegionInfo.getHRegionInfo(res);
-      if (h == null) {
-        return;
-      }
-      LOG.debug("Old " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" +
-          Bytes.toString(HConstants.REGIONINFO_QUALIFIER) + " for " +
-          hri.toString() + " in " + r.toString() + " is: " + h.toString());
-    }
-
-    Put put = MetaEditor.makePutFromRegionInfo(hri);
-    r.put(put);
-
-    if (LOG.isDebugEnabled()) {
-      Get get = new Get(hri.getRegionName());
-      get.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
-      Result res = r.get(get);
-      KeyValue [] kvs = res.raw();
-      if(kvs.length <= 0) {
-        return;
-      }
-      HRegionInfo h = HRegionInfo.getHRegionInfo(res);
-      if (h == null) {
-        return;
-      }
-      LOG.debug("New " + Bytes.toString(HConstants.CATALOG_FAMILY) + ":" +
-            Bytes.toString(HConstants.REGIONINFO_QUALIFIER) + " for " +
-            hri.toString() + " in " + r.toString() + " is: " +  h.toString());
-    }
-  }
-
-  /**
-   * @return List of {@link HRegionInfo} rows found in the ROOT or META
-   * catalog table.
-   * @param tableName Name of table to go looking for.
-   * @throws IOException e
-   * @see #getMetaRegion(HRegionInfo)
-   */
-  public List<HRegionInfo> getMETARows(final byte [] tableName)
-  throws IOException {
-    final List<HRegionInfo> result = new ArrayList<HRegionInfo>();
-    // If passed table name is META, then  return the root region.
-    if (Bytes.equals(HConstants.META_TABLE_NAME, tableName)) {
-      result.add(openRootRegion().getRegionInfo());
-      return result;
-    }
-    // Return all meta regions that contain the passed tablename.
-    scanRootRegion(new ScannerListener() {
-      private final Log SL_LOG = LogFactory.getLog(this.getClass());
-
-      public boolean processRow(HRegionInfo info) throws IOException {
-        SL_LOG.debug("Testing " + info);
-        if (Bytes.equals(info.getTableName(),
-            HConstants.META_TABLE_NAME)) {
-          result.add(info);
-          return false;
-        }
-        return true;
-      }});
-    return result;
+    this.metaRegion.compactStores();
+    return this.metaRegion;
   }
 }

Modified: hbase/branches/0.95/hbase-server/src/main/resources/hbase-webapps/master/table.jsp
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/resources/hbase-webapps/master/table.jsp?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/resources/hbase-webapps/master/table.jsp (original)
+++ hbase/branches/0.95/hbase-server/src/main/resources/hbase-webapps/master/table.jsp Fri Mar  8 22:46:16 2013
@@ -41,7 +41,7 @@
   String tableName = request.getParameter("name");
   HTable table = new HTable(conf, tableName);
   String tableHeader = "<h2>Table Regions</h2><table class=\"table table-striped\"><tr><th>Name</th><th>Region Server</th><th>Start Key</th><th>End Key</th><th>Requests</th></tr>";
-  ServerName rl = master.getCatalogTracker().getRootLocation();
+  ServerName rl = master.getCatalogTracker().getMetaLocation();
   boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
   boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false);
   Map<String, Integer> frags = null;
@@ -191,22 +191,7 @@
     </div>
     <div class="row">
 <%
-  if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {
-%>
-<%= tableHeader %>
-<%
-  String url = "http://" + rl.getHostname() + ":" + infoPort + "/";
-%>
-<tr>
-  <td><%= tableName %></td>
-  <td><a href="<%= url %>"><%= rl.getHostname() %>:<%= rl.getPort() %></a></td>
-  <td>-</td>
-  <td></td>
-  <td>-</td>
-</tr>
-</table>
-<%
-  } else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
+  if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
 %>
 <%= tableHeader %>
 <%

Modified: hbase/branches/0.95/hbase-server/src/main/ruby/hbase/admin.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/ruby/hbase/admin.rb?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/ruby/hbase/admin.rb (original)
+++ hbase/branches/0.95/hbase-server/src/main/ruby/hbase/admin.rb Fri Mar  8 22:46:16 2013
@@ -313,7 +313,6 @@ module Hbase
     def describe(table_name)
       tables = @admin.listTables.to_a
       tables << org.apache.hadoop.hbase.HTableDescriptor::META_TABLEDESC
-      tables << org.apache.hadoop.hbase.HTableDescriptor::ROOT_TABLEDESC
 
       tables.each do |t|
         # Found the table

Modified: hbase/branches/0.95/hbase-server/src/main/ruby/hbase/table.rb
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/main/ruby/hbase/table.rb?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/main/ruby/hbase/table.rb (original)
+++ hbase/branches/0.95/hbase-server/src/main/ruby/hbase/table.rb Fri Mar  8 22:46:16 2013
@@ -459,7 +459,7 @@ EOF
     # Checks if current table is one of the 'meta' tables
     def is_meta_table?
       tn = @table.table_name
-      org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::META_TABLE_NAME) || org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::ROOT_TABLE_NAME)
+      org.apache.hadoop.hbase.util.Bytes.equals(tn, org.apache.hadoop.hbase.HConstants::META_TABLE_NAME)
     end
 
     # Returns family and (when has it) qualifier for a column name

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestCase.java Fri Mar  8 22:46:16 2013
@@ -60,7 +60,6 @@ public abstract class HBaseTestCase exte
   private boolean localfs = false;
   protected static Path testDir = null;
   protected FileSystem fs = null;
-  protected HRegion root = null;
   protected HRegion meta = null;
   protected static final char FIRST_CHAR = 'a';
   protected static final char LAST_CHAR = 'z';
@@ -657,17 +656,13 @@ public abstract class HBaseTestCase exte
    * method. It does cleanup.
    * @throws IOException
    */
-  protected void createRootAndMetaRegions() throws IOException {
-    root = HRegion.createHRegion(HRegionInfo.ROOT_REGIONINFO, testDir,
-        conf, HTableDescriptor.ROOT_TABLEDESC);
+  protected void createMetaRegion() throws IOException {
     meta = HRegion.createHRegion(HRegionInfo.FIRST_META_REGIONINFO, testDir,
         conf, HTableDescriptor.META_TABLEDESC);
-    HRegion.addRegionToMETA(root, meta);
   }
 
   protected void closeRootAndMeta() throws IOException {
     HRegion.closeHRegion(meta);
-    HRegion.closeHRegion(root);
   }
 
   public static void assertByteEquals(byte[] expected,

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java Fri Mar  8 22:46:16 2013
@@ -290,7 +290,7 @@ public class TestDrainingServer {
 
   private static boolean isAllRegionsOnline() {
     return TEST_UTIL.getMiniHBaseCluster().countServedRegions() ==
-        (COUNT_OF_REGIONS + 2 /*catalog regions*/);
+        (COUNT_OF_REGIONS + 1 /*catalog regions*/);
   }
 
 }

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/TestRegionRebalancing.java Fri Mar  8 22:46:16 2013
@@ -188,7 +188,7 @@ public class TestRegionRebalancing {
         if (!(avg > 2.0 && serverLoad <= avgLoadPlusSlop
             && serverLoad >= avgLoadMinusSlop)) {
           for (HRegionInfo hri : ProtobufUtil.getOnlineRegions(server)) {
-            if (hri.isMetaRegion() || hri.isRootRegion()) serverLoad--;
+            if (hri.isMetaRegion()) serverLoad--;
             // LOG.debug(hri.getRegionNameAsString());
           }
           if (!(serverLoad <= avgLoadPlusSlop && serverLoad >= avgLoadMinusSlop)) {
@@ -234,7 +234,7 @@ public class TestRegionRebalancing {
    * Wait until all the regions are assigned.
    */
   private void waitForAllRegionsAssigned() throws IOException {
-    int totalRegions = HBaseTestingUtility.KEYS.length+2;
+    int totalRegions = HBaseTestingUtility.KEYS.length+1;
     while (getRegionCount() < totalRegions) {
     // while (!cluster.getMaster().allRegionsAssigned()) {
       LOG.debug("Waiting for there to be "+ totalRegions +" regions, but there are " + getRegionCount() + " right now.");

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestCatalogTracker.java Fri Mar  8 22:46:16 2013
@@ -54,7 +54,7 @@ import org.apache.hadoop.hbase.protobuf.
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.GetResponse;
 import org.apache.hadoop.hbase.util.Bytes;
 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.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.util.Progressable;
@@ -132,22 +132,22 @@ public class TestCatalogTracker {
     HConnection connection = Mockito.mock(HConnection.class);
     constructAndStartCatalogTracker(connection);
     try {
-      RootRegionTracker.setRootLocation(this.watcher,
-        new ServerName("example.com", 1234, System.currentTimeMillis()));
+      MetaRegionTracker.setMetaLocation(this.watcher,
+          new ServerName("example.com", 1234, System.currentTimeMillis()));
     } finally {
-      // Clean out root location or later tests will be confused... they presume
+      // Clean out meta location or later tests will be confused... they presume
       // start fresh in zk.
-      RootRegionTracker.deleteRootLocation(this.watcher);
+      MetaRegionTracker.deleteMetaLocation(this.watcher);
     }
   }
 
   /**
-   * Test interruptable while blocking wait on root and meta.
+   * Test interruptable while blocking wait on meta.
    * @throws IOException
    * @throws ServiceException
    * @throws InterruptedException
    */
-  @Test public void testInterruptWaitOnMetaAndRoot()
+  @Test public void testInterruptWaitOnMeta()
   throws IOException, InterruptedException, ServiceException {
     final ClientProtocol client = Mockito.mock(ClientProtocol.class);
     HConnection connection = mockConnection(null, client);
@@ -155,8 +155,6 @@ public class TestCatalogTracker {
       Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())).
       thenReturn(GetResponse.newBuilder().build());
       final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-      ServerName hsa = ct.getRootLocation();
-      Assert.assertNull(hsa);
       ServerName meta = ct.getMetaLocation();
       Assert.assertNull(meta);
       Thread t = new Thread() {
@@ -182,86 +180,6 @@ public class TestCatalogTracker {
     }
   }
 
-  /**
-   * Test for HBASE-4288.  Throw an IOE when trying to verify meta region and
-   * prove it doesn't cause master shutdown.
-   * @see <a href="https://issues.apache.org/jira/browse/HBASE-4288">HBASE-4288</a>
-   * @throws IOException
-   * @throws InterruptedException
-   * @throws KeeperException
-   */
-  @Test
-  public void testServerNotRunningIOException()
-  throws IOException, InterruptedException, KeeperException, ServiceException {
-    // Mock an Admin and a Client.
-    final AdminProtocol admin = Mockito.mock(AdminProtocol.class);
-    final ClientProtocol client = Mockito.mock(ClientProtocol.class);
-    HConnection connection = mockConnection(admin, client);
-    try {
-      // If a 'getRegionInfo' is called on mocked AdminProtocol, throw IOE
-      // the first time.  'Succeed' the second time we are called.
-      GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
-      builder.setRegionInfo(HRegionInfo.convert(new HRegionInfo(Bytes.toBytes("test"))));
-      Mockito.when(admin.getRegionInfo((RpcController)Mockito.any(),
-        (GetRegionInfoRequest)Mockito.any())).thenThrow(
-          new ServiceException(new IOException("Server not running, aborting"))).
-        thenReturn(builder.build());
-
-      // After we encounter the above 'Server not running', we should catch the
-      // IOE and go into retrying for the meta mode.  We'll do gets on -ROOT- to
-      // get new meta location.  Return something so this 'get' succeeds
-      // (here we mock up getRegionServerWithRetries, the wrapper around
-      // the actual get).
-
-      // TODO: Refactor.  This method has been moved out of HConnection.
-      // It works for now but has been deprecated.
-      Mockito.when(connection.getRegionServerWithRetries((ServerCallable<Result>)Mockito.any())).
-        thenReturn(getMetaTableRowResult());
-
-      Mockito.when(client.get((RpcController)Mockito.any(), (GetRequest)Mockito.any())).
-        thenReturn(GetResponse.newBuilder().build());
-      // Now start up the catalogtracker with our doctored Connection.
-      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-      try {
-        // Set a location for root and meta.
-        RootRegionTracker.setRootLocation(this.watcher, SN);
-        ct.setMetaLocation(SN);
-        // Call the method that HBASE-4288 calls.  It will try and verify the
-        // meta location and will fail on first attempt then go into a long wait.
-        // So, do this in a thread and then reset meta location to break it out
-        // of its wait after a bit of time.
-        final AtomicBoolean metaSet = new AtomicBoolean(false);
-        final CountDownLatch latch = new CountDownLatch(1);
-        Thread t = new Thread() {
-          @Override
-          public void run() {
-            try {
-              latch.countDown();
-              metaSet.set(ct.waitForMeta(100000) !=  null);
-            } catch (Exception e) {
-              throw new RuntimeException(e);
-            }
-          }
-        };
-        t.start();
-        latch.await();
-        Threads.sleep(1);
-        // Now reset the meta as though it were redeployed.
-        ct.setMetaLocation(SN);
-        t.join();
-        Assert.assertTrue(metaSet.get());
-      } finally {
-        // Clean out root and meta locations or later tests will be confused...
-        // they presume start fresh in zk.
-        ct.resetMetaLocation();
-        RootRegionTracker.deleteRootLocation(this.watcher);
-      }
-    } finally {
-      // Clear out our doctored connection or could mess up subsequent tests.
-      HConnectionManager.deleteConnection(UTIL.getConfiguration());
-    }
-  }
-
   private void testVerifyMetaRegionLocationWithException(Exception ex)
   throws IOException, InterruptedException, KeeperException, ServiceException {
     // Mock an ClientProtocol.
@@ -274,14 +192,14 @@ public class TestCatalogTracker {
       // Now start up the catalogtracker with our doctored Connection.
       final CatalogTracker ct = constructAndStartCatalogTracker(connection);
       try {
-        RootRegionTracker.setRootLocation(this.watcher, SN);
+        MetaRegionTracker.setMetaLocation(this.watcher, SN);
         long timeout = UTIL.getConfiguration().
           getLong("hbase.catalog.verification.timeout", 1000);
         Assert.assertFalse(ct.verifyMetaRegionLocation(timeout));
       } finally {
-        // Clean out root location or later tests will be confused... they
+        // Clean out meta location or later tests will be confused... they
         // presume start fresh in zk.
-        RootRegionTracker.deleteRootLocation(this.watcher);
+        MetaRegionTracker.deleteMetaLocation(this.watcher);
       }
     } finally {
       // Clear out our doctored connection or could mess up subsequent tests.
@@ -323,14 +241,14 @@ public class TestCatalogTracker {
   }
 
   /**
-   * Test get of root region fails properly if nothing to connect to.
+   * Test get of meta region fails properly if nothing to connect to.
    * @throws IOException
    * @throws InterruptedException
    * @throws KeeperException
    * @throws ServiceException
    */
   @Test
-  public void testVerifyRootRegionLocationFails()
+  public void testVerifyMetaRegionLocationFails()
   throws IOException, InterruptedException, KeeperException, ServiceException {
     HConnection connection = Mockito.mock(HConnection.class);
     ServiceException connectException =
@@ -343,130 +261,54 @@ public class TestCatalogTracker {
       thenReturn(implementation);
     final CatalogTracker ct = constructAndStartCatalogTracker(connection);
     try {
-      RootRegionTracker.setRootLocation(this.watcher,
-        new ServerName("example.com", 1234, System.currentTimeMillis()));
-      Assert.assertFalse(ct.verifyRootRegionLocation(100));
+      MetaRegionTracker.setMetaLocation(this.watcher,
+          new ServerName("example.com", 1234, System.currentTimeMillis()));
+      Assert.assertFalse(ct.verifyMetaRegionLocation(100));
     } finally {
-      // Clean out root location or later tests will be confused... they presume
+      // Clean out meta location or later tests will be confused... they presume
       // start fresh in zk.
-      RootRegionTracker.deleteRootLocation(this.watcher);
+      MetaRegionTracker.deleteMetaLocation(this.watcher);
     }
   }
 
   @Test (expected = NotAllMetaRegionsOnlineException.class)
-  public void testTimeoutWaitForRoot()
+  public void testTimeoutWaitForMeta()
   throws IOException, InterruptedException {
     HConnection connection = Mockito.mock(HConnection.class);
     final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-    ct.waitForRoot(100);
-  }
-
-  @Test (expected = RetriesExhaustedException.class)
-  public void testTimeoutWaitForMeta()
-  throws IOException, InterruptedException {
-    HConnection connection =
-      HConnectionTestingUtility.getMockedConnection(UTIL.getConfiguration());
-    try {
-      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-      ct.waitForMeta(100);
-    } finally {
-      HConnectionManager.deleteConnection(UTIL.getConfiguration());
-    }
+    ct.waitForMeta(100);
   }
 
   /**
-   * Test waiting on root w/ no timeout specified.
+   * Test waiting on meat w/ no timeout specified.
    * @throws IOException
    * @throws InterruptedException
    * @throws KeeperException
    */
-  @Test public void testNoTimeoutWaitForRoot()
+  @Test public void testNoTimeoutWaitForMeta()
   throws IOException, InterruptedException, KeeperException {
     HConnection connection = Mockito.mock(HConnection.class);
     final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-    ServerName hsa = ct.getRootLocation();
+    ServerName hsa = ct.getMetaLocation();
     Assert.assertNull(hsa);
 
-    // Now test waiting on root location getting set.
+    // Now test waiting on meta location getting set.
     Thread t = new WaitOnMetaThread(ct);
     startWaitAliveThenWaitItLives(t, 1);
-    // Set a root location.
-    hsa = setRootLocation();
+    // Set a meta location.
+    hsa = setMetaLocation();
     // Join the thread... should exit shortly.
     t.join();
-    // Now root is available.
-    Assert.assertTrue(ct.getRootLocation().equals(hsa));
+    // Now meta is available.
+    Assert.assertTrue(ct.getMetaLocation().equals(hsa));
   }
 
-  private ServerName setRootLocation() throws KeeperException {
-    RootRegionTracker.setRootLocation(this.watcher, SN);
+  private ServerName setMetaLocation() throws KeeperException {
+    MetaRegionTracker.setMetaLocation(this.watcher, SN);
     return SN;
   }
 
   /**
-   * Test waiting on meta w/ no timeout specified.
-   * @throws Exception
-   */
-  @Ignore // Can't make it work reliably on all platforms; mockito gets confused
-  // Throwing: org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
-  // Result cannot be returned by locateRegion()
-  // If you plug locateRegion, it then throws for incCounter, and if you plug
-  // that ... and so one.
-  @Test public void testNoTimeoutWaitForMeta()
-  throws Exception {
-    // Mock an HConnection and a AdminProtocol implementation.  Have the
-    // HConnection return the HRI.  Have the HRI return a few mocked up responses
-    // to make our test work.
-    // Mock an AdminProtocol.
-    final AdminProtocol implementation = Mockito.mock(AdminProtocol.class);
-    HConnection connection = mockConnection(implementation, null);
-    try {
-      // Now the ct is up... set into the mocks some answers that make it look
-      // like things have been getting assigned. Make it so we'll return a
-      // location (no matter what the Get is). Same for getHRegionInfo -- always
-      // just return the meta region.
-      final Result result = getMetaTableRowResult();
-
-      // TODO: Refactor.  This method has been moved out of HConnection.
-      // It works for now but has been deprecated.
-      Mockito.when(connection.getRegionServerWithRetries((ServerCallable<Result>)Mockito.any())).
-        thenReturn(result);
-      GetRegionInfoResponse.Builder builder = GetRegionInfoResponse.newBuilder();
-      builder.setRegionInfo(HRegionInfo.convert(HRegionInfo.FIRST_META_REGIONINFO));
-      Mockito.when(implementation.getRegionInfo((RpcController)Mockito.any(),
-        (GetRegionInfoRequest)Mockito.any())).thenReturn(builder.build());
-      final CatalogTracker ct = constructAndStartCatalogTracker(connection);
-      ServerName hsa = ct.getMetaLocation();
-      Assert.assertNull(hsa);
-
-      // Now test waiting on meta location getting set.
-      Thread t = new WaitOnMetaThread(ct) {
-        @Override
-        void doWaiting() throws InterruptedException {
-          this.ct.waitForMeta();
-        }
-      };
-      startWaitAliveThenWaitItLives(t, 1000);
-
-      // This should trigger wake up of meta wait (Its the removal of the meta
-      // region unassigned node that triggers catalogtrackers that a meta has
-      // been assigned).
-      String node = ct.getMetaNodeTracker().getNode();
-      ZKUtil.createAndFailSilent(this.watcher, node);
-      MetaEditor.updateMetaLocation(ct, HRegionInfo.FIRST_META_REGIONINFO, SN, 0);
-      ZKUtil.deleteNode(this.watcher, node);
-      // Go get the new meta location. waitForMeta gets and verifies meta.
-      Assert.assertTrue(ct.waitForMeta(10000).equals(SN));
-      // Join the thread... should exit shortly.
-      t.join();
-      // Now meta is available.
-      Assert.assertTrue(ct.waitForMeta(10000).equals(SN));
-    } finally {
-      HConnectionManager.deleteConnection(UTIL.getConfiguration());
-    }
-  }
-
-  /**
    * @param admin An {@link AdminProtocol} instance; you'll likely
    * want to pass a mocked HRS; can be null.
    * @param client A mocked ClientProtocol instance, can be null
@@ -537,7 +379,6 @@ public class TestCatalogTracker {
 
   /**
    * Wait on META.
-   * Default is wait on -ROOT-.
    */
   class WaitOnMetaThread extends Thread {
     final CatalogTracker ct;
@@ -559,7 +400,7 @@ public class TestCatalogTracker {
 
     void doWaiting() throws InterruptedException {
       try {
-        while (this.ct.waitForRoot(100) == null);
+        while (this.ct.waitForMeta(100) == null);
       } catch (NotAllMetaRegionsOnlineException e) {
         // Ignore.
       }

Modified: hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java?rev=1454613&r1=1454612&r2=1454613&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java (original)
+++ hbase/branches/0.95/hbase-server/src/test/java/org/apache/hadoop/hbase/catalog/TestMetaMigrationConvertingToPB.java Fri Mar  8 22:46:16 2013
@@ -56,6 +56,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 /**
+ * TODO reenable the tests once a migration path is figured without ROOT
  * Test migration that changes HRI serialization into PB. Tests by bringing up a cluster from actual
  * data from a 0.92 cluster, as well as manually downgrading and then upgrading the META info.
  * @deprecated Remove after 0.96
@@ -168,7 +169,7 @@ public class TestMetaMigrationConverting
     TEST_UTIL.shutdownMiniCluster();
   }
 
-  @Test
+  //@Test
   public void testMetaUpdatedFlagInROOT() throws Exception {
     HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
     boolean metaUpdated = MetaMigrationConvertingToPB.
@@ -177,7 +178,7 @@ public class TestMetaMigrationConverting
     verifyMetaRowsAreUpdated(master.getCatalogTracker());
   }
 
-  @Test
+  //@Test
   public void testMetaMigration() throws Exception {
     LOG.info("Starting testMetaMigration");
     final byte [] FAMILY = Bytes.toBytes("family");
@@ -224,7 +225,7 @@ public class TestMetaMigrationConverting
    * rows and migrate any pending rows at startup.
    * @throws Exception
    */
-  @Test
+  //@Test
   public void testMasterCrashDuringMetaMigration() throws Exception {
     final byte[] FAMILY = Bytes.toBytes("family");
     HTableDescriptor htd = new HTableDescriptor("testMasterCrashDuringMetaMigration");
@@ -293,7 +294,7 @@ public class TestMetaMigrationConverting
     p.add(HConstants.CATALOG_FAMILY, HConstants.META_VERSION_QUALIFIER,
         Bytes.toBytes(META_VERSION_092));
 
-    MetaEditor.putToRootTable(ct, p);
+    // TODO wire this MetaEditor.putToRootTable(ct, p);
     LOG.info("Downgraded -ROOT- meta version=" + META_VERSION_092);
   }