hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r988392 - in /hbase/branches/0.90_master_rewrite: ./ src/main/java/org/apache/hadoop/hbase/ src/main/java/org/apache/hadoop/hbase/avro/ src/main/java/org/apache/hadoop/hbase/catalog/ src/main/java/org/apache/hadoop/hbase/executor/ src/main/...
Date Tue, 24 Aug 2010 05:31:24 GMT
Author: stack
Date: Tue Aug 24 05:31:23 2010
New Revision: 988392

URL: http://svn.apache.org/viewvc?rev=988392&view=rev
Log:
Stripped more from HMsg.  Removed Worker from RegionServer and ToDoEntry
and ToDoQueue.  Basic split working.  RegionServer opens daughters on itself now.

M BRANCH_TODO.txt
  Update on splits.
M src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
  Server interface had getCatalogTracker added.
M src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java
M src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java
M src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java
  Master construtor now throws IOE.
M src/test/java/org/apache/hadoop/hbase/TestHMsg.java
  HMsg is almost gone.  Had to remove stripped HMsg instances.
M src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
  Remove Worker from HRS.
M src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
  Formatting.
D src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java
  I went the wrong path a while; no need to keep up in zk split opening of
  daughters.
M src/main/java/org/apache/hadoop/hbase/regionserver/CompactSplitThread.java
  Add opening of new daughters.  Make edits of meta go via new
  MetaEditor class.
M src/main/java/org/apache/hadoop/hbase/Server.java
  Added getCatalogTracker.  Used by RS and M
M src/main/java/org/apache/hadoop/hbase/master/MasterServices.java
  Removed getCatalogTracker.
M src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
  Log that we need to update master inmemory picture on split.
  Not done yet.
M src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/TableDeleteFamilyHandler.java
M src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
  Get CT from Server rather than MasterServices.
M src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
  Added TODO.
