hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r988820 - in /hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase: catalog/CatalogTracker.java master/AssignmentManager.java master/handler/ServerShutdownHandler.java zookeeper/RootRegionTracker.java
Date Wed, 25 Aug 2010 06:09:41 GMT
Author: stack
Date: Wed Aug 25 06:09:40 2010
New Revision: 988820

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

More shutdown server handler fixes.  Seems to work now; 
least TestZooKeeper passes now.

M src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
  javadoc explaining who puts up the root location.
M src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
  Reassign regions in transition.
M src/main/java/org/apache/hadoop/hbase/master/handler/ServerShutdownHandler.java
  Reordered and made more complete the process of server shutdown.
  Let catalogtracker take care of processing of root and meta if
  they were on this server.  Same for assignmentmanager and RIT
M src/main/java/org/apache/hadoop/hbase/catalog/CatalogTracker.java
  Added processServerShutdown method that manages case this server
  was carrying root or meta.

Modified:
    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/master/AssignmentManager.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/zookeeper/RootRegionTracker.java

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=988820&r1=988819&r2=988820&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
Wed Aug 25 06:09:40 2010
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException;
 import org.apache.hadoop.hbase.NotServingRegionException;
 import org.apache.hadoop.hbase.client.RetriesExhaustedException;
@@ -36,6 +37,7 @@ import org.apache.hadoop.hbase.ipc.HRegi
 import org.apache.hadoop.hbase.zookeeper.MetaNodeTracker;
 import org.apache.hadoop.hbase.zookeeper.RootRegionTracker;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.zookeeper.KeeperException;
 
 /**
  * Tracks the availability of the catalog tables <code>-ROOT-</code> and
@@ -356,4 +358,29 @@ public class CatalogTracker {
       return false;
     }
   }
+
+  /**
+   * Check if <code>hsi</code> was carrying <code>-ROOT-</code> or
+   * <code>.META.</code> and if so, clear out old locations.
+   * @param hsi Server that has crashed/shutdown.
+   * @throws InterruptedException
+   * @throws KeeperException
+   */
+  public void processServerShutdown(final HServerInfo hsi)
+  throws InterruptedException, KeeperException {
+    HServerAddress rootHsa = getRootLocation();
+    if (rootHsa == null) {
+      LOG.info("-ROOT- is not assigned; continuing");
+    } else if (hsi.getServerAddress().equals(rootHsa)) {
+      LOG.info(hsi.getServerName() + " carrying -ROOT-; deleting " +
+        "-ROOT- location from meta");
+      RootLocationEditor.deleteRootLocation(this.zookeeper);
+    }
+    HServerAddress metaHsa = getMetaLocation();
+    if (metaHsa == null) {
+      LOG.info(".META. is not assigned; continuing");
+    } else if (hsi.getServerAddress().equals(metaHsa)) {
+      resetMetaLocation();
+    }
+  }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=988820&r1=988819&r2=988820&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Wed Aug 25 06:09:40 2010
@@ -905,6 +905,10 @@ public class AssignmentManager extends Z
     }
   }
 
