hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [4/6] HBASE-4495 CatalogTracker has an identity crisis; needs to be cut-back in scope (Mikhail Antonov)
Date Thu, 03 Jul 2014 02:03:09 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index f06948e..f8e99f1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -64,7 +64,8 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.UnknownRegionException;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaMigrationConvertingToPB;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.MetaScanner;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
 import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitorBase;
@@ -117,6 +118,7 @@ import org.apache.hadoop.hbase.util.VersionInfo;
 import org.apache.hadoop.hbase.zookeeper.DrainingServerTracker;
 import org.apache.hadoop.hbase.zookeeper.LoadBalancerTracker;
 import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
+import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
 import org.apache.hadoop.hbase.zookeeper.RegionServerTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
@@ -409,7 +411,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     this.loadBalancerTracker = new LoadBalancerTracker(zooKeeper, this);
     this.loadBalancerTracker.start();
     this.assignmentManager = new AssignmentManager(this, serverManager,
-      this.catalogTracker, this.balancer, this.service, this.metricsMaster,
+      this.balancer, this.service, this.metricsMaster,
       this.tableLockManager);
     zooKeeper.registerListenerFirst(assignmentManager);
 
@@ -482,8 +484,8 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());
     this.serverManager = createServerManager(this, this);
 
-    // Now we have the cluster ID, start catalog tracker
-    startCatalogTracker();
+    metaTableLocator = new MetaTableLocator();
+    shortCircuitConnection = createShortCircuitConnection();
 
     // Invalidate all write locks held previously
     this.tableLockManager.reapWriteLocks();
@@ -523,7 +525,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     this.fileSystemManager.removeStaleRecoveringRegionsFromZK(previouslyFailedServers);
 
     // log splitting for hbase:meta server
-    ServerName oldMetaServerLocation = this.catalogTracker.getMetaLocation();
+    ServerName oldMetaServerLocation = metaTableLocator.getMetaRegionLocation(this.getZooKeeper());
     if (oldMetaServerLocation != null && previouslyFailedServers.contains(oldMetaServerLocation)) {
       splitMetaLogBeforeAssignment(oldMetaServerLocation);
       // Note: we can't remove oldMetaServerLocation from previousFailedServers list because it
@@ -575,8 +577,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     // Update meta with new PB serialization if required. i.e migrate all HRI to PB serialization
     // in meta. This must happen before we assign all user regions or else the assignment will
     // fail.
-    org.apache.hadoop.hbase.catalog.MetaMigrationConvertingToPB
-      .updateMetaIfNecessary(this);
+    MetaMigrationConvertingToPB.updateMetaIfNecessary(this);
 
     // Fix up assignment manager status
     status.setStatus("Starting assignment manager");
@@ -675,8 +676,9 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     regionStates.createRegionState(HRegionInfo.FIRST_META_REGIONINFO);
     boolean rit = this.assignmentManager
       .processRegionInTransitionAndBlockUntilAssigned(HRegionInfo.FIRST_META_REGIONINFO);
-    boolean metaRegionLocation = this.catalogTracker.verifyMetaRegionLocation(timeout);
-    ServerName currentMetaServer = this.catalogTracker.getMetaLocation();
+    boolean metaRegionLocation = metaTableLocator.verifyMetaRegionLocation(
+      this.getShortCircuitConnection(), this.getZooKeeper(), timeout);
+    ServerName currentMetaServer = metaTableLocator.getMetaRegionLocation(this.getZooKeeper());
     if (!metaRegionLocation) {
       // Meta location is not verified. It should be in transition, or offline.
       // We will wait for it to be assigned in enableSSHandWaitForMeta below.
@@ -724,7 +726,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     enableServerShutdownHandler(assigned != 0);
 
     LOG.info("hbase:meta assigned=" + assigned + ", rit=" + rit +
-      ", location=" + catalogTracker.getMetaLocation());
+      ", location=" + metaTableLocator.getMetaRegionLocation(this.getZooKeeper()));
     status.setStatus("META assigned.");
   }
 
@@ -764,7 +766,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     }
 
     if (waitForMeta) {
-      this.catalogTracker.waitForMeta();
+      metaTableLocator.waitMetaRegionLocation(this.getZooKeeper());
       // Above check waits for general meta availability but this does not
       // guarantee that the transition has completed
       this.assignmentManager.waitForAssignment(HRegionInfo.FIRST_META_REGIONINFO);
@@ -1410,7 +1412,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     }
     LOG.info(getClientIdAuditPrefix() + " enable " + tableName);
     this.service.submit(new EnableTableHandler(this, tableName,
-      catalogTracker, assignmentManager, tableLockManager, false).prepare());
+      assignmentManager, tableLockManager, false).prepare());
     if (cpHost != null) {
       cpHost.postEnableTable(tableName);
    }
@@ -1424,7 +1426,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     }
     LOG.info(getClientIdAuditPrefix() + " disable " + tableName);
     this.service.submit(new DisableTableHandler(this, tableName,
-      catalogTracker, assignmentManager, tableLockManager, false).prepare());
+      assignmentManager, tableLockManager, false).prepare());
     if (cpHost != null) {
       cpHost.postDisableTable(tableName);
     }