M src/main/java/org/apache/hadoop/hbase/executor/EventHandler.java
M src/main/java/org/apache/hadoop/hbase/executor/ExecutorService.java
  Moved unused event types (weren't a good idea).
M src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
  Added method to update offline parent.

Removed:
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenDaughterRegionHandler.java
Modified:
    hbase/branches/0.90_master_rewrite/BRANCH_TODO.txt
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/Server.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.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/master/MasterServices.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/DeleteTableHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.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/master/handler/TableEventHandler.java
    hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.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/RegionServerServices.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/thrift/ThriftServer.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHMsg.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java
    hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java

Modified: hbase/branches/0.90_master_rewrite/BRANCH_TODO.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/BRANCH_TODO.txt?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/BRANCH_TODO.txt (original)
+++ hbase/branches/0.90_master_rewrite/BRANCH_TODO.txt Tue Aug 24 05:31:23 2010
@@ -6,6 +6,12 @@ remaining tasks before merge
 ---
 
 * finish baseline implementation of new splits
+-- Basic split works now.  RS opens daughters on itself.
+I made the mistake of keeping up state
+in zk at first but thats not necessary; at moment if split fails
+we kill the regionserver rather than have a hole in our table.
+TODO: Come back and review after merge to make sure this jibes
+w/ new split transaction code.  St.Ack 20100823.
 
 * integrate load balancer
 - Looksee if we are still deleting location from meta; not needed any
@@ -27,6 +33,7 @@ tasks to complete post merge
 
 * bulletproof splits.  need to be recoverable from every point including
   partial META edits over on RS.
+
   
 * review timeout semantics for client calls.  servers should generally wait
   forever on root/meta but client class need to eventually timeout.
@@ -60,6 +67,8 @@ harder stuff
 
   -- We need means of fixup if only one edit goes in.. the offlining of parent.
   St.Ack 20100817
+  -- This should be in place; rs opens daughters on itself now.
+  St.Ack 20100823.
 
 * figure what to do with client table admin ops (flush, split, compact)
   (direct to RS rpc calls are in place, need to update client)

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/Server.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/Server.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/Server.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/Server.java Tue Aug 24 05:31:23 2010
@@ -20,6 +20,7 @@
 package org.apache.hadoop.hbase;
 
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
 
 /**
@@ -38,6 +39,11 @@ public interface Server extends Abortabl
   public ZooKeeperWatcher getZooKeeper();
 
   /**
+   * @return Master's instance of {@link CatalogTracker}
+   */
+  public CatalogTracker getCatalogTracker();
+
+  /**
    * Gets the unique server name for this server.
    * If a RegionServer, it returns a concatenation of hostname, port and
    * startcode formatted as <code>&lt;hostname> ',' &lt;port> ',' &lt;startcode></code>.

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/avro/AvroServer.java Tue Aug 24 05:31:23 2010
@@ -35,7 +35,6 @@ import org.apache.hadoop.hbase.HBaseConf
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.MasterNotRunningException;
 import org.apache.hadoop.hbase.TableExistsException;
-import org.apache.hadoop.hbase.ZooKeeperConnectionException;
 import org.apache.hadoop.hbase.avro.generated.AClusterStatus;
 import org.apache.hadoop.hbase.avro.generated.ADelete;
 import org.apache.hadoop.hbase.avro.generated.AFamilyDescriptor;
@@ -52,7 +51,6 @@ import org.apache.hadoop.hbase.avro.gene
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTableInterface;
 import org.apache.hadoop.hbase.client.HTablePool;
-import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -124,11 +122,9 @@ public class AvroServer {
     // TODO(hammer): figure out appropriate setting of maxSize for htablePool
     /**
      * Constructs an HBaseImpl object.
-     * 
-     * @throws MasterNotRunningException
-     * @throws ZooKeeperConnectionException
+     * @throws IOException 
      */
-    HBaseImpl() throws MasterNotRunningException, ZooKeeperConnectionException {
+    HBaseImpl() throws IOException {
       conf = HBaseConfiguration.create();
       admin = new HBaseAdmin(conf);
       htablePool = new HTablePool(conf, 10);
@@ -366,8 +362,7 @@ public class AvroServer {
     // NB: Asynchronous operation
     public Void modifyFamily(ByteBuffer table, ByteBuffer familyName, AFamilyDescriptor familyDescriptor) throws AIOError {
       try {
-	admin.modifyColumn(Bytes.toBytes(table), Bytes.toBytes(familyName),
-                           AvroUtil.afdToHCD(familyDescriptor));
+	admin.modifyColumn(Bytes.toBytes(table), AvroUtil.afdToHCD(familyDescriptor));
 	return null;
       } catch (IOException e) {
 	AIOError ioe = new AIOError();
@@ -496,7 +491,6 @@ public class AvroServer {
 	  aie.message = new Utf8("scanner ID is invalid: " + scannerId);
           throw aie;
         }
-        Result[] results = null;
         return AvroUtil.resultsToAResults(scanner.next(numberOfRows));
       } catch (IOException e) {
     	AIOError ioe = new AIOError();
@@ -556,7 +550,7 @@ public class AvroServer {
     Log LOG = LogFactory.getLog("AvroServer");
     LOG.info("starting HBase Avro server on port " + Integer.toString(port));
     SpecificResponder r = new SpecificResponder(HBase.class, new HBaseImpl());
-    HttpServer server = new HttpServer(r, 9090);
+    new HttpServer(r, 9090);
     Thread.sleep(1000000);
   }
 

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/catalog/MetaEditor.java Tue Aug 24 05:31:23 2010
@@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerInfo;
+import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.ipc.HRegionInterface;
@@ -58,6 +59,34 @@ public class MetaEditor {
   }
 
   /**
+   * Offline parent in meta.
+   * Used when splitting.
+   * @param catalogTracker
+   * @param parent
+   * @param a Split daughter region A
+   * @param b Split daughter region B
+   * @throws NotAllMetaRegionsOnlineException
+   * @throws IOException
+   */
+  public static void offlineParentInMeta(CatalogTracker catalogTracker,
+      HRegionInfo parent, final HRegionInfo a, final HRegionInfo b)
+  throws NotAllMetaRegionsOnlineException, IOException {
+    Put put = new Put(parent.getRegionName());
+    put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
+      Writables.getBytes(parent));
+    put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
+        HConstants.EMPTY_BYTE_ARRAY);
+    put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
+        HConstants.EMPTY_BYTE_ARRAY);
+    put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
+      Writables.getBytes(a));
+    put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
+      Writables.getBytes(b));
+    catalogTracker.waitForMetaServerConnectionDefault().put(CatalogTracker.META_REGION, put);
+    LOG.info("Offlined parent region " + parent + " in META");
+  }
+
+  /**
    * Updates the location of the specified META region in ROOT to be the
    * specified server hostname and startcode.
    * <p>

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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -104,9 +104,6 @@ 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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -124,7 +124,6 @@ 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/master/MasterServices.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/MasterServices.java Tue Aug 24 05:31:23 2010
@@ -21,7 +21,8 @@ package org.apache.hadoop.hbase.master;
 
 import java.io.IOException;
 
-import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.TableNotDisabledException;
+import org.apache.hadoop.hbase.TableNotFoundException;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 
 /**
@@ -29,11 +30,6 @@ import org.apache.hadoop.hbase.executor.
  */
 public interface MasterServices {
   /**
-   * @return Master's instance of {@link CatalogTracker}
-   */
-  public CatalogTracker getCatalogTracker();
-
-  /**
    * @return Master's instance of the {@link AssignmentManager}
    */
   public AssignmentManager getAssignmentManager();

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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -301,9 +301,10 @@ public class ServerManager {
     for (HMsg msg: msgs) {
       LOG.info("Received " + msg);
       switch (msg.getType()) {
-        REGION_SPLIT:
-          // Nothing to do?
-          break;
+      case REGION_SPLIT:
+        // Nothing to do?
+        LOG.warn("TODO: update inmemory region state w/ split info " + msg);
+        break;
 
         default:
           LOG.error("Unhandled msg type " + msg);

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/DeleteTableHandler.java Tue Aug 24 05:31:23 2010
@@ -43,7 +43,7 @@ public class DeleteTableHandler extends 
     for(HRegionInfo region : regions) {
       LOG.debug("Deleting region " + region + " from META and FS");
       // Remove region from META
-      MetaEditor.deleteRegion(this.masterServices.getCatalogTracker(), region);
+      MetaEditor.deleteRegion(this.server.getCatalogTracker(), region);
       // Delete region from FS
       this.masterServices.getMasterFileSystem().deleteRegion(region);
     }

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ModifyTableHandler.java Tue Aug 24 05:31:23 2010
@@ -44,7 +44,7 @@ public class ModifyTableHandler extends 
     for (HRegionInfo hri : hris) {
       // Update region info in META
       hri.setTableDesc(this.htd);
-      MetaEditor.updateRegionInfo(this.masterServices.getCatalogTracker(), hri);
+      MetaEditor.updateRegionInfo(this.server.getCatalogTracker(), hri);
       // Update region info in FS
       this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
     }

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java Tue Aug 24 05:31:23 2010
@@ -32,5 +32,7 @@ public class ServerShutdownHandler exten
   @Override
   public void process() {
     // TODO: implement this
+    
+    // DO FIXUP IF FIND OFFLINED PARENT BUT DAUGHTERS NOT ON LINE
   }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableAddFamilyHandler.java Tue Aug 24 05:31:23 2010
@@ -58,7 +58,7 @@ public class TableAddFamilyHandler exten
       // Update the HTD
       hri.getTableDesc().addFamily(familyDesc);
       // Update region in META
-      MetaEditor.updateRegionInfo(this.masterServices.getCatalogTracker(), hri);
+      MetaEditor.updateRegionInfo(this.server.getCatalogTracker(), hri);
       // Update region info in FS
       this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
     }

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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -56,7 +56,7 @@ public class TableDeleteFamilyHandler ex
       // Update the HTD
       hri.getTableDesc().removeFamily(familyName);
       // Update region in META
-      MetaEditor.updateRegionInfo(this.masterServices.getCatalogTracker(), hri);
+      MetaEditor.updateRegionInfo(this.server.getCatalogTracker(), hri);
       MasterFileSystem mfs = this.masterServices.getMasterFileSystem();
       // Update region info in FS
       mfs.updateRegionInfo(hri);

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableEventHandler.java Tue Aug 24 05:31:23 2010
@@ -58,7 +58,7 @@ public abstract class TableEventHandler 
       LOG.info("Handling table operation " + eventType + " on table " +
           Bytes.toString(tableName));
       List<HRegionInfo> hris =
-        MetaReader.getTableRegions(this.masterServices.getCatalogTracker(),
+        MetaReader.getTableRegions(this.server.getCatalogTracker(),
           tableName);
       handleTableOperation(hris);
     } catch (IOException e) {

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/handler/TableModifyFamilyHandler.java Tue Aug 24 05:31:23 2010
@@ -57,7 +57,7 @@ public class TableModifyFamilyHandler ex
       // Update the HTD
       hri.getTableDesc().addFamily(familyDesc);
       // Update region in META
-      MetaEditor.updateRegionInfo(this.masterServices.getCatalogTracker(), hri);
+      MetaEditor.updateRegionInfo(this.server.getCatalogTracker(), hri);
       // Update region info in FS
       this.masterServices.getMasterFileSystem().updateRegionInfo(hri);
     }

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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -19,20 +19,6 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.HRegionInfo;
-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;
 import java.util.concurrent.BlockingQueue;
@@ -40,14 +26,20 @@ import java.util.concurrent.LinkedBlocki
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.ReentrantLock;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.RemoteExceptionHandler;
+import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler;
+import org.apache.hadoop.util.StringUtils;
+
 /**
  * Compact region on request and then run split if appropriate
  */
 public class CompactSplitThread extends Thread implements CompactionRequestor {
   static final Log LOG = LogFactory.getLog(CompactSplitThread.class);
-
-  private HTable root = null;
-  private HTable meta = null;
   private final long frequency;
   private final ReentrantLock lock = new ReentrantLock();
 
@@ -152,24 +144,7 @@ public class CompactSplitThread extends 
       // Didn't need to be split
       return;
     }
-
-    // When a region is split, the META table needs to updated if we're
-    // splitting a 'normal' region, and the ROOT table needs to be
-    // updated if we are splitting a META region.
-    HTable t = null;
-    if (region.getRegionInfo().isMetaTable()) {
-      // We need to update the root region
-      if (this.root == null) {
-        this.root = new HTable(conf, HConstants.ROOT_TABLE_NAME);
-      }
-      t = root;
-    } else {
-      // For normal regions we need to update the meta region
-      if (meta == null) {
-        meta = new HTable(conf, HConstants.META_TABLE_NAME);
-      }
-      t = meta;
-    }
+    // TODO: Handle splitting of meta.
 
     // Mark old region as offline and split in META.
     // NOTE: there is no need for retry logic here. HTable does it for us.
@@ -177,50 +152,45 @@ public class CompactSplitThread extends 
     oldRegionInfo.setSplit(true);
     // Inform the HRegionServer that the parent HRegion is no-longer online.
     this.server.removeFromOnlineRegions(oldRegionInfo.getEncodedName());
-
-    Put put = new Put(oldRegionInfo.getRegionName());
-    put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
-      Writables.getBytes(oldRegionInfo));
-    put.add(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER,
-        HConstants.EMPTY_BYTE_ARRAY);
-    put.add(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER,
-        HConstants.EMPTY_BYTE_ARRAY);
-    put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER,
-      Writables.getBytes(newRegions[0].getRegionInfo()));
-    put.add(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER,
-      Writables.getBytes(newRegions[1].getRegionInfo()));
-    t.put(put);
+    MetaEditor.offlineParentInMeta(this.server.getCatalogTracker(),
+      oldRegionInfo, newRegions[0].getRegionInfo(),
+      newRegions[1].getRegionInfo());
 
     // If we crash here, then the daughters will not be added and we'll have
     // and offlined parent but no daughters to take up the slack.  hbase-2244
     // adds fixup to the metascanners.
+    // TODO: Need new fixerupper in new master regime.
+
+    // TODO: if we fail here on out, crash out.  The recovery of a shutdown
+    // server should have fixup and get the daughters up on line.
+
 
     // Add new regions to META
     for (int i = 0; i < newRegions.length; i++) {
-      put = new Put(newRegions[i].getRegionName());
-      put.add(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER,
-          Writables.getBytes(newRegions[i].getRegionInfo()));
-      t.put(put);
+      MetaEditor.addRegionToMeta(this.server.getCatalogTracker(),
+        newRegions[i].getRegionInfo());
     }
 
     // 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();
+      HRegion r = null;
       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;
+        // Instantiate the region.
+        r = HRegion.openHRegion(hri, this.server.getWAL(),
+          this.server.getConfiguration(), this.server.getFlushRequester(), null);
+        this.server.postOpenDeployTasks(r, this.server.getCatalogTracker());
+      } catch (Throwable tt) {
+        this.server.abort("Failed open of " + hri.getRegionNameAsString(), tt);
       }
-      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.
 
-    // Now tell the master about the new regions
+    // Now tell the master about the new regions; it needs to update its
+    // inmemory state of regions.
     server.reportSplit(oldRegionInfo, newRegions[0].getRegionInfo(),
       newRegions[1].getRegionInfo());
 

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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -42,7 +42,6 @@ import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
-import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.TimeUnit;
@@ -75,8 +74,9 @@ import org.apache.hadoop.hbase.UnknownRo
 import org.apache.hadoop.hbase.UnknownScannerException;
 import org.apache.hadoop.hbase.YouAreDeadException;
 import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
-import org.apache.hadoop.hbase.HMsg.Type;
 import org.apache.hadoop.hbase.catalog.CatalogTracker;
+import org.apache.hadoop.hbase.catalog.MetaEditor;
+import org.apache.hadoop.hbase.catalog.RootLocationEditor;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.MultiPut;
@@ -288,9 +288,6 @@ public class HRegionServer implements HR
         HConstants.HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY,
         HConstants.DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE);
 