+  /**
+   * Process shutdown server removing any assignments.
+   * @param hsi Server that went down.
+   */
   public void processServerShutdown(final HServerInfo hsi) {
     synchronized (regionsInTransition) {
       // Iterate all regions in transition checking if were on this server
@@ -913,16 +917,14 @@ public class AssignmentManager extends Z
         if (!e.getKey().equals(serverName)) continue;
         RegionState regionState = e.getValue();
         switch(regionState.getState()) {
-          case OFFLINE:
-          case CLOSED:
           case PENDING_OPEN:
           case OPENING:
-            // TODO: Do I need to replay logs for PENDING_OPEN and OPENING?
-            // Maybe the server took on edits?
+          case OFFLINE:
+          case CLOSED:
           case PENDING_CLOSE:
           case CLOSING:
             LOG.info("Region " + regionState.getRegion().getRegionNameAsString() +
-              " was in state=" + regionState.getStamp() + " on shutdown server=" +
+              " was in state=" + regionState.getState() + " on shutdown server=" +
               serverName + ", reassigning");
             assign(regionState.getRegion());
             break;

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=988820&r1=988819&r2=988820&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
Wed Aug 25 06:09:40 2010
@@ -25,13 +25,13 @@ import java.util.NavigableSet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.HRegionInfo;
-import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.Server;
 import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.executor.EventHandler;
 import org.apache.hadoop.hbase.master.DeadServer;
 import org.apache.hadoop.hbase.master.MasterServices;
+import org.apache.zookeeper.KeeperException;
 
 
 public class ServerShutdownHandler extends EventHandler {
@@ -54,36 +54,33 @@ public class ServerShutdownHandler exten
 
   @Override
   public void process() throws IOException {
-    checkRootHost();
     try {
-      this.server.getCatalogTracker().waitForRoot();
+      this.server.getCatalogTracker().processServerShutdown(this.hsi);
     } catch (InterruptedException e) {
-      // Reinterrupt
-      Thread.currentThread().interrupt();
-      throw new IOException("Interrupted", e);
-    }
-    checkMetaHost();
-    try {
-      this.server.getCatalogTracker().waitForMeta();
-    } catch (InterruptedException e) {
-      // Reinterrupt
       Thread.currentThread().interrupt();
       throw new IOException("Interrupted", e);
+    } catch (KeeperException e) {
+      this.server.abort("In server shutdown processing", e);
+      throw new IOException("Aborting", e);
     }
     final String serverName = this.hsi.getServerName();
-    // First reassign regions in transition.
-    LOG.info("Cleaning regions-in-transition of references to " + serverName);
-    this.services.getAssignmentManager().processServerShutdown(this.hsi);
+
     LOG.info("Splitting logs for " + serverName);
     this.services.getMasterFileSystem().splitLog(serverName);
-    
+
+    // Clean out anything in regions in transition.  Being conservative and
+    // doing after log splitting.  Could do some states before -- OPENING?
+    // OFFLINE? -- and then others after like CLOSING that depend on log
+    // splitting.
+    this.services.getAssignmentManager().processServerShutdown(this.hsi);
+
     NavigableSet<HRegionInfo> hris =
       MetaReader.getServerRegions(this.server.getCatalogTracker(), this.hsi);
     LOG.info("Reassigning the " + hris.size() + " region(s) that " + serverName +
       " was carrying.");
 
     // We should encounter -ROOT- and .META. first in the Set given how its
-    // as sorted set.
+    // a sorted set.
     for (HRegionInfo hri: hris) {
       // If table is not disabled but the region is offlined,
       boolean disabled = this.services.getAssignmentManager().
@@ -98,29 +95,4 @@ public class ServerShutdownHandler exten
     this.deadServers.remove(serverName);
     LOG.info("Finished processing of shutdown of " + serverName);
   }
-
-  void checkRootHost() throws IOException {
-    HServerAddress rootHsa;
-    try {
-      rootHsa = this.server.getCatalogTracker().getRootLocation();
-    } catch (InterruptedException e) {
-      // Reinterrupt
-      Thread.currentThread().interrupt();
-      throw new IOException("Interrupted", e);
-    }
-    if (this.hsi.getServerAddress().equals(rootHsa)) {
-      LOG.warn("WAS CARRYING ROOT -- DO I HAVE TO DO ANYTHING?  CAN I HURRY NOTIFICATION
THAT ROOT IS GONE?");
-    }
-    return;
-  }
-
-  void checkMetaHost() {
-    HServerAddress metaHsa;
-    // TODO: Presumes one meta region only.
-    metaHsa = this.server.getCatalogTracker().getMetaLocation();
-    if (this.hsi.getServerAddress().equals(metaHsa)) {
-      LOG.warn("WAS CARRYING META -- DO I HAVE TO DO ANYTHING? CAN I HURRY NOTIFICATION THAT
META IS GONE");
-    }
-    return;
-  }
 }
\ No newline at end of file

Modified: hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java?rev=988820&r1=988819&r2=988820&view=diff
==============================================================================
--- hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
(original)
+++ hbase/branches/0.90_master_rewrite/src/main/java/org/apache/hadoop/hbase/zookeeper/RootRegionTracker.java
Wed Aug 25 06:09:40 2010
@@ -21,10 +21,14 @@ package org.apache.hadoop.hbase.zookeepe
 
 import org.apache.hadoop.hbase.Abortable;
 import org.apache.hadoop.hbase.HServerAddress;
+import org.apache.hadoop.hbase.catalog.RootLocationEditor;
+import org.apache.hadoop.hbase.regionserver.RegionServerServices;
 import org.apache.hadoop.hbase.util.Bytes;
 
 /**
  * Tracks the root region server location node in zookeeper.
+ * Root region location is set by {@link RootLocationEditor} usually called
+ * out of {@link RegionServerServices#postOpenDeployTasks(org.apache.hadoop.hbase.regionserver.HRegion,
org.apache.hadoop.hbase.catalog.CatalogTracker)}
  */
 public class RootRegionTracker extends ZooKeeperNodeTracker {
   /**



Mime
View raw message