hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject [3/4] HBASE-11108 Split ZKTable into interface and implementation (Mikhail Antononv)
Date Thu, 22 May 2014 23:16:50 GMT
http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/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 056d5d3..fc391af 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
@@ -47,6 +47,7 @@ import org.apache.hadoop.hbase.master.RegionState;
 import org.apache.hadoop.hbase.master.RegionState.State;
 import org.apache.hadoop.hbase.master.RegionStates;
 import org.apache.hadoop.hbase.master.ServerManager;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.regionserver.wal.HLogSplitter;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
 import org.apache.zookeeper.KeeperException;
@@ -257,7 +258,8 @@ public class ServerShutdownHandler extends EventHandler {
               toAssignRegions.add(hri);
             } else if (rit != null) {
               if (rit.isPendingCloseOrClosing()
-                  && am.getZKTable().isDisablingOrDisabledTable(hri.getTable())) {
+                  && am.getTableStateManager().isTableState(hri.getTable(),
+                  ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING)) {
                 // If the table was partially disabled and the RS went down, we should clear the RIT
                 // and remove the node for the region.
                 // The rit that we use may be stale in case the table was in DISABLING state
@@ -334,14 +336,15 @@ public class ServerShutdownHandler extends EventHandler {
   public static boolean processDeadRegion(HRegionInfo hri, Result result,
       AssignmentManager assignmentManager, CatalogTracker catalogTracker)
   throws IOException {
-    boolean tablePresent = assignmentManager.getZKTable().isTablePresent(hri.getTable());
+    boolean tablePresent = assignmentManager.getTableStateManager().isTablePresent(hri.getTable());
     if (!tablePresent) {
       LOG.info("The table " + hri.getTable()
           + " was deleted.  Hence not proceeding.");
       return false;
     }
     // If table is not disabled but the region is offlined,
-    boolean disabled = assignmentManager.getZKTable().isDisabledTable(hri.getTable());
+    boolean disabled = assignmentManager.getTableStateManager().isTableState(hri.getTable(),
+      ZooKeeperProtos.Table.State.DISABLED);
     if (disabled){
       LOG.info("The table " + hri.getTable()
           + " was disabled.  Hence not proceeding.");
@@ -353,7 +356,8 @@ public class ServerShutdownHandler extends EventHandler {
       //to the dead server. We don't have to do anything.
       return false;
     }
-    boolean disabling = assignmentManager.getZKTable().isDisablingTable(hri.getTable());
+    boolean disabling = assignmentManager.getTableStateManager().isTableState(hri.getTable(),
+      ZooKeeperProtos.Table.State.DISABLING);
     if (disabling) {
       LOG.info("The table " + hri.getTable()
           + " is disabled.  Hence not assigning region" + hri.getEncodedName());

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/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 6e3176c..ed34875 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
@@ -29,6 +29,7 @@ import java.util.TreeMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.hbase.CoordinatedStateException;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -44,8 +45,8 @@ import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.BulkReOpen;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.master.TableLockManager.TableLock;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.zookeeper.KeeperException;
 
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
@@ -128,8 +129,8 @@ public abstract class TableEventHandler extends EventHandler {
           tableName);
       handleTableOperation(hris);
       if (eventType.isOnlineSchemaChangeSupported() && this.masterServices.
-          getAssignmentManager().getZKTable().
-          isEnabledTable(tableName)) {
+          getAssignmentManager().getTableStateManager().isTableState(
+          tableName, ZooKeeperProtos.Table.State.ENABLED)) {
         if (reOpenAllRegions(hris)) {
           LOG.info("Completed table operation " + eventType + " on table " +
               tableName);
@@ -141,7 +142,7 @@ public abstract class TableEventHandler extends EventHandler {
     } catch (IOException e) {
       LOG.error("Error manipulating table " + tableName, e);
       completed(e);
-    } catch (KeeperException e) {
+    } catch (CoordinatedStateException e) {
       LOG.error("Error manipulating table " + tableName, e);
       completed(e);
     } finally {
@@ -249,5 +250,5 @@ public abstract class TableEventHandler extends EventHandler {
   }
 
   protected abstract void handleTableOperation(List<HRegionInfo> regions)
-  throws IOException, KeeperException;
+    throws IOException, CoordinatedStateException;
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/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 7cc30b4..b4842d0 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
@@ -19,7 +19,6 @@
 package org.apache.hadoop.hbase.master.handler;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
@@ -27,25 +26,20 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+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.backup.HFileArchiver;
 import org.apache.hadoop.hbase.catalog.MetaEditor;
-import org.apache.hadoop.hbase.executor.EventType;
-import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.master.AssignmentManager;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.master.MasterCoprocessorHost;
 import org.apache.hadoop.hbase.master.MasterFileSystem;
 import org.apache.hadoop.hbase.master.MasterServices;
-import org.apache.hadoop.hbase.master.RegionStates;
-import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.util.FSTableDescriptors;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.ModifyRegionUtils;
-import org.apache.hadoop.hbase.util.Threads;
-import org.apache.zookeeper.KeeperException;
 
 /**
  * Truncate the table by removing META and the HDFS files and recreating it.
@@ -67,7 +61,7 @@ public class TruncateTableHandler extends DeleteTableHandler {
 
   @Override
   protected void handleTableOperation(List<HRegionInfo> regions)
-      throws IOException, KeeperException {
+      throws IOException, CoordinatedStateException {
     MasterCoprocessorHost cpHost = ((HMaster) this.server).getMasterCoprocessorHost();
     if (cpHost != null) {
       cpHost.preTruncateTableHandler(this.tableName);
@@ -137,8 +131,9 @@ public class TruncateTableHandler extends DeleteTableHandler {
 
       // 6. Set table enabled flag up in zk.
       try {
-        assignmentManager.getZKTable().setEnabledTable(tableName);
-      } catch (KeeperException e) {
+        assignmentManager.getTableStateManager().setTableState(tableName,
+          ZooKeeperProtos.Table.State.ENABLED);
+      } catch (CoordinatedStateException e) {
         throw new IOException("Unable to ensure that " + tableName + " will be" +
           " enabled because of a ZooKeeper issue", e);
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/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 27cd5c7..ddedf9f 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
@@ -62,6 +62,7 @@ import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameStringPair;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ProcedureDescription;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.snapshot.ClientSnapshotDescriptionUtils;
 import org.apache.hadoop.hbase.snapshot.HBaseSnapshotException;
 import org.apache.hadoop.hbase.snapshot.RestoreSnapshotException;
@@ -556,13 +557,15 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
     // if the table is enabled, then have the RS run actually the snapshot work
     TableName snapshotTable = TableName.valueOf(snapshot.getTable());
     AssignmentManager assignmentMgr = master.getAssignmentManager();
-    if (assignmentMgr.getZKTable().isEnabledTable(snapshotTable)) {
+    if (assignmentMgr.getTableStateManager().isTableState(snapshotTable,
+        ZooKeeperProtos.Table.State.ENABLED)) {
       LOG.debug("Table enabled, starting distributed snapshot.");
       snapshotEnabledTable(snapshot);
       LOG.debug("Started snapshot: " + ClientSnapshotDescriptionUtils.toString(snapshot));
     }
     // For disabled table, snapshot is created by the master
-    else if (assignmentMgr.getZKTable().isDisabledTable(snapshotTable)) {
+    else if (assignmentMgr.getTableStateManager().isTableState(snapshotTable,
+        ZooKeeperProtos.Table.State.DISABLED)) {
       LOG.debug("Table is disabled, running snapshot entirely on master.");
       snapshotDisabledTable(snapshot);
       LOG.debug("Started snapshot: " + ClientSnapshotDescriptionUtils.toString(snapshot));
@@ -692,8 +695,8 @@ public class SnapshotManager extends MasterProcedureManager implements Stoppable
 
     // Execute the restore/clone operation
     if (MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
-      if (master.getAssignmentManager().getZKTable().isEnabledTable(
-          TableName.valueOf(fsSnapshot.getTable()))) {
+      if (master.getAssignmentManager().getTableStateManager().isTableState(
+          TableName.valueOf(fsSnapshot.getTable()), ZooKeeperProtos.Table.State.ENABLED)) {
         throw new UnsupportedOperationException("Table '" +
             TableName.valueOf(fsSnapshot.getTable()) + "' must be disabled in order to " +
             "perform a restore operation" +

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/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 8e64414..e00056a 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
@@ -58,6 +58,8 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Chore;
 import org.apache.hadoop.hbase.ClockOutOfSyncException;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.CoordinatedStateManagerFactory;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -75,8 +77,6 @@ import org.apache.hadoop.hbase.catalog.MetaEditor;
 import org.apache.hadoop.hbase.client.ConnectionUtils;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HConnectionManager;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.ConsensusProviderFactory;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.exceptions.RegionMovedException;
 import org.apache.hadoop.hbase.exceptions.RegionOpeningException;
@@ -392,7 +392,7 @@ public class HRegionServer extends HasThread implements
 
   protected final RSRpcServices rpcServices;
 
-  protected ConsensusProvider consensusProvider;
+  protected CoordinatedStateManager csm;
 
   /**
    * Starts a HRegionServer at the default location.
@@ -401,17 +401,17 @@ public class HRegionServer extends HasThread implements
    * @throws InterruptedException
    */
   public HRegionServer(Configuration conf) throws IOException, InterruptedException {
-    this(conf, ConsensusProviderFactory.getConsensusProvider(conf));
+    this(conf, CoordinatedStateManagerFactory.getCoordinatedStateManager(conf));
   }
 
   /**
    * Starts a HRegionServer at the default location
    * @param conf
-   * @param consensusProvider implementation of ConsensusProvider to be used
+   * @param csm implementation of CoordinatedStateManager to be used
    * @throws IOException
    * @throws InterruptedException
    */
-  public HRegionServer(Configuration conf, ConsensusProvider consensusProvider)
+  public HRegionServer(Configuration conf, CoordinatedStateManager csm)
       throws IOException, InterruptedException {
     this.fsOk = true;
     this.conf = conf;
@@ -483,9 +483,9 @@ public class HRegionServer extends HasThread implements
       zooKeeper = new ZooKeeperWatcher(conf, getProcessName() + ":" +
         rpcServices.isa.getPort(), this, canCreateBaseZNode());
 
-      this.consensusProvider = consensusProvider;
-      this.consensusProvider.initialize(this);
-      this.consensusProvider.start();
+      this.csm = csm;
+      this.csm.initialize(this);
+      this.csm.start();
 
       tableLockManager = TableLockManager.createTableLockManager(
         conf, zooKeeper, serverName);
@@ -2155,8 +2155,8 @@ public class HRegionServer extends HasThread implements
   }
 
   @Override
-  public ConsensusProvider getConsensusProvider() {
-    return consensusProvider;
+  public CoordinatedStateManager getCoordinatedStateManager() {
+    return csm;
   }
 
   @Override
@@ -2253,10 +2253,10 @@ public class HRegionServer extends HasThread implements
    */
   public static HRegionServer constructRegionServer(
       Class<? extends HRegionServer> regionServerClass,
-      final Configuration conf2, ConsensusProvider cp) {
+      final Configuration conf2, CoordinatedStateManager cp) {
     try {
       Constructor<? extends HRegionServer> c = regionServerClass
-          .getConstructor(Configuration.class, ConsensusProvider.class);
+          .getConstructor(Configuration.class, CoordinatedStateManager.class);
       return c.newInstance(conf2, cp);
     } catch (Exception e) {
       throw new RuntimeException("Failed construction of " + "Regionserver: "

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
index 0385238..d56730a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServerCommandLine.java
@@ -23,10 +23,10 @@ import org.apache.commons.logging.LogFactory;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.CoordinatedStateManagerFactory;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.LocalHBaseCluster;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.ConsensusProviderFactory;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.util.ServerCommandLine;
 
 /**
@@ -52,7 +52,7 @@ public class HRegionServerCommandLine extends ServerCommandLine {
 
   private int start() throws Exception {
     Configuration conf = getConf();
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(conf);
+    CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
     try {
       // If 'local', don't start a region server here. Defer to
       // LocalHBaseCluster. It manages 'local' clusters.

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java
index e01bb00..1f4ac07 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/SplitLogWorker.java
@@ -35,7 +35,6 @@ 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.HConstants;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.SplitLogCounters;
@@ -123,7 +122,7 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
   }
 
   public SplitLogWorker(final ZooKeeperWatcher watcher, final Configuration conf,
-      RegionServerServices server, final LastSequenceId sequenceIdChecker) {
+      final RegionServerServices server, final LastSequenceId sequenceIdChecker) {
     this(watcher, conf, server, new TaskExecutor() {
       @Override
       public Status exec(String filename, CancelableProgressable p) {
@@ -141,7 +140,7 @@ public class SplitLogWorker extends ZooKeeperListener implements Runnable {
         // encountered a bad non-retry-able persistent error.
         try {
           if (!HLogSplitter.splitLogFile(rootdir, fs.getFileStatus(new Path(rootdir, filename)),
-            fs, conf, p, sequenceIdChecker, watcher)) {
+            fs, conf, p, sequenceIdChecker, watcher, server.getCoordinatedStateManager())) {
             return Status.PREEMPTED;
           }
         } catch (InterruptedIOException iioe) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
index fdf71cc..22adaf9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/HLogSplitter.java
@@ -56,6 +56,8 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellScanner;
 import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.CoordinatedStateException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -66,6 +68,7 @@ import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.TableNotFoundException;
+import org.apache.hadoop.hbase.TableStateManager;
 import org.apache.hadoop.hbase.Tag;
 import org.apache.hadoop.hbase.TagType;
 import org.apache.hadoop.hbase.client.ConnectionUtils;
@@ -89,6 +92,7 @@ import org.apache.hadoop.hbase.protobuf.generated.AdminProtos.WALEntry;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType;
 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos;
 import org.apache.hadoop.hbase.protobuf.generated.WALProtos.WALKey;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.RegionStoreSequenceIds;
 import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos.StoreSequenceId;
 import org.apache.hadoop.hbase.regionserver.HRegion;
@@ -104,10 +108,8 @@ import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
-import org.apache.hadoop.hbase.zookeeper.ZKTable;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.io.MultipleIOException;
-import org.apache.zookeeper.KeeperException;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
@@ -135,6 +137,7 @@ public class HLogSplitter {
   private Set<TableName> disablingOrDisabledTables =
       new HashSet<TableName>();
   private ZooKeeperWatcher watcher;
+  private CoordinatedStateManager csm;
 
   // If an exception is thrown by one of the other threads, it will be
   // stored here.
@@ -168,7 +171,8 @@ public class HLogSplitter {
   private final int minBatchSize;
 
   HLogSplitter(Configuration conf, Path rootDir,
-      FileSystem fs, LastSequenceId idChecker, ZooKeeperWatcher zkw) {
+      FileSystem fs, LastSequenceId idChecker, ZooKeeperWatcher zkw,
+      CoordinatedStateManager csm) {
     this.conf = HBaseConfiguration.create(conf);
     String codecClassName = conf
         .get(WALCellCodec.WAL_CELL_CODEC_CLASS_KEY, WALCellCodec.class.getName());
@@ -177,6 +181,7 @@ public class HLogSplitter {
     this.fs = fs;
     this.sequenceIdChecker = idChecker;
     this.watcher = zkw;
+    this.csm = csm;
 
     entryBuffers = new EntryBuffers(
         this.conf.getInt("hbase.regionserver.hlog.splitlog.buffersize",
@@ -188,7 +193,7 @@ public class HLogSplitter {
     this.distributedLogReplay = HLogSplitter.isDistributedLogReplay(this.conf);
 
     this.numWriterThreads = this.conf.getInt("hbase.regionserver.hlog.splitlog.writer.threads", 3);
-    if (zkw != null && this.distributedLogReplay) {
+    if (zkw != null && csm != null && this.distributedLogReplay) {
       outputSink = new LogReplayOutputSink(numWriterThreads);
     } else {
       if (this.distributedLogReplay) {
@@ -219,8 +224,9 @@ public class HLogSplitter {
    */
   public static boolean splitLogFile(Path rootDir, FileStatus logfile, FileSystem fs,
       Configuration conf, CancelableProgressable reporter, LastSequenceId idChecker,
-      ZooKeeperWatcher zkw) throws IOException {
-    HLogSplitter s = new HLogSplitter(conf, rootDir, fs, idChecker, zkw);
+      ZooKeeperWatcher zkw, CoordinatedStateManager cp) throws IOException {
+    HLogSplitter s = new HLogSplitter(conf, rootDir, fs, idChecker, zkw,
+      cp);
     return s.splitLogFile(logfile, reporter);
   }
 
@@ -234,7 +240,7 @@ public class HLogSplitter {
     List<Path> splits = new ArrayList<Path>();
     if (logfiles != null && logfiles.length > 0) {
       for (FileStatus logfile: logfiles) {
-        HLogSplitter s = new HLogSplitter(conf, rootDir, fs, null, null);
+        HLogSplitter s = new HLogSplitter(conf, rootDir, fs, null, null, null);
         if (s.splitLogFile(logfile, null)) {
           finishSplitLogFile(rootDir, oldLogDir, logfile.getPath(), conf);
           if (s.outputSink.splits != null) {
@@ -288,10 +294,12 @@ public class HLogSplitter {
         LOG.warn("Nothing to split in log file " + logPath);
         return true;
       }
-      if(watcher != null) {
+      if(watcher != null && csm != null) {
         try {
-          disablingOrDisabledTables = ZKTable.getDisabledOrDisablingTables(watcher);
-        } catch (KeeperException e) {
+          TableStateManager tsm = csm.getTableStateManager();
+          disablingOrDisabledTables = tsm.getTablesInStates(
+            ZooKeeperProtos.Table.State.DISABLED, ZooKeeperProtos.Table.State.DISABLING);
+        } catch (CoordinatedStateException e) {
           throw new IOException("Can't get disabling/disabled tables", e);
         }
       }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSyncUp.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSyncUp.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSyncUp.java
index 9f5afb6..cdb50fa 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSyncUp.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSyncUp.java
@@ -29,9 +29,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.replication.regionserver.Replication;
-import org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceManager;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.util.Tool;
@@ -146,7 +144,7 @@ public class ReplicationSyncUp extends Configured implements Tool {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index 1fcbc5c..d0c84b3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -103,7 +103,7 @@ import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandler;
 import org.apache.hadoop.hbase.util.hbck.TableIntegrityErrorHandlerImpl;
 import org.apache.hadoop.hbase.util.hbck.TableLockChecker;
 import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
-import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
+import org.apache.hadoop.hbase.zookeeper.ZKTableStateClientSideReader;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.hadoop.io.IOUtils;
 import org.apache.hadoop.security.AccessControlException;
@@ -1385,7 +1385,7 @@ public class HBaseFsck extends Configured {
         ZooKeeperWatcher zkw = createZooKeeperWatcher();
         try {
           for (TableName tableName :
-              ZKTableReadOnly.getDisabledOrDisablingTables(zkw)) {
+              ZKTableStateClientSideReader.getDisabledOrDisablingTables(zkw)) {
             disabledTables.add(tableName);
           }
         } catch (KeeperException ke) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
index fbff3ab..69681d9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/JVMClusterUtil.java
@@ -29,7 +29,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.util.ReflectionUtils;
@@ -81,14 +81,14 @@ public class JVMClusterUtil {
    * @return Region server added.
    */
   public static JVMClusterUtil.RegionServerThread createRegionServerThread(
-      final Configuration c, ConsensusProvider cp, final Class<? extends HRegionServer> hrsc,
+      final Configuration c, CoordinatedStateManager cp, final Class<? extends HRegionServer> hrsc,
       final int index)
   throws IOException {
     HRegionServer server;
     try {
       
       Constructor<? extends HRegionServer> ctor = hrsc.getConstructor(Configuration.class,
-      ConsensusProvider.class);
+      CoordinatedStateManager.class);
       ctor.setAccessible(true);
       server = ctor.newInstance(c, cp);
     } catch (InvocationTargetException ite) {
@@ -133,12 +133,12 @@ public class JVMClusterUtil {
    * @return Master added.
    */
   public static JVMClusterUtil.MasterThread createMasterThread(
-      final Configuration c, ConsensusProvider cp, final Class<? extends HMaster> hmc,
+      final Configuration c, CoordinatedStateManager cp, final Class<? extends HMaster> hmc,
       final int index)
   throws IOException {
     HMaster server;
     try {
-      server = hmc.getConstructor(Configuration.class, ConsensusProvider.class).
+      server = hmc.getConstructor(Configuration.class, CoordinatedStateManager.class).
         newInstance(c, cp);
     } catch (InvocationTargetException ite) {
       Throwable target = ite.getTargetException();

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
index 638d0c2..5edb69f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/MiniHBaseCluster.java
@@ -110,7 +110,7 @@ public class MiniHBaseCluster extends HBaseCluster {
     private User user = null;
     public static boolean TEST_SKIP_CLOSE = false;
 
-    public MiniHBaseClusterRegionServer(Configuration conf, ConsensusProvider cp)
+    public MiniHBaseClusterRegionServer(Configuration conf, CoordinatedStateManager cp)
         throws IOException, InterruptedException {
       super(conf, cp);
       this.user = User.getCurrent();

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/MockRegionServerServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/MockRegionServerServices.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/MockRegionServerServices.java
index 3a1e0f3..6d1cfc4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/MockRegionServerServices.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/MockRegionServerServices.java
@@ -136,7 +136,7 @@ class MockRegionServerServices implements RegionServerServices {
   }
 
   @Override
-  public ConsensusProvider getConsensusProvider() {
+  public CoordinatedStateManager getCoordinatedStateManager() {
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
index 85b833f..b3bf1f0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestDrainingServer.java
@@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.consensus.ZkCoordinatedStateManager;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.executor.ExecutorType;
@@ -108,6 +109,12 @@ public class TestDrainingServer {
     Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
     Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);
 
+    CoordinatedStateManager cp = new ZkCoordinatedStateManager();
+    cp.initialize(server);
+    cp.start();
+
+    Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);
+
     Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);
     Mockito.when(serverManager.getOnlineServersList())
     .thenReturn(new ArrayList<ServerName>(onlineServers.keySet()));
@@ -204,6 +211,12 @@ public class TestDrainingServer {
     Mockito.when(server.getServerName()).thenReturn(ServerName.valueOf("masterMock,1,1"));
     Mockito.when(server.getZooKeeper()).thenReturn(zkWatcher);
 
+    CoordinatedStateManager cp = new ZkCoordinatedStateManager();
+    cp.initialize(server);
+    cp.start();
+
+    Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);
+
     Mockito.when(serverManager.getOnlineServers()).thenReturn(onlineServers);
     Mockito.when(serverManager.getOnlineServersList()).thenReturn(
       new ArrayList<ServerName>(onlineServers.keySet()));
@@ -291,4 +304,4 @@ public class TestDrainingServer {
     executor.startExecutorService(ExecutorType.MASTER_META_SERVER_OPERATIONS, 3);
     return executor;
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/TestLocalHBaseCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestLocalHBaseCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestLocalHBaseCluster.java
index 7f9501b..729dca7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestLocalHBaseCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestLocalHBaseCluster.java
@@ -64,7 +64,7 @@ public class TestLocalHBaseCluster {
    * running in local mode.
    */
   public static class MyHMaster extends HMaster {
-    public MyHMaster(Configuration conf, ConsensusProvider cp)
+    public MyHMaster(Configuration conf, CoordinatedStateManager cp)
       throws IOException, KeeperException,
         InterruptedException {
       super(conf, cp);
@@ -80,7 +80,7 @@ public class TestLocalHBaseCluster {
    */
   public static class MyHRegionServer extends MiniHBaseCluster.MiniHBaseClusterRegionServer {
 
-    public MyHRegionServer(Configuration conf, ConsensusProvider cp) throws IOException,
+    public MyHRegionServer(Configuration conf, CoordinatedStateManager cp) throws IOException,
         InterruptedException {
       super(conf, cp);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
index 998cabb..54b751d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
@@ -60,12 +60,13 @@ import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.master.AssignmentManager;
 import org.apache.hadoop.hbase.master.HMaster;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.regionserver.wal.HLogUtilsForTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
-import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
+import org.apache.hadoop.hbase.zookeeper.ZKTableStateClientSideReader;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -255,8 +256,8 @@ public class TestAdmin {
 
     this.admin.disableTable(ht.getName());
     assertTrue("Table must be disabled.", TEST_UTIL.getHBaseCluster()
-        .getMaster().getAssignmentManager().getZKTable().isDisabledTable(
-            ht.getName()));
+        .getMaster().getAssignmentManager().getTableStateManager().isTableState(
+        ht.getName(), ZooKeeperProtos.Table.State.DISABLED));
 
     // Test that table is disabled
     get = new Get(row);
@@ -270,8 +271,8 @@ public class TestAdmin {
     assertTrue(ok);
     this.admin.enableTable(table);
     assertTrue("Table must be enabled.", TEST_UTIL.getHBaseCluster()
-        .getMaster().getAssignmentManager().getZKTable().isEnabledTable(
-            ht.getName()));
+        .getMaster().getAssignmentManager().getTableStateManager().isTableState(
+        ht.getName(), ZooKeeperProtos.Table.State.ENABLED));
 
     // Test that table is enabled
     try {
@@ -343,8 +344,8 @@ public class TestAdmin {
     tables = this.admin.listTables();
     assertEquals(numTables + 1, tables.length);
     assertTrue("Table must be enabled.", TEST_UTIL.getHBaseCluster()
-        .getMaster().getAssignmentManager().getZKTable().isEnabledTable(
-            TableName.valueOf("testCreateTable")));
+        .getMaster().getAssignmentManager().getTableStateManager().isTableState(
+        TableName.valueOf("testCreateTable"), ZooKeeperProtos.Table.State.ENABLED));
   }
 
   @Test (timeout=300000)
@@ -1125,8 +1126,8 @@ public class TestAdmin {
     ZooKeeperWatcher zkw = HBaseTestingUtility.getZooKeeperWatcher(TEST_UTIL);
     TableName tableName = TableName.valueOf("testMasterAdmin");
     TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY).close();
-    while (!ZKTableReadOnly.isEnabledTable(zkw,
-        TableName.valueOf("testMasterAdmin"))) {
+    while (!ZKTableStateClientSideReader.isEnabledTable(zkw,
+      TableName.valueOf("testMasterAdmin"))) {
       Thread.sleep(10);
     }
     this.admin.disableTable(tableName);

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientScannerRPCTimeout.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientScannerRPCTimeout.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientScannerRPCTimeout.java
index e35c618..95b9b21 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientScannerRPCTimeout.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestClientScannerRPCTimeout.java
@@ -30,7 +30,7 @@ import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.MiniHBaseCluster.MiniHBaseClusterRegionServer;
 import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.ipc.RpcClient;
 import org.apache.hadoop.hbase.ipc.RpcServer;
 import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ScanRequest;
@@ -130,7 +130,7 @@ public class TestClientScannerRPCTimeout {
   }
 
   private static class RegionServerWithScanTimeout extends MiniHBaseClusterRegionServer {
-    public RegionServerWithScanTimeout(Configuration conf, ConsensusProvider cp)
+    public RegionServerWithScanTimeout(Configuration conf, CoordinatedStateManager cp)
         throws IOException, InterruptedException {
       super(conf, cp);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
index 0489ead..0924dd2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
@@ -39,7 +39,7 @@ import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.ipc.PayloadCarryingRpcController;
 import org.apache.hadoop.hbase.ipc.RpcServerInterface;
@@ -269,7 +269,7 @@ ClientProtos.ClientService.BlockingInterface, RegionServerServices {
   }
 
   @Override
-  public ConsensusProvider getConsensusProvider() {
+  public CoordinatedStateManager getCoordinatedStateManager() {
     return null;
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
index 326b1a2..1c010b2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
@@ -28,12 +28,12 @@ import java.util.concurrent.Semaphore;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.ConsensusProvider;
 import org.apache.hadoop.hbase.monitoring.MonitoredTask;
 import org.apache.hadoop.hbase.zookeeper.ClusterStatusTracker;
 import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
@@ -282,7 +282,7 @@ public class TestActiveMasterManager {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
index 20fbc0f..5cf10f3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManager.java
@@ -32,6 +32,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.hadoop.hbase.CellScannable;
 import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.CoordinatedStateException;
+import org.apache.hadoop.hbase.CoordinatedStateManagerFactory;
 import org.apache.hadoop.hbase.DoNotRetryIOException;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
@@ -50,8 +52,8 @@ import org.apache.hadoop.hbase.catalog.MetaMockingUtil;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HConnectionTestingUtility;
 import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.ConsensusProviderFactory;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.consensus.ZkCoordinatedStateManager;
 import org.apache.hadoop.hbase.exceptions.DeserializationException;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.executor.ExecutorService;
@@ -116,6 +118,7 @@ public class TestAssignmentManager {
   private Server server;
   private ServerManager serverManager;
   private ZooKeeperWatcher watcher;
+  private CoordinatedStateManager cp;
   private LoadBalancer balancer;
   private HMaster master;
 
@@ -146,6 +149,12 @@ public class TestAssignmentManager {
     Mockito.doThrow(new RuntimeException("Aborted")).
       when(server).abort(Mockito.anyString(), (Throwable)Mockito.anyObject());
 
+    cp = new ZkCoordinatedStateManager();
+    cp.initialize(this.server);
+    cp.start();
+
+    Mockito.when(server.getCoordinatedStateManager()).thenReturn(cp);
+
     // Mock a ServerManager.  Say server SERVERNAME_{A,B} are online.  Also
     // make it so if close or open, we return 'success'.
     this.serverManager = Mockito.mock(ServerManager.class);
@@ -184,6 +193,7 @@ public class TestAssignmentManager {
       // Clean up all znodes
       ZKAssign.deleteAllNodes(this.watcher);
       this.watcher.close();
+      this.cp.stop();
     }
   }
 
@@ -197,7 +207,8 @@ public class TestAssignmentManager {
    */
   @Test(timeout = 60000)
   public void testBalanceOnMasterFailoverScenarioWithOpenedNode()
-  throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
+      throws IOException, KeeperException, InterruptedException, ServiceException,
+      DeserializationException, CoordinatedStateException {
     AssignmentManagerWithExtrasForTesting am =
       setUpMockedAssignmentManager(this.server, this.serverManager);
     try {
@@ -244,8 +255,9 @@ public class TestAssignmentManager {
   }
 
   @Test(timeout = 60000)
-  public void testBalanceOnMasterFailoverScenarioWithClosedNode()
-  throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
+  public void testBalanceOnMasterFailoverScenarioWithClosedNode() 
+      throws IOException, KeeperException, InterruptedException, ServiceException,
+        DeserializationException, CoordinatedStateException {
     AssignmentManagerWithExtrasForTesting am =
       setUpMockedAssignmentManager(this.server, this.serverManager);
     try {
@@ -294,7 +306,8 @@ public class TestAssignmentManager {
 
   @Test(timeout = 60000)
   public void testBalanceOnMasterFailoverScenarioWithOfflineNode()
-  throws IOException, KeeperException, InterruptedException, ServiceException, DeserializationException {
+      throws IOException, KeeperException, InterruptedException, ServiceException,
+      DeserializationException, CoordinatedStateException {
     AssignmentManagerWithExtrasForTesting am =
       setUpMockedAssignmentManager(this.server, this.serverManager);
     try {
@@ -359,8 +372,8 @@ public class TestAssignmentManager {
    * @throws DeserializationException
    */
   @Test
-  public void testBalance()
-    throws IOException, KeeperException, DeserializationException, InterruptedException {
+  public void testBalance() throws IOException, KeeperException, DeserializationException,
+      InterruptedException, CoordinatedStateException {
     // Create and startup an executor.  This is used by AssignmentManager
     // handling zk callbacks.
     ExecutorService executor = startupMasterExecutor("testBalanceExecutor");
@@ -435,7 +448,7 @@ public class TestAssignmentManager {
    */
   @Test
   public void testShutdownHandler()
-      throws KeeperException, IOException, ServiceException {
+      throws KeeperException, IOException, CoordinatedStateException, ServiceException {
     // Create and startup an executor.  This is used by AssignmentManager
     // handling zk callbacks.
     ExecutorService executor = startupMasterExecutor("testShutdownHandler");
@@ -466,7 +479,7 @@ public class TestAssignmentManager {
    */
   @Test
   public void testSSHWhenDisableTableInProgress() throws KeeperException, IOException,
-      ServiceException {
+    CoordinatedStateException, ServiceException {
     testCaseWithPartiallyDisabledState(Table.State.DISABLING);
     testCaseWithPartiallyDisabledState(Table.State.DISABLED);
   }
@@ -488,7 +501,8 @@ public class TestAssignmentManager {
   }
 
   private void testCaseWithSplitRegionPartial(boolean regionSplitDone) throws KeeperException,
-      IOException, NodeExistsException, InterruptedException, ServiceException {
+      IOException, InterruptedException,
+    CoordinatedStateException, ServiceException {
     // Create and startup an executor. This is used by AssignmentManager
     // handling zk callbacks.
     ExecutorService executor = startupMasterExecutor("testSSHWhenSplitRegionInProgress");
@@ -504,7 +518,8 @@ public class TestAssignmentManager {
     // adding region in pending close.
     am.getRegionStates().updateRegionState(
       REGIONINFO, State.SPLITTING, SERVERNAME_A);
-    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
+    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+      Table.State.ENABLED);
     RegionTransition data = RegionTransition.createRegionTransition(EventType.RS_ZK_REGION_SPLITTING,
         REGIONINFO.getRegionName(), SERVERNAME_A);
     String node = ZKAssign.getNodeName(this.watcher, REGIONINFO.getEncodedName());
@@ -536,7 +551,7 @@ public class TestAssignmentManager {
   }
 
   private void testCaseWithPartiallyDisabledState(Table.State state) throws KeeperException,
-      IOException, NodeExistsException, ServiceException {
+      IOException, CoordinatedStateException, ServiceException {
     // Create and startup an executor. This is used by AssignmentManager
     // handling zk callbacks.
     ExecutorService executor = startupMasterExecutor("testSSHWhenDisableTableInProgress");
@@ -553,9 +568,11 @@ public class TestAssignmentManager {
     // adding region in pending close.
     am.getRegionStates().updateRegionState(REGIONINFO, State.PENDING_CLOSE);
     if (state == Table.State.DISABLING) {
-      am.getZKTable().setDisablingTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.DISABLING);
     } else {
-      am.getZKTable().setDisabledTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.DISABLED);
     }
     RegionTransition data = RegionTransition.createRegionTransition(EventType.M_ZK_REGION_CLOSING,
         REGIONINFO.getRegionName(), SERVERNAME_A);
@@ -668,7 +685,8 @@ public class TestAssignmentManager {
   }
 
   @Test
-  public void testUnassignWithSplitAtSameTime() throws KeeperException, IOException {
+  public void testUnassignWithSplitAtSameTime() throws KeeperException,
+      IOException, CoordinatedStateException {
     // Region to use in test.
     final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
     // First amend the servermanager mock so that when we do send close of the
@@ -713,7 +731,8 @@ public class TestAssignmentManager {
    */
   @Test(timeout = 60000)
   public void testProcessDeadServersAndRegionsInTransitionShouldNotFailWithNPE()
-      throws IOException, KeeperException, InterruptedException, ServiceException {
+      throws IOException, KeeperException, CoordinatedStateException,
+      InterruptedException, ServiceException {
     final RecoverableZooKeeper recoverableZk = Mockito
         .mock(RecoverableZooKeeper.class);
     AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
@@ -744,7 +763,7 @@ public class TestAssignmentManager {
    */
   @Test(timeout = 60000)
   public void testRegionPlanIsUpdatedWhenRegionFailsToOpen() throws IOException, KeeperException,
-      ServiceException, InterruptedException {
+      ServiceException, InterruptedException, CoordinatedStateException {
     this.server.getConfiguration().setClass(
       HConstants.HBASE_MASTER_LOADBALANCER_CLASS, MockedLoadBalancer.class,
       LoadBalancer.class);
@@ -842,7 +861,7 @@ public class TestAssignmentManager {
    */
   @Test(timeout = 60000)
   public void testRegionInOpeningStateOnDeadRSWhileMasterFailover() throws IOException,
-      KeeperException, ServiceException, InterruptedException {
+      KeeperException, ServiceException, CoordinatedStateException, InterruptedException {
     AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(
       this.server, this.serverManager);
     ZKAssign.createNodeOffline(this.watcher, REGIONINFO, SERVERNAME_A);
@@ -858,7 +877,8 @@ public class TestAssignmentManager {
     am.gate.set(false);
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
     assertFalse(am.processRegionsInTransition(rt, REGIONINFO, version));
-    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
+    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+      Table.State.ENABLED);
     processServerShutdownHandler(ct, am, false);
     // Waiting for the assignment to get completed.
     while (!am.gate.get()) {
@@ -889,8 +909,9 @@ public class TestAssignmentManager {
     // To avoid cast exception in DisableTableHandler process.
     HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
 
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(HTU.getConfiguration());
-    Server server = new HMaster(HTU.getConfiguration(), cp);
+    CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
+      HTU.getConfiguration());
+    Server server = new HMaster(HTU.getConfiguration(), csm);
     AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
         this.serverManager);
     AtomicBoolean gate = new AtomicBoolean(false);
@@ -899,7 +920,8 @@ public class TestAssignmentManager {
     }
     try{
       // set table in disabling state.
-      am.getZKTable().setDisablingTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.DISABLING);
       am.joinCluster();
       // should not call retainAssignment if we get empty regions in assignAllUserRegions.
       assertFalse(
@@ -907,12 +929,14 @@ public class TestAssignmentManager {
           gate.get());
       // need to change table state from disabling to disabled.
       assertTrue("Table should be disabled.",
-          am.getZKTable().isDisabledTable(REGIONINFO.getTable()));
+          am.getTableStateManager().isTableState(REGIONINFO.getTable(),
+            Table.State.DISABLED));
     } finally {
       this.server.getConfiguration().setClass(
         HConstants.HBASE_MASTER_LOADBALANCER_CLASS, SimpleLoadBalancer.class,
         LoadBalancer.class);
-      am.getZKTable().setEnabledTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.ENABLED);
       am.shutdown();
     }
   }
@@ -932,24 +956,28 @@ public class TestAssignmentManager {
     Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
     HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(HTU.getConfiguration());
-    Server server = new HMaster(HTU.getConfiguration(), cp);
+    CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
+      HTU.getConfiguration());
+    Server server = new HMaster(HTU.getConfiguration(), csm);
     Whitebox.setInternalState(server, "serverManager", this.serverManager);
     AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
         this.serverManager);
     try {
       // set table in enabling state.
-      am.getZKTable().setEnablingTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.ENABLING);
       new EnableTableHandler(server, REGIONINFO.getTable(),
           am.getCatalogTracker(), am, new NullTableLockManager(), true).prepare()
           .process();
       assertEquals("Number of assignments should be 1.", 1, assignmentCount);
       assertTrue("Table should be enabled.",
-          am.getZKTable().isEnabledTable(REGIONINFO.getTable()));
+          am.getTableStateManager().isTableState(REGIONINFO.getTable(),
+            Table.State.ENABLED));
     } finally {
       enabling = false;
       assignmentCount = 0;
-      am.getZKTable().setEnabledTable(REGIONINFO.getTable());
+      am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+        Table.State.ENABLED);
       am.shutdown();
       ZKAssign.deleteAllNodes(this.watcher);
     }
@@ -964,24 +992,26 @@ public class TestAssignmentManager {
    */
   @Test
   public void testMasterRestartShouldRemoveStaleZnodesOfUnknownTableAsForMeta()
-      throws KeeperException, IOException, Exception {
+      throws Exception {
     List<ServerName> destServers = new ArrayList<ServerName>(1);
     destServers.add(SERVERNAME_A);
     Mockito.when(this.serverManager.createDestinationServersList()).thenReturn(destServers);
     Mockito.when(this.serverManager.isServerOnline(SERVERNAME_A)).thenReturn(true);
     HTU.getConfiguration().setInt(HConstants.MASTER_PORT, 0);
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(HTU.getConfiguration());
-    Server server = new HMaster(HTU.getConfiguration(), cp);
+    CoordinatedStateManager csm = CoordinatedStateManagerFactory.getCoordinatedStateManager(
+      HTU.getConfiguration());
+    Server server = new HMaster(HTU.getConfiguration(), csm);
     Whitebox.setInternalState(server, "serverManager", this.serverManager);
     AssignmentManagerWithExtrasForTesting am = setUpMockedAssignmentManager(server,
         this.serverManager);
     try {
       TableName tableName = TableName.valueOf("dummyTable");
       // set table in enabling state.
-      am.getZKTable().setEnablingTable(tableName);
+      am.getTableStateManager().setTableState(tableName,
+        Table.State.ENABLING);
       am.joinCluster();
       assertFalse("Table should not be present in zookeeper.",
-        am.getZKTable().isTablePresent(tableName));
+        am.getTableStateManager().isTablePresent(tableName));
     } finally {
     }
   }
@@ -992,7 +1022,7 @@ public class TestAssignmentManager {
    */
   @Test
   public void testSSHTimesOutOpeningRegionTransition()
-      throws KeeperException, IOException, ServiceException {
+      throws KeeperException, IOException, CoordinatedStateException, ServiceException {
     // We need a mocked catalog tracker.
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
     // Create an AM.
@@ -1006,7 +1036,8 @@ public class TestAssignmentManager {
     // adding region plan
     am.regionPlans.put(REGIONINFO.getEncodedName(),
       new RegionPlan(REGIONINFO, SERVERNAME_B, SERVERNAME_A));
-    am.getZKTable().setEnabledTable(REGIONINFO.getTable());
+    am.getTableStateManager().setTableState(REGIONINFO.getTable(),
+      Table.State.ENABLED);
 
     try {
       am.assignInvoked = false;
@@ -1102,7 +1133,8 @@ public class TestAssignmentManager {
    * @throws KeeperException
    */
   private AssignmentManagerWithExtrasForTesting setUpMockedAssignmentManager(final Server server,
-      final ServerManager manager) throws IOException, KeeperException, ServiceException {
+      final ServerManager manager) throws IOException, KeeperException,
+        ServiceException, CoordinatedStateException {
     // We need a mocked catalog tracker. Its used by our AM instance.
     CatalogTracker ct = Mockito.mock(CatalogTracker.class);
     // Make an RS Interface implementation. Make it so a scanner can go against
@@ -1173,7 +1205,7 @@ public class TestAssignmentManager {
         final Server master, final ServerManager serverManager,
         final CatalogTracker catalogTracker, final LoadBalancer balancer,
         final ExecutorService service, final TableLockManager tableLockManager)
-            throws KeeperException, IOException {
+            throws KeeperException, IOException, CoordinatedStateException {
       super(master, serverManager, catalogTracker, balancer, service, null, tableLockManager);
       this.es = service;
       this.ct = catalogTracker;
@@ -1267,6 +1299,8 @@ public class TestAssignmentManager {
           throw new RuntimeException(e);
         } catch (InterruptedException e) {
           throw new RuntimeException(e);
+        } catch (CoordinatedStateException e) {
+          throw new RuntimeException(e);
         }
       }
     };
@@ -1309,7 +1343,8 @@ public class TestAssignmentManager {
    * assignment). So during master failover, we can ignored such events too.
    */
   @Test
-  public void testAssignmentEventIgnoredIfNotExpected() throws KeeperException, IOException {
+  public void testAssignmentEventIgnoredIfNotExpected() throws KeeperException, IOException,
+      CoordinatedStateException {
     // Region to use in test.
     final HRegionInfo hri = HRegionInfo.FIRST_META_REGIONINFO;
     // Need a mocked catalog tracker.

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
index 0344cef..a6cd57a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestAssignmentManagerOnCluster.java
@@ -48,7 +48,7 @@ import org.apache.hadoop.hbase.Waiter;
 import org.apache.hadoop.hbase.catalog.MetaEditor;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.coprocessor.BaseRegionObserver;
 import org.apache.hadoop.hbase.coprocessor.CoprocessorHost;
 import org.apache.hadoop.hbase.coprocessor.ObserverContext;
@@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.coprocessor.RegionObserver;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.RegionState.State;
 import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -567,7 +568,7 @@ public class TestAssignmentManagerOnCluster {
         Thread.sleep(100);
       }
 
-      am.getZKTable().setDisablingTable(table);
+      am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLING);
       List<HRegionInfo> toAssignRegions = am.processServerShutdown(destServerName);
       assertTrue("Regions to be assigned should be empty.", toAssignRegions.isEmpty());
       assertTrue("Regions to be assigned should be empty.", am.getRegionStates()
@@ -576,7 +577,7 @@ public class TestAssignmentManagerOnCluster {
       if (hri != null && serverName != null) {
         am.regionOnline(hri, serverName);
       }
-      am.getZKTable().setDisabledTable(table);
+      am.getTableStateManager().setTableState(table, ZooKeeperProtos.Table.State.DISABLED);
       TEST_UTIL.deleteTable(table);
     }
   }
@@ -838,7 +839,7 @@ public class TestAssignmentManagerOnCluster {
   public static class MyMaster extends HMaster {
     AtomicBoolean enabled = new AtomicBoolean(true);
 
-    public MyMaster(Configuration conf, ConsensusProvider cp)
+    public MyMaster(Configuration conf, CoordinatedStateManager cp)
       throws IOException, KeeperException,
         InterruptedException {
       super(conf, cp);

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
index 0814357..3b69c16 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
@@ -56,7 +56,7 @@ import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HConnectionManager;
 import org.apache.hadoop.hbase.client.HConnectionTestingUtility;
 import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.io.Reference;
 import org.apache.hadoop.hbase.master.CatalogJanitor.SplitParentFirstComparator;
@@ -165,7 +165,7 @@ public class TestCatalogJanitor {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 
@@ -249,7 +249,7 @@ public class TestCatalogJanitor {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
index a4baf63..687012c 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
@@ -27,7 +27,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -62,7 +62,7 @@ public class TestClockSkewDetection {
       }
 
       @Override
-      public ConsensusProvider getConsensusProvider() {
+      public CoordinatedStateManager getCoordinatedStateManager() {
         return null;
       }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java
index 00a42a2..95c1cdf 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestHMasterRPCException.java
@@ -26,8 +26,8 @@ import java.net.SocketTimeoutException;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.*;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.ConsensusProviderFactory;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.CoordinatedStateManagerFactory;
 import org.apache.hadoop.hbase.ipc.RpcClient;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.generated.MasterProtos;
@@ -48,7 +48,7 @@ public class TestHMasterRPCException {
     TEST_UTIL.startMiniZKCluster();
     Configuration conf = TEST_UTIL.getConfiguration();
     conf.set(HConstants.MASTER_PORT, "0");
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(conf);
+    CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(conf);
     HMaster hm = new HMaster(conf, cp);
     ServerName sm = hm.getServerName();
     RpcClient rpcClient = new RpcClient(conf, HConstants.CLUSTER_ID_DEFAULT);

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
index 5216366..d0ddc96 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMaster.java
@@ -24,6 +24,7 @@ import org.apache.hadoop.hbase.*;
 import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
 
@@ -67,7 +68,8 @@ public class TestMaster {
     HMaster m = cluster.getMaster();
 
     HTable ht = TEST_UTIL.createTable(TABLENAME, FAMILYNAME);
-    assertTrue(m.assignmentManager.getZKTable().isEnabledTable(TABLENAME));
+    assertTrue(m.assignmentManager.getTableStateManager().isTableState(TABLENAME,
+      ZooKeeperProtos.Table.State.ENABLED));
     TEST_UTIL.loadTable(ht, FAMILYNAME, false);
     ht.close();
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
index af33ea7..1ba4e1b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterFailover.java
@@ -47,9 +47,11 @@ import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.RegionTransition;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.TableName;
+import org.apache.hadoop.hbase.TableStateManager;
 import org.apache.hadoop.hbase.executor.EventType;
 import org.apache.hadoop.hbase.master.RegionState.State;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.regionserver.RegionMergeTransaction;
@@ -63,7 +65,7 @@ import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
 import org.apache.hadoop.hbase.util.Threads;
 import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZKTable;
+import org.apache.hadoop.hbase.zookeeper.ZKTableStateManager;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.zookeeper.data.Stat;
 import org.junit.Test;
@@ -305,8 +307,8 @@ public class TestMasterFailover {
     log("Beginning to mock scenarios");
 
     // Disable the disabledTable in ZK
-    ZKTable zktable = new ZKTable(zkw);
-    zktable.setDisabledTable(disabledTable);
+    TableStateManager zktable = new ZKTableStateManager(zkw);
+    zktable.setTableState(disabledTable, ZooKeeperProtos.Table.State.DISABLED);
 
     /*
      *  ZK = OFFLINE
@@ -620,7 +622,8 @@ public class TestMasterFailover {
     log("Assignment completed");
 
     assertTrue(" Table must be enabled.", master.getAssignmentManager()
-        .getZKTable().isEnabledTable(TableName.valueOf("enabledTable")));
+        .getTableStateManager().isTableState(TableName.valueOf("enabledTable"),
+        ZooKeeperProtos.Table.State.ENABLED));
     // we also need regions assigned out on the dead server
     List<HRegionInfo> enabledAndOnDeadRegions = new ArrayList<HRegionInfo>();
     enabledAndOnDeadRegions.addAll(enabledRegions.subList(0, 6));
@@ -694,11 +697,12 @@ public class TestMasterFailover {
     log("Beginning to mock scenarios");
 
     // Disable the disabledTable in ZK
-    ZKTable zktable = new ZKTable(zkw);
-    zktable.setDisabledTable(disabledTable);
+    TableStateManager zktable = new ZKTableStateManager(zkw);
+    zktable.setTableState(disabledTable, ZooKeeperProtos.Table.State.DISABLED);
 
     assertTrue(" The enabled table should be identified on master fail over.",
-        zktable.isEnabledTable(TableName.valueOf("enabledTable")));
+        zktable.isTableState(TableName.valueOf("enabledTable"),
+          ZooKeeperProtos.Table.State.ENABLED));
 
     /*
      * ZK = CLOSING

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
index d03d2ae..2bae847 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterMetrics.java
@@ -23,11 +23,11 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.CompatibilityFactory;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.ServerName;
-import org.apache.hadoop.hbase.ConsensusProvider;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos;
@@ -50,7 +50,7 @@ public class TestMasterMetrics {
   private static HBaseTestingUtility TEST_UTIL;
 
   public static class MyMaster extends HMaster {
-    public MyMaster(Configuration conf, ConsensusProvider cp) throws IOException,
+    public MyMaster(Configuration conf, CoordinatedStateManager cp) throws IOException,
         KeeperException, InterruptedException {
       super(conf, cp);
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
index badc3ce..d7cdc73 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterNoCluster.java
@@ -32,6 +32,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.Abortable;
+import org.apache.hadoop.hbase.CoordinatedStateException;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.CoordinatedStateManagerFactory;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
@@ -46,8 +49,6 @@ import org.apache.hadoop.hbase.catalog.MetaMockingUtil;
 import org.apache.hadoop.hbase.client.HConnection;
 import org.apache.hadoop.hbase.client.HConnectionTestingUtility;
 import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.ConsensusProvider;
-import org.apache.hadoop.hbase.ConsensusProviderFactory;
 import org.apache.hadoop.hbase.monitoring.MonitoredTask;
 import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
 import org.apache.hadoop.hbase.protobuf.generated.RegionServerStatusProtos.RegionServerReportRequest;
@@ -125,7 +126,7 @@ public class TestMasterNoCluster {
   @Test (timeout=30000)
   public void testStopDuringStart()
   throws IOException, KeeperException, InterruptedException {
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(
+    CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(
       TESTUTIL.getConfiguration());
     HMaster master = new HMaster(TESTUTIL.getConfiguration(), cp);
     master.start();
@@ -177,7 +178,7 @@ public class TestMasterNoCluster {
     // and get notification on transitions.  We need to fake out any rpcs the
     // master does opening/closing regions.  Also need to fake out the address
     // of the 'remote' mocked up regionservers.
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(
+    CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(
       TESTUTIL.getConfiguration());
     HMaster master = new HMaster(conf, cp) {
       InetAddress getRemoteInetAddress(final int port, final long serverStartCode)
@@ -260,7 +261,7 @@ public class TestMasterNoCluster {
     final ServerName deadServer = ServerName.valueOf("test.sample", 1, 100);
     final MockRegionServer rs0 = new MockRegionServer(conf, newServer);
 
-    ConsensusProvider cp = ConsensusProviderFactory.getConsensusProvider(
+    CoordinatedStateManager cp = CoordinatedStateManagerFactory.getCoordinatedStateManager(
       TESTUTIL.getConfiguration());
     HMaster master = new HMaster(conf, cp) {
       @Override
@@ -269,7 +270,7 @@ public class TestMasterNoCluster {
 
       @Override
       void initializeZKBasedSystemTrackers() throws IOException,
-      InterruptedException, KeeperException {
+      InterruptedException, KeeperException, CoordinatedStateException {
         super.initializeZKBasedSystemTrackers();
         // Record a newer server in server manager at first
         serverManager.recordNewServerWithLock(newServer, ServerLoad.EMPTY_SERVERLOAD);

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
index c7ddddb..dcb4c16 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterRestartAfterDisablingTable.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.TableName;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.protobuf.generated.ZooKeeperProtos;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.JVMClusterUtil.MasterThread;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
@@ -96,8 +97,9 @@ public class TestMasterRestartAfterDisablingTable {
     cluster.waitForActiveAndReadyMaster();
 
     assertTrue("The table should not be in enabled state", cluster.getMaster()
-        .getAssignmentManager().getZKTable().isDisablingOrDisabledTable(
-            TableName.valueOf("tableRestart")));
+        .getAssignmentManager().getTableStateManager().isTableState(
+        TableName.valueOf("tableRestart"), ZooKeeperProtos.Table.State.DISABLED,
+        ZooKeeperProtos.Table.State.DISABLING));
     log("Enabling table\n");
     // Need a new Admin, the previous one is on the old master
     HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
@@ -111,8 +113,8 @@ public class TestMasterRestartAfterDisablingTable {
         + " switch except for the catalog and namespace tables.",
           6, regions.size());
     assertTrue("The table should be in enabled state", cluster.getMaster()
-        .getAssignmentManager().getZKTable()
-        .isEnabledTable(TableName.valueOf("tableRestart")));
+        .getAssignmentManager().getTableStateManager()
+        .isTableState(TableName.valueOf("tableRestart"), ZooKeeperProtos.Table.State.ENABLED));
     ht.close();
     TEST_UTIL.shutdownMiniCluster();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
index ce6b777..7bd7893 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestOpenedRegionHandler.java
@@ -38,7 +38,7 @@ import org.apache.hadoop.hbase.regionserver.HRegionServer;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.MockServer;
 import org.apache.hadoop.hbase.zookeeper.ZKAssign;
-import org.apache.hadoop.hbase.zookeeper.ZKTable;
+import org.apache.hadoop.hbase.zookeeper.ZKTableStateManager;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 import org.apache.zookeeper.KeeperException;
@@ -130,7 +130,7 @@ public class TestOpenedRegionHandler {
       // create a node with OPENED state
       zkw = HBaseTestingUtility.createAndForceNodeToOpenedState(TEST_UTIL,
           region, server.getServerName());
-      when(am.getZKTable()).thenReturn(new ZKTable(zkw));
+      when(am.getTableStateManager()).thenReturn(new ZKTableStateManager(zkw));
       Stat stat = new Stat();
       String nodeName = ZKAssign.getNodeName(zkw, region.getRegionInfo()
           .getEncodedName());

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
index d44a3dc..8f62ec0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileCleaner.java
@@ -29,13 +29,13 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.MediumTests;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
-import org.apache.hadoop.hbase.ConsensusProvider;
 import org.apache.hadoop.hbase.util.EnvironmentEdge;
 import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
@@ -210,7 +210,7 @@ public class TestHFileCleaner {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea0731d6/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java
index 55a8ff6..e4a26f0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestHFileLinkCleaner.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.hbase.ServerName;
 import org.apache.hadoop.hbase.SmallTests;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.ConsensusProvider;
+import org.apache.hadoop.hbase.CoordinatedStateManager;
 import org.apache.hadoop.hbase.io.HFileLink;
 import org.apache.hadoop.hbase.util.FSUtils;
 import org.apache.hadoop.hbase.util.HFileArchiveUtil;
@@ -146,7 +146,7 @@ public class TestHFileLinkCleaner {
     }
 
     @Override
-    public ConsensusProvider getConsensusProvider() {
+    public CoordinatedStateManager getCoordinatedStateManager() {
       return null;
     }
 


Mime
View raw message