-    // Task thread to process requests from Master.  TODO: REMOVE
-    this.worker = new Worker();
-
     this.numRegionsToReport = conf.getInt(
         "hbase.regionserver.numregionstoreport", 10);
 
@@ -363,7 +360,6 @@ public class HRegionServer implements HR
   }
 
   private void initializeThreads() throws IOException {
-    this.workerThread = new Thread(worker);
 
     // Cache flushing thread.
     this.cacheFlusher = new MemStoreFlusher(conf, this);
@@ -441,8 +437,6 @@ public class HRegionServer implements HR
               checkFileSystem();
             }
             if (this.stopped) {
-              LOG.info("Stop requested, clearing toDo despite exception");
-              toDo.clear();
               continue;
             }
             LOG.warn("Attempt=" + tries, e);
@@ -460,9 +454,7 @@ public class HRegionServer implements HR
         abort("Unhandled exception", t);
       }
     }
-    this.toDo.clear();
     this.leases.closeAfterLeasesExpire();
-    this.worker.stop();
     this.server.stop();
     if (this.infoServer != null) {
       LOG.info("Stopping infoServer");
@@ -548,7 +540,6 @@ public class HRegionServer implements HR
     updateOutboundMsgs(outboundMessages);
     outboundMessages.clear();
 
-    // Queue up the HMaster's instruction stream for processing
     for (int i = 0; !this.stopped && msgs != null && i < msgs.length; i++) {
       LOG.info(msgs[i].toString());
       // Intercept stop regionserver messages
@@ -557,17 +548,7 @@ public class HRegionServer implements HR
         continue;
       }
       this.connection.unsetRootRegionLocation();
-      switch (msgs[i].getType()) {
-        default:
-          if (fsOk) {
-            try {
-              toDo.put(new ToDoEntry(msgs[i]));
-            } catch (InterruptedException e) {
-              throw new RuntimeException("Putting into msgQueue was "
-                  + "interrupted.", e);
-            }
-          }
-      }
+      LOG.warn("NOT PROCESSING " + msgs[i] + " -- WHY IS MASTER SENDING IT TO US?");
     }
     return outboundMessages;
   }