@@ -1486,7 +1488,7 @@ public class HMaster extends HRegionServer implements MasterServices, Server {
     if (isCatalogTable(tableName)) {
       throw new IOException("Can't modify catalog tables");
     }
-    if (!MetaReader.tableExists(getCatalogTracker(), tableName)) {
+    if (!MetaTableAccessor.tableExists(getShortCircuitConnection(), tableName)) {
       throw new TableNotFoundException(tableName);
     }
     if (!getAssignmentManager().getTableStateManager().

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
index 635523d..d4f3d6d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterRpcServices.java
@@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.ServerLoad;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.UnknownRegionException;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.exceptions.MergeRegionException;
 import org.apache.hadoop.hbase.exceptions.UnknownProtocolException;
 import org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface;
@@ -1086,7 +1086,7 @@ public class MasterRpcServices extends RSRpcServices
     try {
       master.checkInitialized();
       Pair<HRegionInfo, ServerName> pair =
-        MetaReader.getRegion(master.getCatalogTracker(), regionName);
+        MetaTableAccessor.getRegion(master.getShortCircuitConnection(), regionName);
       if (pair == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName));
       HRegionInfo hri = pair.getFirst();
       if (master.cpHost != null) {
@@ -1217,7 +1217,7 @@ public class MasterRpcServices extends RSRpcServices
           + " actual: " + type);
       }
       Pair<HRegionInfo, ServerName> pair =
-        MetaReader.getRegion(master.getCatalogTracker(), regionName);
+        MetaTableAccessor.getRegion(master.getShortCircuitConnection(), regionName);
       if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName));
       HRegionInfo hri = pair.getFirst();
       if (master.cpHost != null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
index 7a27489..75def7b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.tmpl.master.MasterStatusTmpl;
 import org.apache.hadoop.hbase.util.FSUtils;
+import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
 
 /**
  * The servlet responsible for rendering the index page of the
@@ -87,12 +88,7 @@ public class MasterStatusServlet extends HttpServlet {
   }
 
   private ServerName getMetaLocationOrNull(HMaster master) {
-    try {
-      return (master.getCatalogTracker() == null) ? null : master.getCatalogTracker().getMetaLocation();
-    } catch (InterruptedException e) {
-      LOG.warn("Unable to get meta location", e);
-      return null;
-    }
+    return master.getMetaTableLocator().getMetaRegionLocation(master.getZooKeeper());
   }
 
   private Map<String, Integer> getFragmentationInfo(

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RackManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RackManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RackManager.java
index 7a6d180..d9b0f95 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RackManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RackManager.java
@@ -73,7 +73,7 @@ public class RackManager {
 
   /**
    * Same as {@link #getRack(ServerName)} except that a list is passed
-   * @param servers
+   * @param servers list of servers we're requesting racks information for
    * @return list of racks for the given list of servers
    */
   public List<String> getRack(List<ServerName> servers) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlacementMaintainer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlacementMaintainer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlacementMaintainer.java
index 848ce7a..282641e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlacementMaintainer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionPlacementMaintainer.java
@@ -47,9 +47,9 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HConnection;
+import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.master.balancer.FavoredNodeAssignmentHelper;
 import org.apache.hadoop.hbase.master.balancer.FavoredNodesPlan;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
@@ -141,7 +141,7 @@ public class RegionPlacementMaintainer {
   public SnapshotOfRegionAssignmentFromMeta getRegionAssignmentSnapshot()
   throws IOException {
     SnapshotOfRegionAssignmentFromMeta currentAssignmentShapshot =
-      new SnapshotOfRegionAssignmentFromMeta(new CatalogTracker(this.conf));
+      new SnapshotOfRegionAssignmentFromMeta(HConnectionManager.getConnection(conf));
     currentAssignmentShapshot.initialize();
     return currentAssignmentShapshot;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java
index 38d9637..8e1e040 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStateStore.java
@@ -31,9 +31,7 @@ import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.Put;
@@ -62,7 +60,6 @@ public class RegionStateStore {
   private volatile boolean initialized;
 
   private final boolean noPersistence;
-  private final CatalogTracker catalogTracker;
   private final Server server;
 
   /**
@@ -76,7 +73,7 @@ public class RegionStateStore {
   static ServerName getRegionServer(final Result r, int replicaId) {
     Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, getServerNameColumn(replicaId));
     if (cell == null || cell.getValueLength() == 0) {
-      RegionLocations locations = MetaReader.getRegionLocations(r);
+      RegionLocations locations = MetaTableAccessor.getRegionLocations(r);
       if (locations != null) {
         HRegionLocation location = locations.getRegionLocation(replicaId);
         if (location != null) {
@@ -138,7 +135,6 @@ public class RegionStateStore {
     // No need to persist if using ZK but not migrating
     noPersistence = ConfigUtil.useZKForAssignment(conf)
       && !conf.getBoolean("hbase.assignment.usezk.migrating", false);
-    catalogTracker = server.getCatalogTracker();
     this.server = server;
     initialized = false;
   }
@@ -152,7 +148,7 @@ public class RegionStateStore {
       }
       if (metaRegion == null) {
         metaTable = new HTable(TableName.META_TABLE_NAME,
-          catalogTracker.getConnection());
+          server.getShortCircuitConnection());
       }
     }
     initialized = true;
@@ -189,7 +185,7 @@ public class RegionStateStore {
 
     try {
       int replicaId = hri.getReplicaId();
-      Put put = new Put(MetaReader.getMetaKeyForRegion(hri));
+      Put put = new Put(MetaTableAccessor.getMetaKeyForRegion(hri));
       StringBuilder info = new StringBuilder("Updating row ");
       info.append(hri.getRegionNameAsString()).append(" with state=").append(state);
       if (serverName != null && !serverName.equals(oldServer)) {
@@ -200,7 +196,7 @@ public class RegionStateStore {
       if (openSeqNum >= 0) {
         Preconditions.checkArgument(state == State.OPEN
           && serverName != null, "Open region should be on a server");
-        MetaEditor.addLocation(put, serverName, openSeqNum, replicaId);
+        MetaTableAccessor.addLocation(put, serverName, openSeqNum, replicaId);
         info.append("&openSeqNum=").append(openSeqNum);
         info.append("&server=").append(serverName);
       }
@@ -224,7 +220,7 @@ public class RegionStateStore {
             if (metaRegion != null) {
               LOG.info("Meta region shortcut failed", t);
               metaTable = new HTable(TableName.META_TABLE_NAME,
-                catalogTracker.getConnection());
+                server.getShortCircuitConnection());
               metaRegion = null;
             }
           }
@@ -241,11 +237,11 @@ public class RegionStateStore {
 
   void splitRegion(HRegionInfo p,
       HRegionInfo a, HRegionInfo b, ServerName sn) throws IOException {
-    MetaEditor.splitRegion(catalogTracker, p, a, b, sn);
+    MetaTableAccessor.splitRegion(server.getShortCircuitConnection(), p, a, b, sn);
   }
 
   void mergeRegions(HRegionInfo p,
       HRegionInfo a, HRegionInfo b, ServerName sn) throws IOException {
-    MetaEditor.mergeRegions(catalogTracker, p, a, b, sn);
+    MetaTableAccessor.mergeRegions(server.getShortCircuitConnection(), p, a, b, sn);
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
index 490de82..9d9401e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
@@ -39,8 +39,8 @@ import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerLoad;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.master.RegionState.State;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
@@ -930,7 +930,7 @@ public class RegionStates {
 
     try {
       Pair<HRegionInfo, ServerName> p =
-        MetaReader.getRegion(server.getCatalogTracker(), regionName);
+        MetaTableAccessor.getRegion(server.getShortCircuitConnection(), regionName);
       HRegionInfo hri = p == null ? null : p.getFirst();
       if (hri != null) {
         createRegionState(hri);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SnapshotOfRegionAssignmentFromMeta.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SnapshotOfRegionAssignmentFromMeta.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SnapshotOfRegionAssignmentFromMeta.java
index 98fa2b6..fa57dbd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SnapshotOfRegionAssignmentFromMeta.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/SnapshotOfRegionAssignmentFromMeta.java
@@ -37,9 +37,9 @@ import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.RegionLocations;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaReader;
-import org.apache.hadoop.hbase.catalog.MetaReader.Visitor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.MetaTableAccessor.Visitor;
+import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.master.balancer.FavoredNodeAssignmentHelper;
 import org.apache.hadoop.hbase.master.balancer.FavoredNodesPlan;
@@ -55,7 +55,7 @@ public class SnapshotOfRegionAssignmentFromMeta {
   private static final Log LOG = LogFactory.getLog(SnapshotOfRegionAssignmentFromMeta.class
       .getName());
 
-  private CatalogTracker tracker;
+  private final HConnection hConnection;
 
   /** the table name to region map */
   private final Map<TableName, List<HRegionInfo>> tableToRegionMap;
@@ -72,13 +72,13 @@ public class SnapshotOfRegionAssignmentFromMeta {
   private final Set<TableName> disabledTables;
   private final boolean excludeOfflinedSplitParents;
 
-  public SnapshotOfRegionAssignmentFromMeta(CatalogTracker tracker) {
-    this(tracker, new HashSet<TableName>(), false);
+  public SnapshotOfRegionAssignmentFromMeta(HConnection hConnection) {
+    this(hConnection, new HashSet<TableName>(), false);
   }
 
-  public SnapshotOfRegionAssignmentFromMeta(CatalogTracker tracker, Set<TableName> disabledTables,
+  public SnapshotOfRegionAssignmentFromMeta(HConnection hConnection, Set<TableName> disabledTables,
       boolean excludeOfflinedSplitParents) {
-    this.tracker = tracker;
+    this.hConnection = hConnection;
     tableToRegionMap = new HashMap<TableName, List<HRegionInfo>>();
     regionToRegionServerMap = new HashMap<HRegionInfo, ServerName>();
     regionServerToRegionMap = new HashMap<ServerName, List<HRegionInfo>>();
@@ -95,13 +95,13 @@ public class SnapshotOfRegionAssignmentFromMeta {
   public void initialize() throws IOException {
     LOG.info("Start to scan the hbase:meta for the current region assignment " +
 		"snappshot");
-    // TODO: at some point this code could live in the MetaReader
+    // TODO: at some point this code could live in the MetaTableAccessor
     Visitor v = new Visitor() {
       @Override
       public boolean visit(Result result) throws IOException {
         try {
           if (result ==  null || result.isEmpty()) return true;
-          RegionLocations rl = MetaReader.getRegionLocations(result);
+          RegionLocations rl = MetaTableAccessor.getRegionLocations(result);
           if (rl == null) return true;
           HRegionInfo hri = rl.getRegionLocation(0).getRegionInfo();
           if (hri == null) return true;
@@ -141,7 +141,7 @@ public class SnapshotOfRegionAssignmentFromMeta {
       }
     };
     // Scan hbase:meta to pick up user regions
-    MetaReader.fullScan(tracker, v);
+    MetaTableAccessor.fullScan(hConnection, v);
     //regionToRegionServerMap = regions;
     LOG.info("Finished to scan the hbase:meta for the current region assignment" +
       "snapshot");

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
index e8e5a28..99d794d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/TableNamespaceManager.java
@@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.NamespaceExistException;
 import org.apache.hadoop.hbase.NamespaceNotFoundException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.ZKNamespaceManager;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
@@ -80,8 +80,8 @@ public class TableNamespaceManager {
   }
 
   public void start() throws IOException {
-    if (!MetaReader.tableExists(masterServices.getCatalogTracker(),
-        TableName.NAMESPACE_TABLE_NAME)) {
+    if (!MetaTableAccessor.tableExists(masterServices.getShortCircuitConnection(),
+      TableName.NAMESPACE_TABLE_NAME)) {
       LOG.info("Namespace table not found. Creating...");
       createNamespaceTable(masterServices);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
index a4bcbf3..c06097c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java
@@ -1069,7 +1069,7 @@ public abstract class BaseLoadBalancer implements LoadBalancer {
    * Subclasses should implement this to return true if the cluster has nodes that hosts
    * multiple replicas for the same region, or, if there are multiple racks and the same
    * rack hosts replicas of the same region
-   * @param c
+   * @param c Cluster information
    * @return whether region replicas are currently co-located
    */
   protected boolean areSomeRegionReplicasColocated(Cluster c) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
index 2a138d3..ae59f26 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeAssignmentHelper.java
@@ -37,8 +37,8 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.master.RackManager;
@@ -85,13 +85,13 @@ public class FavoredNodeAssignmentHelper {
 
   /**
    * Update meta table with favored nodes info
-   * @param regionToFavoredNodes
-   * @param catalogTracker
+   * @param regionToFavoredNodes map of HRegionInfo's to their favored nodes
+   * @param hConnection HConnection to be used
    * @throws IOException
    */
   public static void updateMetaWithFavoredNodesInfo(
       Map<HRegionInfo, List<ServerName>> regionToFavoredNodes,
-      CatalogTracker catalogTracker) throws IOException {
+      HConnection hConnection) throws IOException {
     List<Put> puts = new ArrayList<Put>();
     for (Map.Entry<HRegionInfo, List<ServerName>> entry : regionToFavoredNodes.entrySet()) {
       Put put = makePutFromRegionInfo(entry.getKey(), entry.getValue());
@@ -99,7 +99,7 @@ public class FavoredNodeAssignmentHelper {
         puts.add(put);
       }
     }
-    MetaEditor.putsToMetaTable(catalogTracker, puts);
+    MetaTableAccessor.putsToMetaTable(hConnection, puts);
     LOG.info("Added " + puts.size() + " regions in META");
   }
 
@@ -141,7 +141,7 @@ public class FavoredNodeAssignmentHelper {
   throws IOException {
     Put put = null;
     if (favoredNodeList != null) {
-      put = MetaEditor.makePutFromRegionInfo(regionInfo);
+      put = MetaTableAccessor.makePutFromRegionInfo(regionInfo);
       byte[] favoredNodes = getFavoredNodes(favoredNodeList);
       put.addImmutable(HConstants.CATALOG_FAMILY, FAVOREDNODES_QUALIFIER,
           EnvironmentEdgeManager.currentTimeMillis(), favoredNodes);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeLoadBalancer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeLoadBalancer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeLoadBalancer.java
index 9cf995a..d1a785e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeLoadBalancer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/FavoredNodeLoadBalancer.java
@@ -74,7 +74,7 @@ public class FavoredNodeLoadBalancer extends BaseLoadBalancer {
     List<RegionPlan> plans = new ArrayList<RegionPlan>();
     //perform a scan of the meta to get the latest updates (if any)
     SnapshotOfRegionAssignmentFromMeta snaphotOfRegionAssignment =
-        new SnapshotOfRegionAssignmentFromMeta(super.services.getCatalogTracker());
+        new SnapshotOfRegionAssignmentFromMeta(super.services.getShortCircuitConnection());
     try {
       snaphotOfRegionAssignment.initialize();
     } catch (IOException ie) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
index d6a5d6a..fa34ba1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/CreateTableHandler.java
@@ -36,10 +36,8 @@ import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.TableExistsException;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -64,7 +62,6 @@ public class CreateTableHandler extends EventHandler {
   protected final HTableDescriptor hTableDescriptor;
   protected final Configuration conf;
   private final AssignmentManager assignmentManager;
-  private final CatalogTracker catalogTracker;
   private final TableLockManager tableLockManager;
   private final HRegionInfo [] newRegions;
   private final TableLock tableLock;
@@ -78,7 +75,6 @@ public class CreateTableHandler extends EventHandler {
     this.hTableDescriptor = hTableDescriptor;
     this.conf = conf;
     this.newRegions = newRegions;
-    this.catalogTracker = masterServices.getCatalogTracker();
     this.assignmentManager = masterServices.getAssignmentManager();
     this.tableLockManager = masterServices.getTableLockManager();
 
@@ -92,7 +88,8 @@ public class CreateTableHandler extends EventHandler {
     int timeout = conf.getInt("hbase.client.catalog.timeout", 10000);
     // Need hbase:meta availability to create a table
     try {
-      if (catalogTracker.waitForMeta(timeout) == null) {
+      if (server.getMetaTableLocator().waitMetaRegionLocation(
+          server.getZooKeeper(), timeout) == null) {
         throw new NotAllMetaRegionsOnlineException();
       }
     } catch (InterruptedException e) {
@@ -107,7 +104,7 @@ public class CreateTableHandler extends EventHandler {
     boolean success = false;
     try {
       TableName tableName = this.hTableDescriptor.getTableName();
-      if (MetaReader.tableExists(catalogTracker, tableName)) {
+      if (MetaTableAccessor.tableExists(this.server.getShortCircuitConnection(), tableName)) {
         throw new TableExistsException(tableName);
       }
 
@@ -242,7 +239,7 @@ public class CreateTableHandler extends EventHandler {
 
     if (regionInfos != null && regionInfos.size() > 0) {
       // 4. Add regions to META
-      addRegionsToMeta(this.catalogTracker, regionInfos);
+      addRegionsToMeta(regionInfos);
       // 5. Add replicas if needed
       regionInfos = addReplicas(hTableDescriptor, regionInfos);
 
@@ -310,8 +307,8 @@ public class CreateTableHandler extends EventHandler {
   /**
    * Add the specified set of regions to the hbase:meta table.
    */
-  protected void addRegionsToMeta(final CatalogTracker ct, final List<HRegionInfo> regionInfos)
+  protected void addRegionsToMeta(final List<HRegionInfo> regionInfos)
       throws IOException {
-    MetaEditor.addRegionsToMeta(this.catalogTracker, regionInfos);
+    MetaTableAccessor.addRegionsToMeta(this.server.getShortCircuitConnection(), regionInfos);
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
index 8874ff1..730da73 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
@@ -33,7 +33,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.backup.HFileArchiver;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -133,7 +133,7 @@ public class DeleteTableHandler extends TableEventHandler {
       throws IOException, CoordinatedStateException {
     // 1. Remove regions from META
     LOG.debug("Deleting regions from META");
-    MetaEditor.deleteRegions(this.server.getCatalogTracker(), regions);
+    MetaTableAccessor.deleteRegions(this.server.getShortCircuitConnection(), regions);
 
     // -----------------------------------------------------------------------
     // NOTE: At this point we still have data on disk, but nothing in hbase:meta

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
index f9f6147..6fcb30a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
@@ -31,8 +31,7 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.TableNotEnabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.constraint.ConstraintException;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventType;
@@ -56,17 +55,15 @@ public class DisableTableHandler extends EventHandler {
   private final TableName tableName;
   private final AssignmentManager assignmentManager;
   private final TableLockManager tableLockManager;
-  private final CatalogTracker catalogTracker;
   private final boolean skipTableStateCheck;
   private TableLock tableLock;
 
   public DisableTableHandler(Server server, TableName tableName,
-      CatalogTracker catalogTracker, AssignmentManager assignmentManager,
-      TableLockManager tableLockManager, boolean skipTableStateCheck) {
+      AssignmentManager assignmentManager, TableLockManager tableLockManager,
+      boolean skipTableStateCheck) {
     super(server, EventType.C_M_DISABLE_TABLE);
     this.tableName = tableName;
     this.assignmentManager = assignmentManager;
-    this.catalogTracker = catalogTracker;
     this.tableLockManager = tableLockManager;
     this.skipTableStateCheck = skipTableStateCheck;
   }
@@ -84,7 +81,7 @@ public class DisableTableHandler extends EventHandler {
     boolean success = false;
     try {
       // Check if table exists
-      if (!MetaReader.tableExists(catalogTracker, tableName)) {
+      if (!MetaTableAccessor.tableExists(this.server.getShortCircuitConnection(), tableName)) {
         throw new TableNotFoundException(tableName);
       }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
index 5e90232..b8edc0b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
@@ -34,8 +34,7 @@ import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -60,26 +59,24 @@ public class EnableTableHandler extends EventHandler {
   private final TableName tableName;
   private final AssignmentManager assignmentManager;
   private final TableLockManager tableLockManager;
-  private final CatalogTracker catalogTracker;
   private boolean skipTableStateCheck = false;
   private TableLock tableLock;
   private MasterServices services;
 
   public EnableTableHandler(Server server, TableName tableName,
-      CatalogTracker catalogTracker, AssignmentManager assignmentManager,
-      TableLockManager tableLockManager, boolean skipTableStateCheck) {
+      AssignmentManager assignmentManager, TableLockManager tableLockManager,
+      boolean skipTableStateCheck) {
     super(server, EventType.C_M_ENABLE_TABLE);
     this.tableName = tableName;
-    this.catalogTracker = catalogTracker;
     this.assignmentManager = assignmentManager;
     this.tableLockManager = tableLockManager;
     this.skipTableStateCheck = skipTableStateCheck;
   }
 
   public EnableTableHandler(MasterServices services, TableName tableName,
-      CatalogTracker catalogTracker, AssignmentManager assignmentManager,
+      AssignmentManager assignmentManager,
       TableLockManager tableLockManager, boolean skipTableStateCheck) {
-    this((Server)services, tableName, catalogTracker, assignmentManager, tableLockManager,
+    this((Server)services, tableName, assignmentManager, tableLockManager,
         skipTableStateCheck);
     this.services = services;
   }
@@ -94,7 +91,7 @@ public class EnableTableHandler extends EventHandler {
     boolean success = false;
     try {
       // Check if table exists
-      if (!MetaReader.tableExists(catalogTracker, tableName)) {
+      if (!MetaTableAccessor.tableExists(this.server.getShortCircuitConnection(), tableName)) {
         // retainAssignment is true only during recovery.  In normal case it is false
         if (!this.skipTableStateCheck) {
           throw new TableNotFoundException(tableName);
@@ -192,8 +189,9 @@ public class EnableTableHandler extends EventHandler {
     ServerManager serverManager = ((HMaster)this.server).getServerManager();
     // Get the regions of this table. We're done when all listed
     // tables are onlined.
-    List<Pair<HRegionInfo, ServerName>> tableRegionsAndLocations = MetaReader
-        .getTableRegionsAndLocations(this.catalogTracker, tableName, true);
+    List<Pair<HRegionInfo, ServerName>> tableRegionsAndLocations = MetaTableAccessor
+      .getTableRegionsAndLocations(this.server.getZooKeeper(),
+           this.server.getShortCircuitConnection(), tableName, true);
     int countOfRegionsInTable = tableRegionsAndLocations.size();
     Map<HRegionInfo, ServerName> regionsToAssign =
         regionsToAssignWithServerName(tableRegionsAndLocations);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
index 11a4fb2..a24e387 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/MetaServerShutdownHandler.java
@@ -91,7 +91,7 @@ public class MetaServerShutdownHandler extends ServerShutdownHandler {
         LOG.info("Server " + serverName + " was carrying META. Trying to assign.");
         am.regionOffline(HRegionInfo.FIRST_META_REGIONINFO);
         verifyAndAssignMetaWithRetries();
-      } else if (!this.services.getCatalogTracker().isMetaLocationAvailable()) {
+      } else if (!server.getMetaTableLocator().isLocationAvailable(this.server.getZooKeeper())) {
         // the meta location as per master is null. This could happen in case when meta assignment
         // in previous run failed, while meta znode has been updated to null. We should try to
         // assign the meta again.
@@ -154,14 +154,16 @@ public class MetaServerShutdownHandler extends ServerShutdownHandler {
       throws InterruptedException, IOException, KeeperException {
     long timeout = this.server.getConfiguration().
         getLong("hbase.catalog.verification.timeout", 1000);
-    if (!this.server.getCatalogTracker().verifyMetaRegionLocation(timeout)) {
+    if (!server.getMetaTableLocator().verifyMetaRegionLocation(server.getShortCircuitConnection(),
+      this.server.getZooKeeper(), timeout)) {
       this.services.getAssignmentManager().assignMeta();
-    } else if (serverName.equals(server.getCatalogTracker().getMetaLocation())) {
+    } else if (serverName.equals(server.getMetaTableLocator().getMetaRegionLocation(
+      this.server.getZooKeeper()))) {
       throw new IOException("hbase:meta is onlined on the dead server "
           + serverName);
     } else {
       LOG.info("Skip assigning hbase:meta, because it is online on the "
-          + server.getCatalogTracker().getMetaLocation());
+          + server.getMetaTableLocator().getMetaRegionLocation(this.server.getZooKeeper()));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
index f0af406..48fb26f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
@@ -31,8 +31,7 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
@@ -93,7 +92,7 @@ public class ModifyTableHandler extends TableEventHandler {
       TableName table) throws IOException {
     if (newReplicaCount >= oldReplicaCount) return;
     Set<byte[]> tableRows = new HashSet<byte[]>();
-    Scan scan = MetaReader.getScanForTableName(table);
+    Scan scan = MetaTableAccessor.getScanForTableName(table);
     scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
     HTable htable = null;
     try {
@@ -102,8 +101,8 @@ public class ModifyTableHandler extends TableEventHandler {
       for (Result result : resScanner) {
         tableRows.add(result.getRow());
       }
-      MetaEditor.removeRegionReplicasFromMeta(tableRows, newReplicaCount,
-          oldReplicaCount - newReplicaCount, masterServices.getCatalogTracker());
+      MetaTableAccessor.removeRegionReplicasFromMeta(tableRows, newReplicaCount,
+          oldReplicaCount - newReplicaCount, masterServices.getShortCircuitConnection());
     } finally {
       if (htable != null) {
         htable.close();

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
index 70648e1..607d042 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
@@ -32,8 +32,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -144,7 +143,7 @@ public class ServerShutdownHandler extends EventHandler {
 
       // Wait on meta to come online; we need it to progress.
       // TODO: Best way to hold strictly here?  We should build this retry logic
-      // into the MetaReader operations themselves.
+      // into the MetaTableAccessor operations themselves.
       // TODO: Is the reading of hbase:meta necessary when the Master has state of
       // cluster in its head?  It should be possible to do without reading hbase:meta
       // in all but one case. On split, the RS updates the hbase:meta
@@ -160,11 +159,11 @@ public class ServerShutdownHandler extends EventHandler {
       Set<HRegionInfo> hris = null;
       while (!this.server.isStopped()) {
         try {
-          this.server.getCatalogTracker().waitForMeta();
+          server.getMetaTableLocator().waitMetaRegionLocation(server.getZooKeeper());
           // Skip getting user regions if the server is stopped.
           if (!this.server.isStopped()) {
             if (ConfigUtil.useZKForAssignment(server.getConfiguration())) {
-              hris = MetaReader.getServerUserRegions(this.server.getCatalogTracker(),
+              hris = MetaTableAccessor.getServerUserRegions(this.server.getShortCircuitConnection(),
                 this.serverName).keySet();
             } else {
               // Not using ZK for assignment, regionStates has everything we want
@@ -235,7 +234,7 @@ public class ServerShutdownHandler extends EventHandler {
           Lock lock = am.acquireRegionLock(encodedName);
           try {
             RegionState rit = regionStates.getRegionTransitionState(hri);
-            if (processDeadRegion(hri, am, server.getCatalogTracker())) {
+            if (processDeadRegion(hri, am)) {
               ServerName addressFromAM = regionStates.getRegionServerOfRegion(hri);
               if (addressFromAM != null && !addressFromAM.equals(this.serverName)) {
                 // If this region is in transition on the dead server, it must be
@@ -336,12 +335,11 @@ public class ServerShutdownHandler extends EventHandler {
    * disabling or if the region has a partially completed split.
    * @param hri
    * @param assignmentManager
-   * @param catalogTracker
    * @return Returns true if specified region should be assigned, false if not.
    * @throws IOException
    */
   public static boolean processDeadRegion(HRegionInfo hri,
-      AssignmentManager assignmentManager, CatalogTracker catalogTracker)
+      AssignmentManager assignmentManager)
   throws IOException {
     boolean tablePresent = assignmentManager.getTableStateManager().isTablePresent(hri.getTable());
     if (!tablePresent) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
index ed34875..4f1c39d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
@@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableNotDisabledException;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.executor.EventType;
@@ -125,8 +125,8 @@ public abstract class TableEventHandler extends EventHandler {
           tableName);
 
       List<HRegionInfo> hris =
-        MetaReader.getTableRegions(this.server.getCatalogTracker(),
-          tableName);
+        MetaTableAccessor.getTableRegions(this.server.getZooKeeper(),
+          this.server.getShortCircuitConnection(), tableName);
       handleTableOperation(hris);
       if (eventType.isOnlineSchemaChangeSupported() && this.masterServices.
           getAssignmentManager().getTableStateManager().isTableState(

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TruncateTableHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TruncateTableHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TruncateTableHandler.java
index fce86d1..086d1d5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TruncateTableHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/handler/TruncateTableHandler.java
@@ -30,7 +30,7 @@ import org.apache.hadoop.hbase.CoordinatedStateException;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.master.AssignmentManager;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
@@ -124,7 +124,8 @@ public class TruncateTableHandler extends DeleteTableHandler {
       }
 
       // 4. Add regions to META
-      MetaEditor.addRegionsToMeta(masterServices.getCatalogTracker(), regionInfos);
+      MetaTableAccessor.addRegionsToMeta(masterServices.getShortCircuitConnection(),
+        regionInfos);
 
       // 5. Trigger immediate assignment of the regions in round-robin fashion
       ModifyRegionUtils.assignRegions(assignmentManager, regionInfos);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java
index d902c58..b8dbcd3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/CloneSnapshotHandler.java
@@ -33,7 +33,6 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.TableExistsException;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
 import org.apache.hadoop.hbase.master.MasterServices;
@@ -139,10 +138,10 @@ public class CloneSnapshotHandler extends CreateTableHandler implements Snapshot
   }
 
   @Override
-  protected void addRegionsToMeta(final CatalogTracker ct, final List<HRegionInfo> regionInfos)
+  protected void addRegionsToMeta(final List<HRegionInfo> regionInfos)
       throws IOException {
-    super.addRegionsToMeta(ct, regionInfos);
-    metaChanges.updateMetaParentRegions(ct, regionInfos);
+    super.addRegionsToMeta(regionInfos);
+    metaChanges.updateMetaParentRegions(this.server.getShortCircuitConnection(), regionInfos);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/MasterSnapshotVerifier.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/MasterSnapshotVerifier.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/MasterSnapshotVerifier.java
index fc1f862..b140300 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/MasterSnapshotVerifier.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/MasterSnapshotVerifier.java
@@ -32,8 +32,8 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.client.RegionReplicaUtil;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
 import org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionManifest;
@@ -150,8 +150,8 @@ public final class MasterSnapshotVerifier {
    * @throws IOException if we can't reach hbase:meta or read the files from the FS
    */
   private void verifyRegions(final SnapshotManifest manifest) throws IOException {
-    List<HRegionInfo> regions = MetaReader.getTableRegions(this.services.getCatalogTracker(),
-        tableName);
+    List<HRegionInfo> regions = MetaTableAccessor.getTableRegions(
+      this.services.getZooKeeper(), this.services.getShortCircuitConnection(), tableName);
     // Remove the non-default regions
     RegionReplicaUtil.removeNonDefaultRegions(regions);
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
index 2b97505..2eb504d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/RestoreSnapshotHandler.java
@@ -32,8 +32,8 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
 import org.apache.hadoop.hbase.executor.EventType;
@@ -109,7 +109,7 @@ public class RestoreSnapshotHandler extends TableEventHandler implements Snapsho
   @Override
   protected void handleTableOperation(List<HRegionInfo> hris) throws IOException {
     MasterFileSystem fileSystemManager = masterServices.getMasterFileSystem();
-    CatalogTracker catalogTracker = masterServices.getCatalogTracker();
+    HConnection conn = masterServices.getShortCircuitConnection();
     FileSystem fs = fileSystemManager.getFileSystem();
     Path rootDir = fileSystemManager.getRootDir();
     TableName tableName = hTableDescriptor.getTableName();
@@ -149,7 +149,7 @@ public class RestoreSnapshotHandler extends TableEventHandler implements Snapsho
       // that are not correct after the restore.
       List<HRegionInfo> hrisToRemove = new LinkedList<HRegionInfo>();
       if (metaChanges.hasRegionsToRemove()) hrisToRemove.addAll(metaChanges.getRegionsToRemove());
-      MetaEditor.deleteRegions(catalogTracker, hrisToRemove);
+      MetaTableAccessor.deleteRegions(conn, hrisToRemove);
 
       // 4.2 Add the new set of regions to META
       //
@@ -159,11 +159,11 @@ public class RestoreSnapshotHandler extends TableEventHandler implements Snapsho
       // in the snapshot folder.
       hris.clear();
       if (metaChanges.hasRegionsToAdd()) hris.addAll(metaChanges.getRegionsToAdd());
-      MetaEditor.addRegionsToMeta(catalogTracker, hris);
+      MetaTableAccessor.addRegionsToMeta(conn, hris);
       if (metaChanges.hasRegionsToRestore()) {
-        MetaEditor.overwriteRegions(catalogTracker, metaChanges.getRegionsToRestore());
+        MetaTableAccessor.overwriteRegions(conn, metaChanges.getRegionsToRestore());
       }
-      metaChanges.updateMetaParentRegions(catalogTracker, hris);
+      metaChanges.updateMetaParentRegions(this.server.getShortCircuitConnection(), hris);
 
       // At this point the restore is complete. Next step is enabling the table.
       LOG.info("Restore snapshot=" + ClientSnapshotDescriptionUtils.toString(snapshot) +

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
index ddedf9f..3bf704a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/SnapshotManager.java
@@ -42,7 +42,7 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.Stoppable;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.master.AssignmentManager;
@@ -694,7 +694,7 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
     SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, manifest);
 
     // Execute the restore/clone operation
-    if (MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
+    if (MetaTableAccessor.tableExists(master.getShortCircuitConnection(), tableName)) {
       if (master.getAssignmentManager().getTableStateManager().isTableState(
           TableName.valueOf(fsSnapshot.getTable()), ZooKeeperProtos.Table.State.ENABLED)) {
         throw new UnsupportedOperationException("Table '" +

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java
index 4d6182b..9857acf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionSnare;
@@ -168,8 +168,8 @@ public abstract class TakeSnapshotHandler extends EventHandler implements Snapsh
       monitor.rethrowException();
 
       List<Pair<HRegionInfo, ServerName>> regionsAndLocations =
-          MetaReader.getTableRegionsAndLocations(this.server.getCatalogTracker(),
-              snapshotTable, false);
+          MetaTableAccessor.getTableRegionsAndLocations(this.server.getZooKeeper(),
+            this.server.getShortCircuitConnection(), snapshotTable, false);
 
       // run the snapshot
       snapshotRegions(regionsAndLocations);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
index daef083..b11d74c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/migration/NamespaceUpgrade.java
@@ -40,7 +40,7 @@ import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.NamespaceDescriptor;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Put;
@@ -431,8 +431,8 @@ public class NamespaceUpgrade implements Tool {
                 newRegionDir);
           }
         }
-        meta.put(MetaEditor.makePutFromRegionInfo(newRegionInfo));
-        meta.delete(MetaEditor.makeDeleteFromRegionInfo(oldRegionInfo));
+        meta.put(MetaTableAccessor.makePutFromRegionInfo(newRegionInfo));
+        meta.delete(MetaTableAccessor.makeDeleteFromRegionInfo(oldRegionInfo));
       }
     } finally {
       meta.flushcache();

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/flush/MasterFlushTableProcedureManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/flush/MasterFlushTableProcedureManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/flush/MasterFlushTableProcedureManager.java
index 16456c3..4101c16 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/flush/MasterFlushTableProcedureManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/procedure/flush/MasterFlushTableProcedureManager.java
@@ -30,7 +30,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.errorhandling.ForeignException;
 import org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher;
 import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
@@ -124,8 +124,9 @@ public class MasterFlushTableProcedureManager extends MasterProcedureManager {
     List<Pair<HRegionInfo, ServerName>> regionsAndLocations = null;
     try {
       regionsAndLocations =
-          MetaReader.getTableRegionsAndLocations(this.master.getCatalogTracker(),
-              TableName.valueOf(desc.getInstance()), false);
+          MetaTableAccessor.getTableRegionsAndLocations(this.master.getZooKeeper(),
+            this.master.getShortCircuitConnection(),
+            TableName.valueOf(desc.getInstance()), false);
     } catch (InterruptedException e1) {
       String msg = "Failed to get regions for '" + desc.getInstance() + "'";
       LOG.error(msg);

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 2cdd136..0048852 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -72,8 +72,7 @@ import org.apache.hadoop.hbase.TableDescriptors;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.YouAreDeadException;
 import org.apache.hadoop.hbase.ZNodeClearer;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.ConnectionUtils;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HConnectionManager;
@@ -135,7 +134,7 @@ import org.apache.hadoop.hbase.util.Threads;
 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.MetaRegionTracker;
+import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
 import org.apache.hadoop.hbase.zookeeper.RecoveringRegionWatcher;
 import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
@@ -182,8 +181,20 @@ public class HRegionServer extends HasThread implements
 
   protected HeapMemoryManager hMemManager;
 
-  // catalog tracker
-  protected CatalogTracker catalogTracker;
+  /*
+   * Short-circuit (ie. bypassing RPC layer) HConnection to this Server
+   * to be used internally for miscellaneous needs. Initialized at the server startup
+   * and closed when server shuts down. Clients must never close it explicitly.
+   */
+  protected HConnection shortCircuitConnection;
+
+  /*
+   * Long-living meta table locator, which is created when the server is started and stopped
+   * when server shuts down. References to this locator shall be used to perform according
+   * operations in EventHandlers. Primary reason for this decision is to make it mockable
+   * for tests.
+   */
+  protected MetaTableLocator metaTableLocator;
 
   // Watch if a region is out of recovering state from ZooKeeper
   @SuppressWarnings("unused")
@@ -543,14 +554,13 @@ public class HRegionServer extends HasThread implements
   }
 
   /**
-   * Create CatalogTracker.
+   * Create wrapped short-circuit connection to this server.
    * In its own method so can intercept and mock it over in tests.
    * @throws IOException
    */
-  protected CatalogTracker createCatalogTracker() throws IOException {
-    HConnection conn = ConnectionUtils.createShortCircuitHConnection(
+  protected HConnection createShortCircuitConnection() throws IOException {
+    return ConnectionUtils.createShortCircuitHConnection(
       HConnectionManager.getConnection(conf), serverName, rpcServices, rpcServices);
-    return new CatalogTracker(zooKeeper, conf, conn, this);
   }
 
   /**
@@ -596,7 +606,7 @@ public class HRegionServer extends HasThread implements
    * Bring up connection to zk ensemble and then wait until a master for this
    * cluster and then after that, wait until cluster 'up' flag has been set.
    * This is the order in which master does things.
-   * Finally put up a catalog tracker.
+   * Finally open long-living server short-circuit connection.
    * @throws IOException
    * @throws InterruptedException
    */
@@ -625,8 +635,8 @@ public class HRegionServer extends HasThread implements
       this.abort("Failed to retrieve Cluster ID",e);
     }
 
-    // Now we have the cluster ID, start catalog tracker
-    startCatalogTracker();
+    shortCircuitConnection = createShortCircuitConnection();
+    metaTableLocator = new MetaTableLocator();
 
     // watch for snapshots and other procedures
     try {
@@ -705,17 +715,6 @@ public class HRegionServer extends HasThread implements
   }
 
   /**
-   * Create and start the catalog tracker if not already done.
-   */
-  protected synchronized void startCatalogTracker()
-      throws IOException, InterruptedException {
-    if (catalogTracker == null) {
-      catalogTracker = createCatalogTracker();
-      catalogTracker.start();
-    }
-  }
-
-  /**
    * The HRegionServer sticks in this loop until closed.
    */
   @Override
@@ -859,9 +858,18 @@ public class HRegionServer extends HasThread implements
       closeUserRegions(abortRequested);
       LOG.info("stopping server " + this.serverName);
     }
-    // Interrupt catalog tracker here in case any regions being opened out in
-    // handlers are stuck waiting on meta.
-    if (this.catalogTracker != null) this.catalogTracker.stop();
+
+    // so callers waiting for meta without timeout can stop
+    metaTableLocator.stop();
+    if (this.shortCircuitConnection != null && !shortCircuitConnection.isClosed()) {
+      try {
+        this.shortCircuitConnection.close();
+      } catch (IOException e) {
+        // Although the {@link Closeable} interface throws an {@link
+        // IOException}, in reality, the implementation would never do that.
+        LOG.error("Attempt to close server's short circuit HConnection failed.", e);
+      }
+    }
 
     // Closing the compactSplit thread before closing meta regions
     if (!this.killed && containsMetaTableRegions()) {
@@ -1644,8 +1652,13 @@ public class HRegionServer extends HasThread implements
   }
 
   @Override
-  public CatalogTracker getCatalogTracker() {
-    return this.catalogTracker;
+  public HConnection getShortCircuitConnection() {
+    return this.shortCircuitConnection;
+  }
+
+  @Override
+  public MetaTableLocator getMetaTableLocator() {
+    return this.metaTableLocator;
   }
 
   @Override
@@ -1672,7 +1685,7 @@ public class HRegionServer extends HasThread implements
   }
 
   @Override
-  public void postOpenDeployTasks(final HRegion r, final CatalogTracker ct)
+  public void postOpenDeployTasks(final HRegion r)
   throws KeeperException, IOException {
     rpcServices.checkOpen();
     LOG.info("Post open deploy tasks for " + r.getRegionNameAsString());
@@ -1694,9 +1707,9 @@ public class HRegionServer extends HasThread implements
 
     // Update ZK, or META
     if (r.getRegionInfo().isMetaRegion()) {
-      MetaRegionTracker.setMetaLocation(getZooKeeper(), serverName);
+      MetaTableLocator.setMetaLocation(getZooKeeper(), serverName);
     } else if (useZKForAssignment) {
-      MetaEditor.updateRegionLocation(ct, r.getRegionInfo(),
+      MetaTableAccessor.updateRegionLocation(shortCircuitConnection, r.getRegionInfo(),
         this.serverName, openSeqNum);
     }
     if (!useZKForAssignment && !reportRegionStateTransition(

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index a601577..9a0e8a4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -52,7 +52,7 @@ import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.UnknownScannerException;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.Append;
 import org.apache.hadoop.hbase.client.ConnectionUtils;
 import org.apache.hadoop.hbase.client.Delete;
@@ -1206,8 +1206,8 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
           }
           // See HBASE-5094. Cross check with hbase:meta if still this RS is owning
           // the region.
-          Pair<HRegionInfo, ServerName> p = MetaReader.getRegion(
-            regionServer.catalogTracker, region.getRegionName());
+          Pair<HRegionInfo, ServerName> p = MetaTableAccessor.getRegion(
+            regionServer.getShortCircuitConnection(), region.getRegionName());
           if (regionServer.serverName.equals(p.getSecond())) {
             Boolean closing = regionServer.regionsInTransitionInRS.get(region.getEncodedNameAsBytes());
             // Map regionsInTransitionInRSOnly has an entry for a region only if the region

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionMergeTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionMergeTransaction.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionMergeTransaction.java
index 8be66e0..2db8d7e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionMergeTransaction.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionMergeTransaction.java
@@ -33,10 +33,9 @@ import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MetaMutationAnnotation;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.catalog.MetaReader;
+import org.apache.hadoop.hbase.MetaTableAccessor;
 import org.apache.hadoop.hbase.client.Delete;
+import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.Mutation;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager;
@@ -325,11 +324,13 @@ public class RegionMergeTransaction {
     // rollback
     if (!testing && useCoordinationForAssignment) {
       if (metaEntries.isEmpty()) {
-        MetaEditor.mergeRegions(server.getCatalogTracker(), mergedRegion.getRegionInfo(), region_a
-            .getRegionInfo(), region_b.getRegionInfo(), server.getServerName());
+        MetaTableAccessor.mergeRegions(server.getShortCircuitConnection(),
+          mergedRegion.getRegionInfo(), region_a.getRegionInfo(), region_b.getRegionInfo(),
+          server.getServerName());
       } else {
-        mergeRegionsAndPutMetaEntries(server.getCatalogTracker(), mergedRegion.getRegionInfo(),
-          region_a.getRegionInfo(), region_b.getRegionInfo(), server.getServerName(), metaEntries);
+        mergeRegionsAndPutMetaEntries(server.getShortCircuitConnection(),
+          mergedRegion.getRegionInfo(), region_a.getRegionInfo(), region_b.getRegionInfo(),
+          server.getServerName(), metaEntries);
       }
     } else if (services != null && !useCoordinationForAssignment) {
       if (!services.reportRegionStateTransition(TransitionCode.MERGE_PONR,
@@ -343,11 +344,11 @@ public class RegionMergeTransaction {
     return mergedRegion;
   }
 
-  private void mergeRegionsAndPutMetaEntries(CatalogTracker catalogTracker,
-      HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB, ServerName serverName,
-      List<Mutation> metaEntries) throws IOException {
+  private void mergeRegionsAndPutMetaEntries(HConnection hConnection,
+      HRegionInfo mergedRegion, HRegionInfo regionA, HRegionInfo regionB,
+      ServerName serverName, List<Mutation> metaEntries) throws IOException {
     prepareMutationsForMerge(mergedRegion, regionA, regionB, serverName, metaEntries);
-    MetaEditor.mutateMetaTable(catalogTracker, metaEntries);
+    MetaTableAccessor.mutateMetaTable(hConnection, metaEntries);
   }
 
   public void prepareMutationsForMerge(HRegionInfo mergedRegion, HRegionInfo regionA,
@@ -355,13 +356,13 @@ public class RegionMergeTransaction {
     HRegionInfo copyOfMerged = new HRegionInfo(mergedRegion);
 
     // Put for parent
-    Put putOfMerged = MetaEditor.makePutFromRegionInfo(copyOfMerged);
+    Put putOfMerged = MetaTableAccessor.makePutFromRegionInfo(copyOfMerged);
     putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEA_QUALIFIER, regionA.toByteArray());
     putOfMerged.add(HConstants.CATALOG_FAMILY, HConstants.MERGEB_QUALIFIER, regionB.toByteArray());
     mutations.add(putOfMerged);
     // Deletes for merging regions
-    Delete deleteA = MetaEditor.makeDeleteFromRegionInfo(regionA);
-    Delete deleteB = MetaEditor.makeDeleteFromRegionInfo(regionB);
+    Delete deleteA = MetaTableAccessor.makeDeleteFromRegionInfo(regionA);
+    Delete deleteB = MetaTableAccessor.makeDeleteFromRegionInfo(regionB);
     mutations.add(deleteA);
     mutations.add(deleteB);
     // The merged is a new region, openSeqNum = 1 is fine.
@@ -579,7 +580,7 @@ public class RegionMergeTransaction {
     if (services != null) {
       try {
         if (useCoordinationForAssignment) {
-          services.postOpenDeployTasks(merged, server.getCatalogTracker());
+          services.postOpenDeployTasks(merged);
         } else if (!services.reportRegionStateTransition(TransitionCode.MERGED,
             mergedRegionInfo, region_a.getRegionInfo(), region_b.getRegionInfo())) {
           throw new IOException("Failed to report merged region to master: "
@@ -753,8 +754,8 @@ public class RegionMergeTransaction {
     if (services == null) return false;
     // Get merge regions if it is a merged region and already has merge
     // qualifier
-    Pair<HRegionInfo, HRegionInfo> mergeRegions = MetaReader
-        .getRegionsFromMergeQualifier(services.getCatalogTracker(), regionName);
+    Pair<HRegionInfo, HRegionInfo> mergeRegions = MetaTableAccessor
+        .getRegionsFromMergeQualifier(services.getShortCircuitConnection(), regionName);
     if (mergeRegions != null &&
         (mergeRegions.getFirst() != null || mergeRegions.getSecond() != null)) {
       // It has merge qualifier

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
index 0ad1f29..63dd003 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
@@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentMap;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.ipc.RpcServerInterface;
 import org.apache.hadoop.hbase.master.TableLockManager;
@@ -73,11 +72,10 @@ public interface RegionServerServices
    * regionserver
    *
    * @param r Region to open.
-   * @param ct Instance of {@link CatalogTracker}
    * @throws KeeperException
    * @throws IOException
    */
-  void postOpenDeployTasks(final HRegion r, final CatalogTracker ct)
+  void postOpenDeployTasks(final HRegion r)
   throws KeeperException, IOException;
 
   /**
@@ -117,11 +115,6 @@ public interface RegionServerServices
   ExecutorService getExecutorService();
 
   /**
-   * @return The RegionServer's CatalogTracker
-   */
-  CatalogTracker getCatalogTracker();
-
-  /**
    * @return set of recovering regions on the hosting region server
    */
   Map<String, HRegion> getRecoveringRegions();

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
index e8754d6..c5b29e6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitTransaction.java
@@ -39,8 +39,8 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.MetaTableAccessor;
+import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.Mutation;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.coordination.BaseCoordinatedStateManager;
@@ -277,11 +277,11 @@ public class SplitTransaction {
     // and assign the parent region.
     if (!testing && useZKForAssignment) {
       if (metaEntries == null || metaEntries.isEmpty()) {
-        MetaEditor.splitRegion(server.getCatalogTracker(),
-            parent.getRegionInfo(), daughterRegions.getFirst().getRegionInfo(),
-            daughterRegions.getSecond().getRegionInfo(), server.getServerName());
+        MetaTableAccessor.splitRegion(server.getShortCircuitConnection(),
+          parent.getRegionInfo(), daughterRegions.getFirst().getRegionInfo(),
+          daughterRegions.getSecond().getRegionInfo(), server.getServerName());
       } else {
-        offlineParentInMetaAndputMetaEntries(server.getCatalogTracker(),
+        offlineParentInMetaAndputMetaEntries(server.getShortCircuitConnection(),
           parent.getRegionInfo(), daughterRegions.getFirst().getRegionInfo(), daughterRegions
               .getSecond().getRegionInfo(), server.getServerName(), metaEntries);
       }
@@ -418,7 +418,7 @@ public class SplitTransaction {
         try {
           if (useZKForAssignment) {
             // add 2nd daughter first (see HBASE-4335)
-            services.postOpenDeployTasks(b, server.getCatalogTracker());
+            services.postOpenDeployTasks(b);
           } else if (!services.reportRegionStateTransition(TransitionCode.SPLIT,
               parent.getRegionInfo(), hri_a, hri_b)) {
             throw new IOException("Failed to report split region to master: "
@@ -427,7 +427,7 @@ public class SplitTransaction {
           // Should add it to OnlineRegions
           services.addToOnlineRegions(b);
           if (useZKForAssignment) {
-            services.postOpenDeployTasks(a, server.getCatalogTracker());
+            services.postOpenDeployTasks(a);
           }
           services.addToOnlineRegions(a);
         } catch (KeeperException ke) {
@@ -482,7 +482,7 @@ public class SplitTransaction {
     return regions;
   }
 
-  private void offlineParentInMetaAndputMetaEntries(CatalogTracker catalogTracker,
+  private void offlineParentInMetaAndputMetaEntries(HConnection hConnection,
       HRegionInfo parent, HRegionInfo splitA, HRegionInfo splitB,
       ServerName serverName, List<Mutation> metaEntries) throws IOException {
     List<Mutation> mutations = metaEntries;
@@ -491,19 +491,19 @@ public class SplitTransaction {
     copyOfParent.setSplit(true);
 
     //Put for parent
-    Put putParent = MetaEditor.makePutFromRegionInfo(copyOfParent);
-    MetaEditor.addDaughtersToPut(putParent, splitA, splitB);
+    Put putParent = MetaTableAccessor.makePutFromRegionInfo(copyOfParent);
+    MetaTableAccessor.addDaughtersToPut(putParent, splitA, splitB);
     mutations.add(putParent);
     
     //Puts for daughters
-    Put putA = MetaEditor.makePutFromRegionInfo(splitA);
-    Put putB = MetaEditor.makePutFromRegionInfo(splitB);
+    Put putA = MetaTableAccessor.makePutFromRegionInfo(splitA);
+    Put putB = MetaTableAccessor.makePutFromRegionInfo(splitB);
 
     addLocation(putA, serverName, 1); //these are new regions, openSeqNum = 1 is fine.
     addLocation(putB, serverName, 1);
     mutations.add(putA);
     mutations.add(putB);
-    MetaEditor.mutateMetaTable(catalogTracker, mutations);
+    MetaTableAccessor.mutateMetaTable(hConnection, mutations);
   }
 
   public Put addLocation(final Put p, final ServerName sn, long openSeqNum) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/24a0a2a2/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
index 2749b18..ef30f08 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
@@ -297,9 +297,7 @@ public class OpenRegionHandler extends EventHandler {
   /**
    * Thread to run region post open tasks. Call {@link #getException()} after
    * the thread finishes to check for exceptions running
-   * {@link RegionServerServices#postOpenDeployTasks(
-   * HRegion, org.apache.hadoop.hbase.catalog.CatalogTracker)}
-   * .
+   * {@link RegionServerServices#postOpenDeployTasks(HRegion)
    */
   static class PostOpenDeployTasksThread extends Thread {
     private Throwable exception = null;
@@ -320,8 +318,7 @@ public class OpenRegionHandler extends EventHandler {
 
     public void run() {
       try {
-        this.services.postOpenDeployTasks(this.region,
-          this.server.getCatalogTracker());
+        this.services.postOpenDeployTasks(this.region);
       } catch (IOException e) {
         server.abort("Exception running postOpenDeployTasks; region=" +
             this.region.getRegionInfo().getEncodedName(), e);


Mime
View raw message