You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2010/08/24 01:58:21 UTC

svn commit: r988358 - in /hbase/branches/0.90_master_rewrite/src: main/java/org/apache/hadoop/hbase/ main/java/org/apache/hadoop/hbase/catalog/ main/java/org/apache/hadoop/hbase/client/ main/java/org/apache/hadoop/hbase/executor/ main/java/org/apache/h...

Author: stack
Date: Mon Aug 23 23:58:20 2010
New Revision: 988358

URL: http://svn.apache.org/viewvc?rev=988358&view=rev
Log:

First cut at running split, compact, flush and closes from client
rather than from master.

M src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
  Minor changes to what methods throw.
M src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
  Use new methods.  Removed unused imports and method.
M src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
  Started new testSplitCompactFlushClose method.
M src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
  Added some overloads so can start an open of a daughter region
  from a RS on split.
M src/main/java/org/apache/hadoop/hbase/HConstants.java
  Formatting.
M src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
  Make this subclassable.
M src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
  Adding open of regions on the regionserver that did the split.
M src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
  Add handling of split message to master.
M src/main/java/org/apache/hadoop/hbase/master/HMaster.java
  Formatting.
M src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
  Move checks up into the constructor.
M src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
  Added two types for opening of regions by rs on split.
M src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
  First cut at running split, close, flush, and compact from client
  rather than over in master.
M src/main/java/org/apache/hadoop/hbase/HMsg.java
  Remove unused types.