@@ -1013,7 +994,6 @@ public class HRegionServer implements HR
         handler);
     Threads.setDaemonThreadRunning(this.compactSplitThread, n + ".compactor",
         handler);
-    Threads.setDaemonThreadRunning(this.workerThread, n + ".worker", handler);
     Threads.setDaemonThreadRunning(this.majorCompactionChecker, n
         + ".majorCompactionChecker", handler);
 
@@ -1070,7 +1050,7 @@ public class HRegionServer implements HR
     // Verify that all threads are alive
     if (!(leases.isAlive() && compactSplitThread.isAlive()
         && cacheFlusher.isAlive() && hlogRoller.isAlive()
-        && workerThread.isAlive() && this.majorCompactionChecker.isAlive())) {
+        && this.majorCompactionChecker.isAlive())) {
       stop("One or more threads are no longer alive -- stop");
       return false;
     }
@@ -1083,6 +1063,11 @@ public class HRegionServer implements HR
   }
 
   @Override
+  public CatalogTracker getCatalogTracker() {
+    return this.catalogTracker;
+  }
+
+  @Override
   public void stop(final String msg) {
     this.stopped = true;
     LOG.info("STOPPED: " + msg);
@@ -1092,6 +1077,29 @@ public class HRegionServer implements HR
     }
   }
 
+  @Override
+  public void postOpenDeployTasks(final HRegion r, final CatalogTracker ct)
+  throws KeeperException, IOException {
+    // Do checks to see if we need to compact (references or too many files)
+    if (r.hasReferences() || r.hasTooManyStoreFiles()) {
+      getCompactionRequester().requestCompaction(r,
+        r.hasReferences()? "Region has references on open" :
+          "Region has too many store files");
+    }
+    // Add to online regions
+    addToOnlineRegions(r);
+    // Update ZK, ROOT or META
+    if (r.getRegionInfo().isRootRegion()) {
+      RootLocationEditor.setRootLocation(getZooKeeper(),
+        getServerInfo().getServerAddress());
+    } else if(r.getRegionInfo().isMetaRegion()) {
+      // TODO: doh, this has weird naming between RootEditor/MetaEditor
+      MetaEditor.updateMetaLocation(ct, r.getRegionInfo(), getServerInfo());
+    } else {
+      MetaEditor.updateRegionLocation(ct, r.getRegionInfo(), getServerInfo());
+    }
+  }
+
   /**
    * Cause the server to exit without closing the regions it is serving, the log
    * it is using and without notifying the master. Used unit testing and on
@@ -1139,7 +1147,6 @@ public class HRegionServer implements HR
    */
   protected void join() {
     Threads.shutdown(this.majorCompactionChecker);
-    Threads.shutdown(this.workerThread);
     Threads.shutdown(this.cacheFlusher);
     Threads.shutdown(this.compactSplitThread);
     Threads.shutdown(this.hlogRoller);
@@ -1251,114 +1258,6 @@ public class HRegionServer implements HR
   // HMaster-given operations
   // ////////////////////////////////////////////////////////////////////////////
 
-  /*
-   * Data structure to hold a HMsg and retries count.
-   */
-  private static final class ToDoEntry {
-    protected final AtomicInteger tries = new AtomicInteger(0);
-    protected final HMsg msg;
-
-    ToDoEntry(final HMsg msg) {
-      this.msg = msg;
-    }
-  }
-
-  final BlockingQueue<ToDoEntry> toDo = new LinkedBlockingQueue<ToDoEntry>();
-  private Worker worker;
-  private Thread workerThread;
-
-  /** Thread that performs long running requests from the master */
-  class Worker implements Runnable {
-    void stop() {
-      synchronized (toDo) {
-        toDo.notifyAll();
-      }
-    }
-
-    public void run() {
-      try {
-        while (!stopped) {
-          ToDoEntry e = null;
-          try {
-            e = toDo.poll(threadWakeFrequency, TimeUnit.MILLISECONDS);
-            if (e == null || stopped) {
-              continue;
-            }
-            LOG.info("Worker: " + e.msg);
-            HRegion region = null;
-            HRegionInfo info = e.msg.getRegionInfo();
-            switch (e.msg.getType()) {
-
-              case SPLIT_REGION:
-                region = getRegion(info.getRegionName());
-                region.flushcache();
-                region.shouldSplit(true);
-                // force a compaction; split will be side-effect.
-                compactSplitThread.requestCompaction(region, e.msg.getType()
-                    .name());
-                break;
-
-              case MAJOR_COMPACTION:
-              case COMPACT_REGION:
-                // Compact a region
-                region = getRegion(info.getRegionName());
-                compactSplitThread.requestCompaction(region, e.msg
-                    .isType(Type.MAJOR_COMPACTION), e.msg.getType()
-                    .name());
-                break;
-
-              case FLUSH_REGION:
-                region = getRegion(info.getRegionName());
-                region.flushcache();
-                break;
-
-              case TESTING_BLOCK_REGIONSERVER:
-                while (!stopped) {
-                  Threads.sleep(1000);
-                  LOG.info("Regionserver blocked by "
-                      + HMsg.Type.TESTING_BLOCK_REGIONSERVER + "; " + stopped);
-                }
-                break;
-
-              default:
-                throw new AssertionError(
-                    "Impossible state during msg processing.  Instruction: "
-                        + e.msg.toString());
-            }
-          } catch (InterruptedException ex) {
-            LOG.warn("Processing Worker queue", ex);
-          } catch (Exception ex) {
-            if (ex instanceof IOException) {
-              ex = RemoteExceptionHandler.checkIOException((IOException) ex);
-            }
-            if (e != null && e.tries.get() < numRetries) {
-              LOG.warn(ex);
-              e.tries.incrementAndGet();
-              try {
-                toDo.put(e);
-              } catch (InterruptedException ie) {
-                throw new RuntimeException("Putting into msgQueue was "
-                    + "interrupted.", ex);
-              }
-            } else {
-              LOG.error("unable to process message"
-                  + (e != null ? (": " + e.msg.toString()) : ""), ex);
-              if (!checkFileSystem()) {
-                break;
-              }
-            }
-          }
-        }
-      } catch (Throwable t) {
-        if (!checkOOME(t)) {
-          LOG.fatal("Unhandled exception", t);
-        }
-      } finally {
-        LOG.info("worker thread exiting");
-      }
-    }
-  }
-
   /**
    * Closes all regions.  Called on our way out.
    * Assumes that its not possible for new regions to be added to onlineRegions

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/regionserver/RegionServerServices.java Tue Aug 24 05:31:23 2010
@@ -19,8 +19,12 @@
  */
 package org.apache.hadoop.hbase.regionserver;
 
+import java.io.IOException;
+
 import org.apache.hadoop.hbase.HServerInfo;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
+import org.apache.zookeeper.KeeperException;
 
 /**
  * Services provided by {@link HRegionServer}
@@ -43,4 +47,15 @@ public interface RegionServerServices ex
    * @return The HServerInfo for this RegionServer.
    */
   public HServerInfo getServerInfo();
+
+  /**
+   * Tasks to perform after region open to complete deploy of region on
+   * regionserver
+   * @param r Region to open.
+   * @param ct Instance of {@link CatalogTracker}
+   * @throws KeeperException
+   * @throws IOException
+   */
+  public void postOpenDeployTasks(final HRegion r, final CatalogTracker ct)
+  throws KeeperException, IOException;
 }