Added:
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java
Modified:
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HConstants.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HMsg.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HConstants.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HConstants.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HConstants.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HConstants.java Mon Aug 23 23:58:20 2010
@@ -343,7 +343,8 @@ public final class HConstants {
    * HRegion server lease period in milliseconds. Clients must report in within this period
    * else they are considered dead. Unit measured in ms (milliseconds).
    */
-  public static String HBASE_REGIONSERVER_LEASE_PERIOD_KEY   = "hbase.regionserver.lease.period";
+  public static String HBASE_REGIONSERVER_LEASE_PERIOD_KEY =
+    "hbase.regionserver.lease.period";
 
 
   /**

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HMsg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HMsg.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HMsg.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/HMsg.java Mon Aug 23 23:58:20 2010
@@ -43,22 +43,6 @@ public class HMsg implements Writable {
   public static final HMsg [] EMPTY_HMSG_ARRAY = new HMsg[0];
 
   public static enum Type {
-    /** Split the specified region */
-    SPLIT_REGION,
-
-    /** Compact the specified region */
-    COMPACT_REGION,
-
-    /**
-     * Flush region.
-     */
-    FLUSH_REGION,
-
-    /**
-     * Run Major Compaction
-     */
-    MAJOR_COMPACTION,
-
     /** Master tells region server to stop.
      */
     STOP_REGIONSERVER,

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java Mon Aug 23 23:58:20 2010
@@ -71,13 +71,16 @@ public class CatalogTracker {
   /**
    * Constructs the catalog tracker.  Find current state of catalog tables and
    * begin active tracking by executing {@link #start()}.
-   * @param zookeeper zk reference
+   * @param zk
    * @param connection server connection
    * @param abortable if fatal exception
+   * @throws IOException 
    */
-  public CatalogTracker(ZooKeeperWatcher zookeeper, ServerConnection connection,
-      Abortable abortable, int defaultTimeout) {
-    this.zookeeper = zookeeper;
+  public CatalogTracker(final ZooKeeperWatcher zk,
+      final ServerConnection connection, final Abortable abortable,
+      final int defaultTimeout)
+  throws IOException {
+    this.zookeeper = zk;
     this.connection = connection;
     this.rootRegionTracker = new RootRegionTracker(zookeeper, abortable);
     this.metaNodeTracker = new MetaNodeTracker(zookeeper, this);

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/client/HBaseAdmin.java Mon Aug 23 23:58:20 2010
@@ -28,55 +28,81 @@ import java.util.NavigableMap;
 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.ClusterStatus;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.RegionException;
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.TableExistsException;
-import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.ipc.HMasterInterface;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.util.MetaUtils;
+import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Writables;
-import org.apache.hadoop.io.BooleanWritable;
-import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.ipc.RemoteException;
 
 /**
  * Provides administrative functions for HBase
  */
-public class HBaseAdmin {
+public class HBaseAdmin implements Abortable {
   private final Log LOG = LogFactory.getLog(this.getClass().getName());
 //  private final HConnection connection;
   final HConnection connection;
   private volatile Configuration conf;
   private final long pause;
   private final int numRetries;
+  /**
+   * Lazily instantiated.  Use {@link #getCatalogTracker()} to ensure you get
+   * an instance rather than a null.
+   */
+  private CatalogTracker catalogTracker = null;
 
   /**
    * Constructor
    *
    * @param conf Configuration object
-   * @throws MasterNotRunningException if the master is not running
-   * @throws ZooKeeperConnectionException if unable to connect to zookeeper
+   * @throws IOException 
    */
   public HBaseAdmin(Configuration conf)
-  throws MasterNotRunningException, ZooKeeperConnectionException {
+  throws IOException {
     this.connection = HConnectionManager.getConnection(conf);
     this.conf = conf;
     this.pause = conf.getLong("hbase.client.pause", 30 * 1000);
     this.numRetries = conf.getInt("hbase.client.retries.number", 5);
-    // make sure we can get to the master
-    connection.getMaster();
+    this.connection.getMaster();
+  }
+
+  private synchronized CatalogTracker getCatalogTracker()
+  throws ZooKeeperConnectionException, IOException {
+    if (this.catalogTracker == null) {
+      this.catalogTracker = new CatalogTracker(this.connection.getZooKeeperWatcher(),
+        ServerConnectionManager.getConnection(conf), this,
+        this.conf.getInt("hbase.admin.catalog.timeout", 10 * 1000));
+      try {
+        this.catalogTracker.start();
+      } catch (InterruptedException e) {
+        // Let it out as an IOE for now until we redo all so tolerate IEs
+        Thread.currentThread().interrupt();
+        throw new IOException("Interrupted", e);
+      }
+    }
+    return this.catalogTracker;
+  }
+
+  @Override
+  public void abort(String why, Throwable e) {
+    // Currently does nothing but throw the passed message and exception
+    throw new RuntimeException(why, e);
   }
 
   /** @return HConnection used by this object. */
@@ -265,7 +291,7 @@ public class HBaseAdmin {
       try {
         Thread.sleep(getPauseTime(tries));
       } catch (InterruptedException e) {
-        // continue
+        // Just continue; ignore the interruption.
       }
     }
   }
@@ -668,42 +694,41 @@ public class HBaseAdmin {
 
   /**
    * Close a region. For expert-admins.
-   * Asynchronous operation.
-   *
    * @param regionname region name to close
-   * @param Optional server name.  Otherwise, we'll send close to the
-   * server registered in .META.
+   * @param hostAndPort If supplied, we'll use this location rather than
+   * the one currently in <code>.META.</code>
    * @throws IOException if a remote or network exception occurs
    */
-  public void closeRegion(final String regionname, final Object... args)
+  public void closeRegion(final String regionname, final String hostAndPort)
   throws IOException {
-    // TODO: reimplement this.  i don't think we will be able to send a
-    //       server name anymore as client does not have this, would have to
-    //       use META or be passed an HServerAddress
-    closeRegion(Bytes.toBytes(regionname), args);
+    closeRegion(Bytes.toBytes(regionname), hostAndPort);
   }
 
   /**
    * Close a region.  For expert-admins.
-   * Asynchronous operation.
-   *
    * @param regionname region name to close
-   * @param args Optional server name.  Otherwise, we'll send close to the
-   * server registered in .META.
+   * @param hostAndPort If supplied, we'll use this location rather than
+   * the one currently in <code>.META.</code>
    * @throws IOException if a remote or network exception occurs
    */
-  public void closeRegion(final byte [] regionname, final Object... args)
+  public void closeRegion(final byte [] regionname, final String hostAndPort)
   throws IOException {
-    // Be careful. Must match the handler over in HMaster at MODIFY_CLOSE_REGION
-    int len = (args == null)? 0: args.length;
-    int xtraArgsCount = 1;
-    Object [] newargs = new Object[len + xtraArgsCount];
-    newargs[0] = regionname;
-    if(args != null) {
-      System.arraycopy(args, 0, newargs, xtraArgsCount, len);
+    if (hostAndPort != null) {
+      HServerAddress hsa = new HServerAddress(hostAndPort);
+      Pair<HRegionInfo, HServerAddress> pair =
+        MetaReader.getRegion(getCatalogTracker(), regionname);
+      closeRegion(hsa, pair.getFirst());
+    } else {
+      Pair<HRegionInfo, HServerAddress> pair =
+        MetaReader.getRegion(getCatalogTracker(), regionname);
+      closeRegion(pair.getSecond(), pair.getFirst());
     }
-    modifyTable(HConstants.META_TABLE_NAME, HConstants.Modify.CLOSE_REGION,
-      newargs);
+  }
+
+  private void closeRegion(final HServerAddress hsa, final HRegionInfo hri)
+  throws IOException {
+    HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+    rs.closeRegion(hri);
   }
 
   /**
@@ -725,40 +750,25 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public void flush(final byte [] tableNameOrRegionName) throws IOException {
-    // TODO: implement two new connection methods and change split/compact
-    boolean isTable = checkTableOrRegion(tableNameOrRegionName);
-    if(!isTable) {
-      HRegionLocation hrl = connection.locateRegion(tableNameOrRegionName);
-      HRegionInterface hri =
-        connection.getHRegionConnection(hrl.getServerAddress());
-      hri.flushRegion(hrl.getRegionInfo());
-      return;
-    }
-    List<HRegionLocation> regionLocations =
-      connection.locateRegions(tableNameOrRegionName);
-    for(HRegionLocation hrl : regionLocations) {
-      HRegionInterface hri =
-        connection.getHRegionConnection(hrl.getServerAddress());
-      hri.flushRegion(hrl.getRegionInfo());
+    boolean isRegionName = isRegionName(tableNameOrRegionName);
+    if (isRegionName) {
+      Pair<HRegionInfo, HServerAddress> pair =
+        MetaReader.getRegion(getCatalogTracker(), tableNameOrRegionName);
+      flush(pair.getSecond(), pair.getFirst());
+    } else {
+      List<Pair<HRegionInfo, HServerAddress>> pairs =
+        MetaReader.getTableRegionsAndLocations(getCatalogTracker(),
+          Bytes.toString(tableNameOrRegionName));
+      for (Pair<HRegionInfo, HServerAddress> pair: pairs) {
+        flush(pair.getSecond(), pair.getFirst());
+      }
     }
   }
 
-  /**
-   * Checks if the specified table or region name is a table or region.  Returns
-   * true if it is a table name and false if not (so likely a region name).
-   * @param tableNameOrRegionName
-   * @return true if table, false if not
-   * @throws IllegalArgumentException
-   * @throws ZooKeeperConnectionException 
-   * @throws MasterNotRunningException 
-   */
-  private boolean checkTableOrRegion(final byte [] tableNameOrRegionName)
-  throws IllegalArgumentException, MasterNotRunningException,
-  ZooKeeperConnectionException {
-    if (tableNameOrRegionName == null) {
-      throw new IllegalArgumentException("Pass a table name or region name");
-    }
-    return tableExists(tableNameOrRegionName);
+  private void flush(final HServerAddress hsa, final HRegionInfo hri)
+  throws IOException {
+    HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+    rs.flushRegion(hri);
   }
 
   /**
@@ -780,7 +790,7 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public void compact(final byte [] tableNameOrRegionName) throws IOException {
-    modifyTable(tableNameOrRegionName, HConstants.Modify.TABLE_COMPACT);
+    compact(tableNameOrRegionName, false);
   }
 
   /**
@@ -804,7 +814,38 @@ public class HBaseAdmin {
    */
   public void majorCompact(final byte [] tableNameOrRegionName)
   throws IOException {
-    modifyTable(tableNameOrRegionName, HConstants.Modify.TABLE_MAJOR_COMPACT);
+    compact(tableNameOrRegionName, true);
+  }
+
+  /**
+   * Compact a table or an individual region.
+   * Asynchronous operation.
+   *
+   * @param tableNameOrRegionName table or region to compact
+   * @param major True if we are to do a major compaction.
+   * @throws IOException if a remote or network exception occurs
+   */
+  private void compact(final byte [] tableNameOrRegionName, final boolean major)
+  throws IOException {
+    if (isRegionName(tableNameOrRegionName)) {
+      Pair<HRegionInfo, HServerAddress> pair =
+        MetaReader.getRegion(getCatalogTracker(), tableNameOrRegionName);
+      compact(pair.getSecond(), pair.getFirst(), major);
+    } else {
+      List<Pair<HRegionInfo, HServerAddress>> pairs =
+        MetaReader.getTableRegionsAndLocations(getCatalogTracker(),
+          Bytes.toString(tableNameOrRegionName));
+      for (Pair<HRegionInfo, HServerAddress> pair: pairs) {
+        compact(pair.getSecond(), pair.getFirst(), major);
+      }
+    }
+  }
+
+  private void compact(final HServerAddress hsa, final HRegionInfo hri,
+      final boolean major)
+  throws IOException {
+    HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+    rs.compactRegion(hri, major);
   }
 
   /**
@@ -826,7 +867,25 @@ public class HBaseAdmin {
    * @throws IOException if a remote or network exception occurs
    */
   public void split(final byte [] tableNameOrRegionName) throws IOException {
-    modifyTable(tableNameOrRegionName, HConstants.Modify.TABLE_SPLIT);
+    if (isRegionName(tableNameOrRegionName)) {
+      // Its a possible region name.
+      Pair<HRegionInfo, HServerAddress> pair =
+        MetaReader.getRegion(getCatalogTracker(), tableNameOrRegionName);
+      split(pair.getSecond(), pair.getFirst());
+    } else {
+      List<Pair<HRegionInfo, HServerAddress>> pairs =
+        MetaReader.getTableRegionsAndLocations(getCatalogTracker(),
+          Bytes.toString(tableNameOrRegionName));
+      for (Pair<HRegionInfo, HServerAddress> pair: pairs) {
+        split(pair.getSecond(), pair.getFirst());
+      }
+    }
+  }
+
+  private void split(final HServerAddress hsa, final HRegionInfo hri)
+  throws IOException {
+    HRegionInterface rs = this.connection.getHRegionConnection(hsa);
+    rs.splitRegion(hri);
   }
 
   /**
@@ -850,106 +909,20 @@ public class HBaseAdmin {
     }
   }
 
-
-  /*
-   * Call modifyTable using passed tableName or region name String.  If no
-   * such table, presume we have been passed a region name.
-   * @param tableNameOrRegionName
-   * @param op
-   * @throws IOException
+  /**
+   * @param tableNameOrRegionName Name of a table or name of a region.
+   * @return True if <code>tableNameOrRegionName</code> is *possibly* a region
+   * name else false if a verified tablename (we call {@link #tableExists(byte[])};
+   * else we throw an exception.
+   * @throws ZooKeeperConnectionException 
+   * @throws MasterNotRunningException 
    */
-  private void modifyTable(final byte [] tableNameOrRegionName,
-      final HConstants.Modify op)
-  throws IOException {
+  private boolean isRegionName(final byte [] tableNameOrRegionName)
+  throws MasterNotRunningException, ZooKeeperConnectionException {
     if (tableNameOrRegionName == null) {
       throw new IllegalArgumentException("Pass a table name or region name");
     }
-    byte [] tableName = tableExists(tableNameOrRegionName)?
-      tableNameOrRegionName: null;
-    byte [] regionName = tableName == null? tableNameOrRegionName: null;
-    Object [] args = regionName == null? null: new byte [][] {regionName};
-    modifyTable(tableName == null? null: tableName, op, args);
-  }
-
-  /**
-   * Modify an existing table.
-   * Asynchronous operation.
-   *
-   * @param tableName name of table.  May be null if we are operating on a
-   * region.
-   * @param op table modification operation
-   * @param args operation specific arguments
-   * @throws IOException if a remote or network exception occurs
-   */
-  public void modifyTable(final byte [] tableName, HConstants.Modify op,
-      Object... args)
-      throws IOException {
-    // Let pass if its a catalog table.  Used by admins.
-    if (tableName != null && !MetaUtils.isMetaTableName(tableName)) {
-      // This will throw exception
-      HTableDescriptor.isLegalTableName(tableName);
-    }
-    Writable[] arr = null;
-    try {
-      switch (op) {
-      case TABLE_SET_HTD:
-        if (args == null || args.length < 1 ||
-            !(args[0] instanceof HTableDescriptor)) {
-          throw new IllegalArgumentException("SET_HTD requires a HTableDescriptor");
-        }
-        arr = new Writable[1];
-        arr[0] = (HTableDescriptor)args[0];
-        // getMaster().modifyTable(tableName, htd);
-        break;
-
-      case TABLE_COMPACT:
-      case TABLE_SPLIT:
-      case TABLE_MAJOR_COMPACT:
-      case TABLE_FLUSH:
-        if (args != null && args.length > 0) {
-          arr = new Writable[1];
-          if (args[0] instanceof byte[]) {
-            arr[0] = new ImmutableBytesWritable((byte[])args[0]);
-          } else if (args[0] instanceof ImmutableBytesWritable) {
-            arr[0] = (ImmutableBytesWritable)args[0];
-          } else if (args[0] instanceof String) {
-            arr[0] = new ImmutableBytesWritable(Bytes.toBytes((String)args[0]));
-          } else {
-            throw new IllegalArgumentException("Requires byte[], String, or" +
-              "ImmutableBytesWritable");
-          }
-        }
-//        getMaster().modifyTable(tableName, op, arr);
-        break;
-
-      case CLOSE_REGION:
-        if (args == null || args.length < 1) {
-          throw new IllegalArgumentException("Requires at least a region name");
-        }
-        arr = new Writable[args.length];
-        for (int i = 0; i < args.length; i++) {
-          if (args[i] instanceof byte[]) {
-            arr[i] = new ImmutableBytesWritable((byte[])args[i]);
-          } else if (args[i] instanceof ImmutableBytesWritable) {
-            arr[i] = (ImmutableBytesWritable)args[i];
-          } else if (args[i] instanceof String) {
-            arr[i] = new ImmutableBytesWritable(Bytes.toBytes((String)args[i]));
-          } else if (args[i] instanceof Boolean) {
-            arr[i] = new BooleanWritable((Boolean) args[i]);
-          } else {
-            throw new IllegalArgumentException("Requires byte [] or " +
-              "ImmutableBytesWritable, not " + args[i]);
-          }
-        }
-//        getMaster().modifyTable(tableName, op, arr);
-        break;
-
-      default:
-        throw new IOException("unknown modifyTable op " + op);
-      }
-    } catch (RemoteException e) {
-      throw RemoteExceptionHandler.decodeRemoteException(e);
-    }
+    return !tableExists(tableNameOrRegionName);
   }
 
   /**
@@ -998,13 +971,12 @@ public class HBaseAdmin {
    * Check to see if HBase is running. Throw an exception if not.
    *
    * @param conf system configuration
-   * @throws MasterNotRunningException if a remote or network exception occurs
-   * @throws ZooKeeperConnectionException if unable to connect to zookeeper
+   * @throws IOException 
    */
   public static void checkHBaseAvailable(Configuration conf)
-  throws MasterNotRunningException, ZooKeeperConnectionException {
+  throws IOException {
     Configuration copyOfConf = HBaseConfiguration.create(conf);
     copyOfConf.setInt("hbase.client.retries.number", 1);
     new HBaseAdmin(copyOfConf);
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java Mon Aug 23 23:58:20 2010
@@ -104,6 +104,9 @@ public abstract class EventHandler imple
     RS2ZK_REGION_CLOSED       (2),   // RS has finished closing a region
     RS2ZK_REGION_OPENING      (3),   // RS is in process of opening a region
     RS2ZK_REGION_OPENED       (4),   // RS has finished opening a region
+    RS2ZK_REGION_OFFLINE      (5),   // RS adds region as offline in zk
+
+    RS2RS_OPEN_REGION         (10),  // RS scheduling a region open on itself.
 
     // Messages originating from Master to RS
     M2RS_OPEN_REGION          (20),  // Master asking RS to open a region

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java Mon Aug 23 23:58:20 2010
@@ -124,6 +124,7 @@ public class ExecutorService {
       // RegionServer executor services
 
       case M2RS_OPEN_REGION:
+      case RS2RS_OPEN_REGION:
         return ExecutorType.RS_OPEN_REGION;
 
       case M2RS_OPEN_ROOT:

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Mon Aug 23 23:58:20 2010
@@ -336,4 +336,4 @@ public interface HRegionInterface extend
    */
   void compactRegion(HRegionInfo regionInfo, boolean major)
   throws NotServingRegionException, IOException;
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Mon Aug 23 23:58:20 2010
@@ -232,8 +232,8 @@ implements HMasterInterface, HMasterRegi
     this.serverManager = new ServerManager(this, this.connection, metrics,
       fileSystemManager, this.executorService);
 
-    this.catalogTracker = new CatalogTracker(zooKeeper, connection, this,
-      conf.getInt("hbase.master.catalog.timeout", -1));
+    this.catalogTracker = new CatalogTracker(this.zooKeeper, this.connection,
+      this, conf.getInt("hbase.master.catalog.timeout", -1));
     this.catalogTracker.start();
 
     this.assignmentManager = new AssignmentManager(this, serverManager,
@@ -805,7 +805,7 @@ implements HMasterInterface, HMasterRegi
   }
 
   protected static void doMain(String [] args,
-      Class<? extends HMaster> masterClass) {
+      Class<? extends HMaster> masterClass) throws IOException {
     if (args.length < 1) {
       printUsageAndExit();
     }
@@ -895,8 +895,9 @@ implements HMasterInterface, HMasterRegi
   /**
    * Main program
    * @param args
+   * @throws IOException 
    */
-  public static void main(String [] args) {
+  public static void main(String [] args) throws IOException {
     doMain(args, HMaster.class);
   }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Mon Aug 23 23:58:20 2010
@@ -277,7 +277,7 @@ public class ServerManager {
    * @throws IOException
    */
   HMsg [] regionServerReport(final HServerInfo serverInfo,
-    final HMsg msgs[], final HRegionInfo[] mostLoadedRegions)
+    final HMsg [] msgs, final HRegionInfo[] mostLoadedRegions)
   throws IOException {
     // Be careful. This method does returns in the middle.
     HServerInfo info = new HServerInfo(serverInfo);
@@ -298,6 +298,18 @@ public class ServerManager {
       return HMsg.STOP_REGIONSERVER_ARRAY;
     }
 
+    for (HMsg msg: msgs) {
+      LOG.info("Received " + msg);
+      switch (msg.getType()) {
+        REGION_SPLIT:
+          // Nothing to do?
+          break;
+
+        default:
+          LOG.error("Unhandled msg type " + msg);
+      }
+    }
+
     HMsg [] reply = null;
     int numservers = numServers();
     if (this.clusterShutdown) {

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DisableTableHandler.java Mon Aug 23 23:58:20 2010
@@ -39,16 +39,22 @@ public class DisableTableHandler extends
 
   private final byte [] tableName;
   private final String tableNameStr;
-  private final CatalogTracker catalogTracker;
   private final AssignmentManager assignmentManager;
 
   public DisableTableHandler(Server server, byte [] tableName,
-      CatalogTracker catalogTracker, AssignmentManager assignmentManager) {
+      CatalogTracker catalogTracker, AssignmentManager assignmentManager)
+  throws TableNotFoundException, IOException {
     super(server, EventType.C2M_DISABLE_TABLE);
     this.tableName = tableName;
     this.tableNameStr = Bytes.toString(this.tableName);
-    this.catalogTracker = catalogTracker;
     this.assignmentManager = assignmentManager;
+    // Check if table exists
+    // TODO: do we want to keep this in-memory as well?  i guess this is
+    //       part of old master rewrite, schema to zk to check for table
+    //       existence and such
+    if(!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
+      throw new TableNotFoundException(Bytes.toString(tableName));
+    }
   }
 
   @Override
@@ -62,13 +68,6 @@ public class DisableTableHandler extends
   }
 
   private void handleDisableTable() throws IOException {
-    // Check if table exists
-    // TODO: do we want to keep this in-memory as well?  i guess this is
-    //       part of old master rewrite, schema to zk to check for table
-    //       existence and such
-    if(!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
-      throw new TableNotFoundException(Bytes.toString(tableName));
-    }
     // Set the table as disabled so it doesn't get re-onlined
     assignmentManager.disableTable(this.tableNameStr);
     // Get the online regions of this table.

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/EnableTableHandler.java Mon Aug 23 23:58:20 2010
@@ -39,16 +39,21 @@ public class EnableTableHandler extends 
 
   private final byte [] tableName;
   private final String tableNameStr;
-  private final CatalogTracker catalogTracker;
   private final AssignmentManager assignmentManager;
+  private final CatalogTracker ct;
 
   public EnableTableHandler(Server server, byte [] tableName,
-      CatalogTracker catalogTracker, AssignmentManager assignmentManager) {
+      CatalogTracker catalogTracker, AssignmentManager assignmentManager)
+  throws TableNotFoundException, IOException {
     super(server, EventType.C2M_ENABLE_TABLE);
     this.tableName = tableName;
     this.tableNameStr = Bytes.toString(tableName);
-    this.catalogTracker = catalogTracker;
+    this.ct = catalogTracker;
     this.assignmentManager = assignmentManager;
+    // Check if table exists
+    if(!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
+      throw new TableNotFoundException(Bytes.toString(tableName));
+    }
   }
 
   @Override
@@ -62,13 +67,8 @@ public class EnableTableHandler extends 
   }
 
   private void handleEnableTable() throws IOException {
-    // Check if table exists
-    if(!MetaReader.tableExists(catalogTracker, this.tableNameStr)) {
-      throw new TableNotFoundException(Bytes.toString(tableName));
-    }
     // Get the regions of this table
-    List<HRegionInfo> regions = MetaReader.getTableRegions(catalogTracker,
-        tableName);
+    List<HRegionInfo> regions = MetaReader.getTableRegions(this.ct, tableName);
     // Set the table as disabled so it doesn't get re-onlined
     assignmentManager.undisableTable(this.tableNameStr);
     // Verify all regions of table are disabled
@@ -76,4 +76,4 @@ public class EnableTableHandler extends 
       assignmentManager.assign(region);
     }
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/OpenedRegionHandler.java Mon Aug 23 23:58:20 2010
@@ -97,4 +97,4 @@ public class OpenedRegionHandler extends
     assignmentManager.regionOnline(regionInfo, serverInfo);
     LOG.debug("Opened region " + regionInfo.getRegionNameAsString());
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java Mon Aug 23 23:58:20 2010
@@ -52,7 +52,7 @@ public class TableDeleteFamilyHandler ex
           "Family '" + Bytes.toString(familyName) + "' does not exist so " +
           "cannot be deleted");
     }
-    for(HRegionInfo hri : hris) {
+    for (HRegionInfo hri : hris) {
       // Update the HTD
       hri.getTableDesc().removeFamily(familyName);
       // Update region in META

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java Mon Aug 23 23:58:20 2010
@@ -27,8 +27,11 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.RemoteExceptionHandler;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
+import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.util.Writables;
+import org.apache.hadoop.hbase.zookeeper.ZKAssign;
 import org.apache.hadoop.util.StringUtils;
+import org.apache.zookeeper.KeeperException;
 
 import java.io.IOException;
 import java.util.HashSet;
@@ -144,7 +147,7 @@ public class CompactSplitThread extends 
   throws IOException {
     final HRegionInfo oldRegionInfo = region.getRegionInfo();
     final long startTime = System.currentTimeMillis();
-    final HRegion[] newRegions = region.splitRegion(midKey);
+    final HRegion [] newRegions = region.splitRegion(midKey);
     if (newRegions == null) {
       // Didn't need to be split
       return;
@@ -200,6 +203,19 @@ public class CompactSplitThread extends 
       t.put(put);
     }
 
+    // Open the regions on this server. TODO: Revisit.  Make sure no holes.
+    for (int i = 0; i < newRegions.length; i++) {
+      HRegionInfo hri = newRegions[i].getRegionInfo();
+      try {
+        ZKAssign.createNodeOffline(this.server.getZooKeeper(), hri,
+          this.server.getServerName(), EventType.RS2ZK_REGION_OFFLINE);
+      } catch (KeeperException e) {
+        this.server.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
+        return;
+      }
+      this.server.openRegion(hri);
+    }
+
     // If we crash here, the master will not know of the new daughters and they
     // will not be assigned.  The metascanner when it runs will notice and take
     // care of assigning the new daughters.
@@ -208,7 +224,7 @@ public class CompactSplitThread extends 
     server.reportSplit(oldRegionInfo, newRegions[0].getRegionInfo(),
       newRegions[1].getRegionInfo());
 
-    LOG.info("region split, META updated, and report to master all" +
+    LOG.info("region split, META updated, daughters opened, and report to master all" +
       " successful. Old region=" + oldRegionInfo.toString() +
       ", new regions: " + newRegions[0].toString() + ", " +
       newRegions[1].toString() + ". Split took " +
@@ -233,4 +249,4 @@ public class CompactSplitThread extends 
   public int getCompactionQueueSize() {
     return compactionQueue.size();
   }
-}
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Mon Aug 23 23:58:20 2010
@@ -346,8 +346,8 @@ public class HRegionServer implements HR
     masterAddressManager.start();
 
     // create the catalog tracker and start it
-    this.catalogTracker = new CatalogTracker(zooKeeper, connection, this,
-        conf.getInt("hbase.regionserver.catalog.timeout", -1));
+    this.catalogTracker = new CatalogTracker(this.zooKeeper, this.connection,
+      this, this.conf.getInt("hbase.regionserver.catalog.timeout", -1));
     catalogTracker.start();
 
     this.clusterStatusTracker = new ClusterStatusTracker(this.zooKeeper, this);

Added: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java?rev=988358&view=auto
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java (added)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java Mon Aug 23 23:58:20 2010
@@ -0,0 +1,56 @@
+/**
+ * Copyright 2010 The Apache Software Foundation
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.regionserver.handler;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.Server;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.regionserver.RegionServerServices;
+import org.apache.hadoop.hbase.zookeeper.ZKAssign;
+import org.apache.zookeeper.KeeperException;
+
+public class OpenDaughterRegionHandler extends OpenRegionHandler {
+  private static final Log LOG = LogFactory.getLog(OpenDaughterRegionHandler.class);
+
+  public OpenDaughterRegionHandler(Server server,
+      RegionServerServices rsServices, CatalogTracker catalogTracker,
+      HRegionInfo regionInfo) {
+    super(server, rsServices, catalogTracker, regionInfo, EventType.RS2RS_OPEN_REGION);
+  }
+
+  @Override
+  int transitionZookeeper(String encodedName) {
+    // Transition ZK node from no znode to OPENING
+    int openingVersion = -1;
+    try {
+      if ((openingVersion = ZKAssign.transitionNodeOpening(server.getZooKeeper(),
+          getRegionInfo(), server.getServerName(), EventType.RS2RS_OPEN_REGION)) == -1) {
+        LOG.warn("Error transitioning node from OFFLINE to OPENING, " +
+          "aborting open");
+      }
+    } catch (KeeperException e) {
+      LOG.error("Error transitioning node from OFFLINE to OPENING for region " +
+        encodedName, e);
+    }
+    return openingVersion;
+  }
+}
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java Mon Aug 23 23:58:20 2010
@@ -89,21 +89,8 @@ public class OpenRegionHandler extends E
       return;
     }
 
-    // Transition ZK node from OFFLINE to OPENING
-    // TODO: should also handle transition from CLOSED?
-    int openingVersion;
-    try {
-      if((openingVersion = ZKAssign.transitionNodeOpening(server.getZooKeeper(),
-          regionInfo, server.getServerName())) == -1) {
-        LOG.warn("Error transitioning node from OFFLINE to OPENING, " +
-            "aborting open");
-        return;
-      }
-    } catch (KeeperException e) {
-      LOG.error("Error transitioning node from OFFLINE to OPENING for region " +
-        encodedName, e);
-      return;
-    }
+    int openingVersion = transitionZookeeper(encodedName);
+    if (openingVersion == -1) return;
 
     // Open the region
     final AtomicInteger openingInteger = new AtomicInteger(openingVersion);
@@ -131,6 +118,8 @@ public class OpenRegionHandler extends E
         "; resetting state of transition node from OPENING to OFFLINE");
       try {
         // TODO: We should rely on the master timing out OPENING instead of this
+        // TODO: What if this was a split open?  The RS made the OFFLINE
+        // znode, not the master.
         ZKAssign.forceNodeOffline(server.getZooKeeper(), regionInfo,
             server.getServerName());
       } catch (KeeperException e1) {
@@ -212,4 +201,21 @@ public class OpenRegionHandler extends E
     // Done!  Successful region open
     LOG.debug("Opened " + region.getRegionNameAsString());
   }
+
+  int transitionZookeeper(final String encodedName) {
+    // Transition ZK node from OFFLINE to OPENING
+    // TODO: should also handle transition from CLOSED?
+    int openingVersion = -1;
+    try {
+      if ((openingVersion = ZKAssign.transitionNodeOpening(server.getZooKeeper(),
+          regionInfo, server.getServerName())) == -1) {
+        LOG.warn("Error transitioning node from OFFLINE to OPENING, " +
+            "aborting open");
+      }
+    } catch (KeeperException e) {
+      LOG.error("Error transitioning node from OFFLINE to OPENING for region " +
+        encodedName, e);
+    }
+    return openingVersion;
+  }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java Mon Aug 23 23:58:20 2010
@@ -107,14 +107,12 @@ public class ZKAssign {
   // Master methods
 
   /**
-   * Creates a new unassigned node in the OFFLINE state for the specified
-   * region.
+   * Creates a new unassigned node in the OFFLINE state for the specified region.
    *
    * <p>Does not transition nodes from other states.  If a node already exists
    * for this region, a {@link NodeExistsException} will be thrown.
    *
-   * <p>Sets a watcher on the unassigned region node if the method is
-   * successful.
+   * <p>Sets a watcher on the unassigned region node if the method is successful.
    *
    * <p>This method should only be used during cluster startup and the enabling
    * of a table.
@@ -128,10 +126,16 @@ public class ZKAssign {
   public static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
       String serverName)
   throws KeeperException, KeeperException.NodeExistsException {
+    createNodeOffline(zkw, region, serverName, EventType.M2ZK_REGION_OFFLINE);
+  }
+
+  public static void createNodeOffline(ZooKeeperWatcher zkw, HRegionInfo region,
+      String serverName, final EventType event)
+  throws KeeperException, KeeperException.NodeExistsException {
     zkw.debug("Creating an unassigned node for " + region.getEncodedName() +
         " in an OFFLINE state");
-    RegionTransitionData data = new RegionTransitionData(
-        EventType.M2ZK_REGION_OFFLINE, region.getRegionName(), serverName);
+    RegionTransitionData data = new RegionTransitionData(event,
+      region.getRegionName(), serverName);
     synchronized(zkw.getNodes()) {
       String node = getNodeName(zkw, region.getEncodedName());
       zkw.getNodes().add(node);
@@ -457,10 +461,17 @@ public class ZKAssign {
   public static int transitionNodeOpening(ZooKeeperWatcher zkw,
       HRegionInfo region, String serverName)
   throws KeeperException {
-    return transitionNode(zkw, region, serverName,
-        EventType.M2ZK_REGION_OFFLINE,
-        EventType.RS2ZK_REGION_OPENING, -1);
+    return transitionNodeOpening(zkw, region, serverName,
+      EventType.M2ZK_REGION_OFFLINE);
   }
+
+  public static int transitionNodeOpening(ZooKeeperWatcher zkw,
+      HRegionInfo region, String serverName, final EventType beginState)
+  throws KeeperException {
+    return transitionNode(zkw, region, serverName, beginState,
+      EventType.RS2ZK_REGION_OPENING, -1);
+  }
+
   /**
    * Retransitions an existing unassigned node for the specified region which is
    * currently in the OPENING state to be in the OPENING state.

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java Mon Aug 23 23:58:20 2010
@@ -784,11 +784,10 @@ public class HBaseTestingUtility {
    * Returns a HBaseAdmin instance.
    *
    * @return The HBaseAdmin instance.
-   * @throws MasterNotRunningException
-   * @throws ZooKeeperConnectionException
+   * @throws IOException 
    */
   public HBaseAdmin getHBaseAdmin()
-  throws MasterNotRunningException, ZooKeeperConnectionException {
+  throws IOException {
     if (hbaseAdmin == null) {
       hbaseAdmin = new HBaseAdmin(getConfiguration());
     }
@@ -813,7 +812,7 @@ public class HBaseTestingUtility {
    */
   public void closeRegion(byte[] regionName) throws IOException {
     HBaseAdmin admin = getHBaseAdmin();
-    admin.closeRegion(regionName, (Object[]) null);
+    admin.closeRegion(regionName, null);
   }
 
   /**

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestAdmin.java Mon Aug 23 23:58:20 2010
@@ -26,7 +26,10 @@ import static org.junit.Assert.assertTru
 
 import java.io.IOException;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
+import java.util.NavigableSet;
+import java.util.TreeSet;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
 
@@ -38,6 +41,7 @@ import org.apache.hadoop.hbase.HConstant
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HTableDescriptor;
+import org.apache.hadoop.hbase.MiniHBaseCluster;
 import org.apache.hadoop.hbase.TableExistsException;
 import org.apache.hadoop.hbase.TableNotDisabledException;
 import org.apache.hadoop.hbase.TableNotFoundException;
@@ -46,6 +50,7 @@ import org.apache.hadoop.hbase.executor.
 import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.master.MasterServices;
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.JVMClusterUtil.RegionServerThread;
 import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -80,6 +85,31 @@ public class TestAdmin {
     this.admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
   }
 
+  @Test public void testSplitCompactFlushClose() throws IOException {
+    final byte [] tableName = Bytes.toBytes("testSplitCompactFlushClose");
+    TEST_UTIL.createTable(tableName, HConstants.CATALOG_FAMILY);
+    HTable t = new HTable(TEST_UTIL.getConfiguration(), tableName);
+    TEST_UTIL.loadTable(t, HConstants.CATALOG_FAMILY);
+    NavigableSet<HRegionInfo> hris = getClusterRegions();
+    assertFalse(hris.isEmpty());
+    this.admin.split(tableName);
+    NavigableSet<HRegionInfo> splitHris = getClusterRegions();
+    assertFalse(splitHris.isEmpty());
+    int originalCount = hris.size();
+    int postSplitCount = splitHris.size();
+    assertTrue(postSplitCount > originalCount);
+  }
+
+  private NavigableSet<HRegionInfo> getClusterRegions() {
+    MiniHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+    List<RegionServerThread> rss = cluster.getRegionServerThreads();
+    NavigableSet<HRegionInfo> hris = new TreeSet<HRegionInfo>();
+    for (RegionServerThread rst: rss) {
+      hris.addAll(rst.getRegionServer().getOnlineRegions());
+    }
+    return hris;
+  }
+
   @Test
   public void testCreateTable() throws IOException {
     HTableDescriptor [] tables = admin.listTables();
@@ -94,7 +124,7 @@ public class TestAdmin {
    * Verify schema modification takes.
    * @throws IOException
    */
-  @Test public void changeTableSchema() throws IOException {
+  @Test public void testChangeTableSchema() throws IOException {
     final byte [] tableName = Bytes.toBytes("changeTableSchema");
     HTableDescriptor [] tables = admin.listTables();
     int numTables = tables.length;
@@ -242,7 +272,7 @@ public class TestAdmin {
   }
 
   @Test
-  public void testCreateTableWithRegions() throws IOException {
+  public void testCreateTableWithRegions() throws IOException, InterruptedException {
 
     byte[] tableName = Bytes.toBytes("testCreateTableWithRegions");
 

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java?rev=988358&r1=988357&r2=988358&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java Mon Aug 23 23:58:20 2010
@@ -25,9 +25,9 @@ import static org.junit.Assert.assertSam
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.io.File;
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -41,7 +41,6 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
@@ -51,6 +50,7 @@ import org.apache.hadoop.hbase.HTableDes
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.filter.BinaryComparator;
 import org.apache.hadoop.hbase.filter.CompareFilter;
+import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.FilterList;
 import org.apache.hadoop.hbase.filter.PrefixFilter;
@@ -59,7 +59,6 @@ import org.apache.hadoop.hbase.filter.Re
 import org.apache.hadoop.hbase.filter.RowFilter;
 import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
 import org.apache.hadoop.hbase.filter.WhileMatchFilter;
-import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -262,9 +261,10 @@ public class TestFromClientSide {
    * logs to ensure that we're not scanning more regions that we're supposed to.
    * Related to the TestFilterAcrossRegions over in the o.a.h.h.filter package.
    * @throws IOException
+   * @throws InterruptedException 
    */
   @Test
-  public void testFilterAcrossMutlipleRegions() throws IOException {
+  public void testFilterAcrossMutlipleRegions() throws IOException, InterruptedException {
     byte [] name = Bytes.toBytes("testFilterAcrossMutlipleRegions");
     HTable t = TEST_UTIL.createTable(name, FAMILY);
     int rowCount = TEST_UTIL.loadTable(t, FAMILY);
@@ -314,32 +314,6 @@ public class TestFromClientSide {
       CompareFilter.CompareOp.GREATER_OR_EQUAL));
     assertEquals(rowCount - endKeyCount, countGreater);
   }
-  
-  /*
-   * Load table with rows from 'aaa' to 'zzz'.
-   * @param t
-   * @return Count of rows loaded.
-   * @throws IOException
-   */
-  private int loadTable(final HTable t) throws IOException {
-    // Add data to table.
-    byte[] k = new byte[3];
-    int rowCount = 0;
-    for (byte b1 = 'a'; b1 < 'z'; b1++) {
-      for (byte b2 = 'a'; b2 < 'z'; b2++) {
-        for (byte b3 = 'a'; b3 < 'z'; b3++) {
-          k[0] = b1;
-          k[1] = b2;
-          k[2] = b3;
-          Put put = new Put(k);
-          put.add(FAMILY, new byte[0], k);
-          t.put(put);
-          rowCount++;
-        }
-      }
-    }
-    return rowCount;
-  }
 
   /*
    * @param key
@@ -399,7 +373,7 @@ public class TestFromClientSide {
    * @throws IOException
    */
   private Map<HRegionInfo, HServerAddress> splitTable(final HTable t)
-  throws IOException {
+  throws IOException, InterruptedException {
     // Split this table in two.
     HBaseAdmin admin = new HBaseAdmin(TEST_UTIL.getConfiguration());
     admin.split(t.getTableName());
@@ -3376,7 +3350,7 @@ public class TestFromClientSide {
   }
 
   @Test
-  public void testListTables() throws IOException {
+  public void testListTables() throws IOException, InterruptedException {
     byte [] t1 = Bytes.toBytes("testListTables1");
     byte [] t2 = Bytes.toBytes("testListTables2");
     byte [] t3 = Bytes.toBytes("testListTables3");
@@ -3459,7 +3433,7 @@ public class TestFromClientSide {
     for (HColumnDescriptor c : desc.getFamilies())
       c.setValue(attrName, attrValue);
     // update metadata for all regions of this table
-    admin.modifyTable(tableAname, HConstants.Modify.TABLE_SET_HTD, desc);
+    admin.modifyTable(tableAname, desc);
     // enable the table
     admin.enableTable(tableAname);