\ 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=988392&r1=988391&r2=988392&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 Tue Aug 24 05:31:23 2010
@@ -40,7 +40,7 @@ import org.apache.zookeeper.KeeperExcept
 /**
  * Handles opening of a region on a region server.
  * <p>
- * This is executed after receiving an OPEN RPC from the master.
+ * This is executed after receiving an OPEN RPC from the master or client.
  */
 public class OpenRegionHandler extends EventHandler {
   private static final Log LOG = LogFactory.getLog(OpenRegionHandler.class);
@@ -54,7 +54,8 @@ public class OpenRegionHandler extends E
   public OpenRegionHandler(final Server server,
       final RegionServerServices rsServices,
       CatalogTracker catalogTracker, HRegionInfo regionInfo) {
-    this(server, rsServices, catalogTracker, regionInfo, EventType.M2RS_OPEN_REGION);
+    this(server, rsServices, catalogTracker, regionInfo,
+      EventType.M2RS_OPEN_REGION);
   }
 
   protected OpenRegionHandler(final Server server,
@@ -72,7 +73,7 @@ public class OpenRegionHandler extends E
   }
 
   @Override
-  public void process() {
+  public void process() throws IOException {
     LOG.debug("Processing open of " + regionInfo.getRegionNameAsString());
     final String encodedName = regionInfo.getEncodedName();
 
@@ -89,7 +90,7 @@ public class OpenRegionHandler extends E
       return;
     }
 
-    int openingVersion = transitionZookeeper(encodedName);
+    int openingVersion = transitionZookeeperOfflineToOpening(encodedName);
     if (openingVersion == -1) return;
 
     // Open the region
@@ -136,7 +137,7 @@ public class OpenRegionHandler extends E
           server.getZooKeeper(), regionInfo, server.getServerName(),
           openingVersion)) == -1) {
         LOG.warn("Completed the OPEN of a region but when transitioning from " +
-            " OPENING to OPENED got a version mismatch, someone else clashed " +
+            " OPENING to OPENING got a version mismatch, someone else clashed " +
             "so now unassigning");
         region.close();
         return;
@@ -149,29 +150,10 @@ public class OpenRegionHandler extends E
       return;
     }
 
-    // Do checks to see if we need to compact (references or too many files)
-    if(region.hasReferences() || region.hasTooManyStoreFiles()) {
-      this.rsServices.getCompactionRequester().requestCompaction(region,
-          region.hasReferences() ? "Region has references on open" :
-                                   "Region has too many store files");
-    }
-
-    // Add to online regions
-    this.rsServices.addToOnlineRegions(region);
-
     // Update ZK, ROOT or META
     try {
-      if(regionInfo.isRootRegion()) {
-        RootLocationEditor.setRootLocation(server.getZooKeeper(),
-            this.rsServices.getServerInfo().getServerAddress());
-      } else if(regionInfo.isMetaRegion()) {
-        // TODO: doh, this has weird naming between RootEditor/MetaEditor
-        MetaEditor.updateMetaLocation(catalogTracker, regionInfo,
-            this.rsServices.getServerInfo());
-      } else {
-        MetaEditor.updateRegionLocation(catalogTracker, region.getRegionInfo(),
-          this.rsServices.getServerInfo());
-      }
+      this.rsServices.postOpenDeployTasks(region,
+        this.server.getCatalogTracker());
     } catch (IOException e) {
       // TODO: rollback the open?
       LOG.error("Error updating region location in catalog table", e);
@@ -202,7 +184,7 @@ public class OpenRegionHandler extends E
     LOG.debug("Opened " + region.getRegionNameAsString());
   }
 
-  int transitionZookeeper(final String encodedName) {
+  int transitionZookeeperOfflineToOpening(final String encodedName) {
     // Transition ZK node from OFFLINE to OPENING
     // TODO: should also handle transition from CLOSED?
     int openingVersion = -1;

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java (original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/thrift/ThriftServer.java Tue Aug 24 05:31:23 2010
@@ -46,8 +46,6 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.MasterNotRunningException;
-import org.apache.hadoop.hbase.ZooKeeperConnectionException;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
@@ -184,12 +182,10 @@ public class ThriftServer {
 
     /**
      * Constructs an HBaseHandler object.
-     *
-     * @throws MasterNotRunningException
-     * @throws ZooKeeperConnectionException
+     * @throws IOException 
      */
     HBaseHandler()
-    throws MasterNotRunningException, ZooKeeperConnectionException {
+    throws IOException {
       conf = HBaseConfiguration.create();
       admin = new HBaseAdmin(conf);
       scannerMap = new HashMap<Integer, ResultScanner>();

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHMsg.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHMsg.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHMsg.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/TestHMsg.java Tue Aug 24 05:31:23 2010
@@ -35,7 +35,7 @@ public class TestHMsg extends TestCase {
     final int size = 10;
     for (int i = 0; i < size; i++) {
       byte [] b = Bytes.toBytes(i);
-      hmsg = new HMsg(HMsg.Type.FLUSH_REGION,
+      hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
         new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
       msgs.add(hmsg);
     }
@@ -45,12 +45,12 @@ public class TestHMsg extends TestCase {
     msgs.remove(index);
     assertEquals(size - 1, msgs.size());
     byte [] other = Bytes.toBytes("other");
-    hmsg = new HMsg(HMsg.Type.FLUSH_REGION,
+    hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
       new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), other, other));
     assertEquals(-1, msgs.indexOf(hmsg));
     // Assert that two HMsgs are same if same content.
     byte [] b = Bytes.toBytes(1);
-    hmsg = new HMsg(HMsg.Type.FLUSH_REGION,
+    hmsg = new HMsg(HMsg.Type.STOP_REGIONSERVER,
      new HRegionInfo(new HTableDescriptor(Bytes.toBytes("test")), b, b));
     assertNotSame(-1, msgs.indexOf(hmsg));
   }
@@ -73,8 +73,8 @@ public class TestHMsg extends TestCase {
       new HRegionInfo(new HTableDescriptor(Bytes.toBytes("a")), abytes, abytes);
     HRegionInfo daughterb =
       new HRegionInfo(new HTableDescriptor(Bytes.toBytes("b")), bbytes, bbytes);
-    HMsg splithmsg = new HMsg(HMsg.Type.SPLIT_REGION,
-      parent, daughtera, daughterb, Bytes.toBytes("split"));
+    HMsg splithmsg = new HMsg(HMsg.Type.REGION_SPLIT,
+      parent, daughtera, daughterb, Bytes.toBytes("REGION_SPLIT"));
     bytes = Writables.getBytes(splithmsg);
     hmsg = (HMsg)Writables.getWritable(bytes, new HMsg());
     assertTrue(splithmsg.equals(hmsg));

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/OOMEHMaster.java Tue Aug 24 05:31:23 2010
@@ -54,8 +54,9 @@ public class OOMEHMaster extends HMaster
 
   /**
    * @param args
+   * @throws IOException 
    */
-  public static void main(String[] args) {
+  public static void main(String[] args) throws IOException {
     doMain(args, OOMEHMaster.class);
   }
 }

Modified: hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java?rev=988392&r1=988391&r2=988392&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java (original)
+++ hbase/branches/0.90_master_rewrite/src/test/java/org/apache/hadoop/hbase/master/TestActiveMasterManager.java Tue Aug 24 05:31:23 2010
@@ -31,7 +31,7 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.Server;
-import org.apache.hadoop.hbase.client.ServerConnection;
+import org.apache.hadoop.hbase.catalog.CatalogTracker;
 import org.apache.hadoop.hbase.zookeeper.ZKUtil;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperListener;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
@@ -225,5 +225,10 @@ public class TestActiveMasterManager {
     public void stop(String why) {
       this.stopped = true;
     }
+
+    @Override
+    public CatalogTracker getCatalogTracker() {
+      return null;
+    }
   }
 }



Mime
View raw message