hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1208502 - in /hbase/branches/0.90: ./ src/main/java/org/apache/hadoop/hbase/io/ src/main/java/org/apache/hadoop/hbase/ipc/ src/main/java/org/apache/hadoop/hbase/master/ src/main/java/org/apache/hadoop/hbase/regionserver/ src/main/java/org/...
Date Wed, 30 Nov 2011 16:41:08 GMT
Author: stack
Date: Wed Nov 30 16:41:07 2011
New Revision: 1208502

URL: http://svn.apache.org/viewvc?rev=1208502&view=rev
Log:
Remove hbase-4352 commit temporarily

Modified:
    hbase/branches/0.90/CHANGES.txt
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenMetaHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRootHandler.java
    hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
    hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Wed Nov 30 16:41:07 2011
@@ -129,7 +129,6 @@ Release 0.90.5 - Unreleased
                (Jonathan Hsieh)
    HBASE-4806  Fix logging message in HbaseObjectWritable
                (Jonathan Hsieh via todd)
-   HBASE-4352  Apply version of hbase-4015 to branch
 
 
   NEW FEATURE

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java Wed Nov 30 16:41:07 2011
@@ -79,7 +79,6 @@ import org.apache.hadoop.hbase.filter.Va
 import org.apache.hadoop.hbase.filter.WhileMatchFilter;
 import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
 import org.apache.hadoop.hbase.regionserver.HRegion;
-import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.regionserver.wal.HLogKey;
 import org.apache.hadoop.hbase.util.Bytes;
@@ -214,8 +213,6 @@ public class HbaseObjectWritable impleme
     // serializable
     addToMap(Serializable.class, code++);
 
-    addToMap(RegionOpeningState.class, code++);
-
   }
 
   private Class<?> declaredClass;

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/ipc/HRegionInterface.java Wed Nov 30 16:41:07 2011
@@ -38,7 +38,6 @@ import org.apache.hadoop.hbase.client.Mu
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.regionserver.wal.HLog;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.ipc.RemoteException;
@@ -313,37 +312,10 @@ public interface HRegionInterface extend
 
   /**
    * Opens the specified region.
-   * 
-   * @param region
-   *          region to open
-   * @param versionOfOfflineNode
-   *          the version of znode to compare when RS transitions the znode from
-   *          OFFLINE state.
-   * @return RegionOpeningState 
-   *         OPENED -         if region open request was successful.
-   *         ALREADY_OPENED - if the region was already opened. 
-   *         FAILED_OPENING - if region opening failed.
-   * @throws IOException
-   */
-  public RegionOpeningState openRegion(final HRegionInfo region) throws IOException;
-  
-  /**
-   * Opens the specified region.
-   * 
-   * @param region
-   *          region to open
-   * @param versionOfOfflineNode
-   *          the version of znode to compare when RS transitions the znode from
-   *          OFFLINE state.
-   * @return RegionOpeningState 
-   *         OPENED -         if region open request was successful.
-   *         ALREADY_OPENED - if the region was already opened. 
-   *         FAILED_OPENING - if region opening failed.
+   * @param region region to open
    * @throws IOException
    */
-  public RegionOpeningState openRegion(HRegionInfo region,
-      int versionOfOfflineNode) throws IOException;
-    
+  public void openRegion(final HRegionInfo region) throws IOException;
 
   /**
    * Opens the specified regions.

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Wed Nov 30 16:41:07 2011
@@ -36,7 +36,6 @@ import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.logging.Log;
@@ -63,7 +62,6 @@ import org.apache.hadoop.hbase.master.ha
 import org.apache.hadoop.hbase.master.handler.DisableTableHandler;
 import org.apache.hadoop.hbase.master.handler.OpenedRegionHandler;
 import org.apache.hadoop.hbase.master.handler.ServerShutdownHandler;
-import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.hbase.util.Threads;
@@ -140,9 +138,6 @@ public class AssignmentManager extends Z
     new TreeMap<HRegionInfo,HServerInfo>();
 
   private final ExecutorService executorService;
-  
-  // Thread pool executor service for timeout monitor
-  private java.util.concurrent.ExecutorService threadPoolExecutorService;
 
   /**
    * Constructs a new assignment manager.
@@ -171,7 +166,6 @@ public class AssignmentManager extends Z
     this.zkTable = new ZKTable(this.master.getZooKeeper());
     this.maximumAssignmentAttempts =
       this.master.getConfiguration().getInt("hbase.assignment.maximum.attempts", 10);
-    this.threadPoolExecutorService = Executors.newCachedThreadPool();
   }
 
   /**
@@ -367,19 +361,8 @@ public class AssignmentManager extends Z
 
         // Just insert region into RIT
         // If this never updates the timeout will trigger new assignment
-        if (regionInfo.isMetaRegion() || regionInfo.isRootRegion()) {
-          regionsInTransition.put(encodedRegionName, new RegionState(
-              regionInfo, RegionState.State.OPENING, data.getStamp()));
-          // If ROOT or .META. table is waiting for timeout monitor to assign
-          // it may take lot of time when the assignment.timeout.period is
-          // the default value which may be very long.  We will not be able
-          // to serve any request during this time.
-          // So we will assign the ROOT and .META. region immediately.
-          processOpeningState(regionInfo);
-          break;
-        }
-        regionsInTransition.put(encodedRegionName, new RegionState(regionInfo,
-            RegionState.State.OPENING, data.getStamp()));
+        regionsInTransition.put(encodedRegionName, new RegionState(
+            regionInfo, RegionState.State.OPENING, data.getStamp()));
         break;
 
       case RS_ZK_REGION_OPENED:
@@ -871,40 +854,26 @@ public class AssignmentManager extends Z
   public void assign(HRegionInfo region, boolean setOfflineInZK) {
     assign(region, setOfflineInZK, false);
   }
-  public void assign(HRegionInfo region, boolean setOfflineInZK,
-      boolean forceNewPlan) {
-    assign(region, setOfflineInZK, forceNewPlan, false);
-  }
 
-  /**
-   * @param region
-   * @param setOfflineInZK
-   * @param forceNewPlan
-   * @param hijack - true new assignment is needed, false otherwise
-   */
   public void assign(HRegionInfo region, boolean setOfflineInZK,
-      boolean forceNewPlan, boolean hijack) {
-    // If hijack is true do not call disableRegionIfInRIT as
-    // we have not yet moved the znode to OFFLINE state.
-    if (!hijack && isDisabledorDisablingRegionInRIT(region)) {
-      return;
-    }
-    RegionState state = addToRegionsInTransition(region, hijack);
-    synchronized (state) {
-      assign(region, state, setOfflineInZK, forceNewPlan, hijack);
-    }
-  }
-
-  private boolean isDisabledorDisablingRegionInRIT(HRegionInfo region) {
+      boolean forceNewPlan) {
     String tableName = region.getTableDesc().getNameAsString();
     boolean disabled = this.zkTable.isDisabledTable(tableName);
     if (disabled || this.zkTable.isDisablingTable(tableName)) {
       LOG.info("Table " + tableName + (disabled? " disabled;": " disabling;") +
         " skipping assign of " + region.getRegionNameAsString());
       offlineDisabledRegion(region);
-      return true;
+      return;
+    }
+    if (this.serverManager.isClusterShutdown()) {
+      LOG.info("Cluster shutdown is set; skipping assign of " +
+        region.getRegionNameAsString());
+      return;
+    }
+    RegionState state = addToRegionsInTransition(region);
+    synchronized (state) {
+      assign(state, setOfflineInZK, forceNewPlan);
     }
-    return false;
   }
 
   /**
@@ -1039,13 +1008,11 @@ public class AssignmentManager extends Z
 
   /**
    * @param region
-   * @param hijack
-   * @return The current RegionState
+   * @return
    */
-  private RegionState addToRegionsInTransition(final HRegionInfo region,
-      boolean hijack) {
+  private RegionState addToRegionsInTransition(final HRegionInfo region) {
     synchronized (regionsInTransition) {
-      return forceRegionStateToOffline(region, hijack);
+      return forceRegionStateToOffline(region);
     }
   }
 
@@ -1056,31 +1023,14 @@ public class AssignmentManager extends Z
    * @return Amended RegionState.
    */
   private RegionState forceRegionStateToOffline(final HRegionInfo region) {
-    return forceRegionStateToOffline(region, false);
-  }
-  /**
-   * Sets regions {@link RegionState} to {@link RegionState.State#OFFLINE}.
-   * Caller must hold lock on this.regionsInTransition.
-   * @param region
-   * @param hijack
-   * @return Amended RegionState.
-   */
-  private RegionState forceRegionStateToOffline(final HRegionInfo region,
-      boolean hijack) {
     String encodedName = region.getEncodedName();
     RegionState state = this.regionsInTransition.get(encodedName);
     if (state == null) {
       state = new RegionState(region, RegionState.State.OFFLINE);
       this.regionsInTransition.put(encodedName, state);
     } else {
-      // If we are reassigning the node do not force in-memory state to OFFLINE.
-      // Based on the znode state we will decide if to change
-      // in-memory state to OFFLINE or not. It will
-      // be done before setting the znode to OFFLINE state.
-      if (!hijack) {
-        LOG.debug("Forcing OFFLINE; was=" + state);
-        state.update(RegionState.State.OFFLINE);
-      }
+      LOG.debug("Forcing OFFLINE; was=" + state);
+      state.update(RegionState.State.OFFLINE);
     }
     return state;
   }
@@ -1090,27 +1040,11 @@ public class AssignmentManager extends Z
    * @param state
    * @param setOfflineInZK
    * @param forceNewPlan
-   * @param hijack
    */
-  private void assign(final HRegionInfo region, final RegionState state,
-      final boolean setOfflineInZK, final boolean forceNewPlan, boolean hijack) {
+  private void assign(final RegionState state, final boolean setOfflineInZK,
+      final boolean forceNewPlan) {
     for (int i = 0; i < this.maximumAssignmentAttempts; i++) {
-      int versionOfOfflineNode = -1;
-      if (setOfflineInZK) {
-        // get the version of the znode after setting it to OFFLINE.
-        // versionOfOfflineNode will be -1 if the znode was not set to OFFLINE
-        versionOfOfflineNode = setOfflineInZooKeeper(state, hijack);
-        if (versionOfOfflineNode != -1) {
-          if (isDisabledorDisablingRegionInRIT(region)) {
-            return;
-          }
-        }
-      }
-
-      if (setOfflineInZK && versionOfOfflineNode == -1) {
-        return;
-      }
-            
+      if (setOfflineInZK && !setOfflineInZooKeeper(state)) return;
       if (this.master.isStopped()) {
         LOG.debug("Server stopped; skipping assign of " + state);
         return;
@@ -1128,34 +1062,7 @@ public class AssignmentManager extends Z
         // Transition RegionState to PENDING_OPEN
         state.update(RegionState.State.PENDING_OPEN);
         // Send OPEN RPC. This can fail if the server on other end is is not up.
-        // Pass the version that was obtained while setting the node to OFFLINE.
-        RegionOpeningState regionOpenState = serverManager.sendRegionOpen(plan
-            .getDestination(), state.getRegion(), versionOfOfflineNode);
-        if (regionOpenState == RegionOpeningState.ALREADY_OPENED) {
-          // Remove region from in-memory transition and unassigned node from ZK
-          // While trying to enable the table the regions of the table were
-          // already enabled.
-          String encodedRegionName = state.getRegion()
-              .getEncodedName();
-          try {
-            ZKAssign.deleteOfflineNode(master.getZooKeeper(), encodedRegionName);
-          } catch (KeeperException.NoNodeException e) {
-            if(LOG.isDebugEnabled()){
-              LOG.debug("The unassigned node "+encodedRegionName+" doesnot exist.");
-            }
-          } catch (KeeperException e) {
-            master.abort(
-                "Error deleting OFFLINED node in ZK for transition ZK node ("
-                    + encodedRegionName + ")", e);
-          }
-          synchronized (this.regionsInTransition) {
-            this.regionsInTransition.remove(plan.getRegionInfo()
-                .getEncodedName());
-          }
-          synchronized (this.regions) {
-            this.regions.put(plan.getRegionInfo(), plan.getDestination());
-          }
-        }
+        serverManager.sendRegionOpen(plan.getDestination(), state.getRegion());
         break;
       } catch (Throwable t) {
         LOG.warn("Failed assignment of " +
@@ -1188,53 +1095,29 @@ public class AssignmentManager extends Z
   /**
    * Set region as OFFLINED up in zookeeper
    * @param state
-   * @param hijack
-   *          - true if needs to be hijacked and reassigned, false otherwise.
-   * @return the version of the offline node if setting of the OFFLINE node was
-   *         successful, -1 otherwise.
-   */
-  int setOfflineInZooKeeper(final RegionState state, boolean hijack) {
-    // In case of reassignment the current state in memory need not be
-    // OFFLINE. 
-    if (!hijack && !state.isClosed() && !state.isOffline()) {
+   * @return True if we succeeded, false otherwise (State was incorrect or failed
+   * updating zk).
+   */
+  boolean setOfflineInZooKeeper(final RegionState state) {
+    if (!state.isClosed() && !state.isOffline()) {
         new RuntimeException("Unexpected state trying to OFFLINE; " + state);
       this.master.abort("Unexpected state trying to OFFLINE; " + state,
         new IllegalStateException());
-      return -1;
-    }
-    boolean allowZNodeCreation = false;
-    // Under reassignment if the current state is PENDING_OPEN
-    // or OPENING then refresh the in-memory state to PENDING_OPEN. This is
-    // important because if the region was in
-    // RS_OPENING state for a long time the master will try to force the znode
-    // to OFFLINE state meanwhile the RS could have opened the corresponding
-    // region and the state in znode will be RS_ZK_REGION_OPENED.
-    // For all other cases we can change the in-memory state to OFFLINE.
-    if (hijack
-        && (state.getState().equals(RegionState.State.PENDING_OPEN) || state
-            .getState().equals(RegionState.State.OPENING))) {
-      state.update(RegionState.State.PENDING_OPEN);
-      allowZNodeCreation = false;
-    } else {
-      state.update(RegionState.State.OFFLINE);
-      allowZNodeCreation = true;
+      return false;
     }
-    int versionOfOfflineNode = -1;
+    state.update(RegionState.State.OFFLINE);
     try {
-      // get the version after setting the znode to OFFLINE
-      versionOfOfflineNode = ZKAssign.createOrForceNodeOffline(master
-          .getZooKeeper(), state.getRegion(), this.master.getServerName(),
-          hijack, allowZNodeCreation);
-      if (versionOfOfflineNode == -1) {
+      if(!ZKAssign.createOrForceNodeOffline(master.getZooKeeper(),
+          state.getRegion(), master.getServerName())) {
         LOG.warn("Attempted to create/force node into OFFLINE state before " +
           "completing assignment but failed to do so for " + state);
-        return -1;
+        return false;
       }
     } catch (KeeperException e) {
       master.abort("Unexpected ZK exception creating/setting node OFFLINE", e);
-      return -1;
+      return false;
     }
-    return versionOfOfflineNode;
+    return true;
   }
 
   /**
@@ -1965,134 +1848,135 @@ public class AssignmentManager extends Z
     protected void chore() {
       // If bulkAssign in progress, suspend checks
       if (this.bulkAssign) return;
+      List<HRegionInfo> unassigns = new ArrayList<HRegionInfo>();
+      Map<HRegionInfo, Boolean> assigns =
+        new HashMap<HRegionInfo, Boolean>();
       synchronized (regionsInTransition) {
         // Iterate all regions in transition checking for time outs
         long now = System.currentTimeMillis();
         for (RegionState regionState : regionsInTransition.values()) {
           if (regionState.getStamp() + timeout <= now) {
-            actOnTimeOut(regionState);
+            HRegionInfo regionInfo = regionState.getRegion();
+            LOG.info("Regions in transition timed out:  " + regionState);
+            // Expired!  Do a retry.
+            switch (regionState.getState()) {
+              case CLOSED:
+                LOG.info("Region " + regionInfo.getEncodedName() +
+                  " has been CLOSED for too long, waiting on queued " +
+                  "ClosedRegionHandler to run or server shutdown");
+                // Update our timestamp.
+                synchronized(regionState) {
+                  regionState.update(regionState.getState());
+                }
+                break;
+              case OFFLINE:
+                LOG.info("Region has been OFFLINE for too long, " +
+                  "reassigning " + regionInfo.getRegionNameAsString() +
+                  " to a random server");
+                assigns.put(regionState.getRegion(), Boolean.FALSE);
+                break;
+              case PENDING_OPEN:
+                LOG.info("Region has been PENDING_OPEN for too " +
+                    "long, reassigning region=" +
+                    regionInfo.getRegionNameAsString());
+                assigns.put(regionState.getRegion(), Boolean.TRUE);
+                break;
+              case OPENING:
+                LOG.info("Region has been OPENING for too " +
+                  "long, reassigning region=" +
+                  regionInfo.getRegionNameAsString());
+                // Should have a ZK node in OPENING state
+                try {
+                  String node = ZKAssign.getNodeName(watcher,
+                      regionInfo.getEncodedName());
+                  Stat stat = new Stat();
+                  RegionTransitionData data = ZKAssign.getDataNoWatch(watcher,
+                      node, stat);
+                  if (data == null) {
+                    LOG.warn("Data is null, node " + node + " no longer exists");
+                    break;
+                  }
+                  if (data.getEventType() == EventType.RS_ZK_REGION_OPENED) {
+                    LOG.debug("Region has transitioned to OPENED, allowing " +
+                        "watched event handlers to process");
+                    break;
+                  } else if (data.getEventType() !=
+                      EventType.RS_ZK_REGION_OPENING) {
+                    LOG.warn("While timing out a region in state OPENING, " +
+                        "found ZK node in unexpected state: " +
+                        data.getEventType());
+                    break;
+                  }
+                  // Attempt to transition node into OFFLINE
+                  try {
+                    data = new RegionTransitionData(
+                      EventType.M_ZK_REGION_OFFLINE, regionInfo.getRegionName(),
+                      master.getServerName());
+                    if (ZKUtil.setData(watcher, node, data.getBytes(),
+                        stat.getVersion())) {
+                      // Node is now OFFLINE, let's trigger another assignment
+                      ZKUtil.getDataAndWatch(watcher, node); // re-set the watch
+                      LOG.info("Successfully transitioned region=" +
+                          regionInfo.getRegionNameAsString() + " into OFFLINE" +
+                          " and forcing a new assignment");
+                      assigns.put(regionState.getRegion(), Boolean.TRUE);
+                    }
+                  } catch (KeeperException.NoNodeException nne) {
+                    // Node did not exist, can't time this out
+                  }
+                } catch (KeeperException ke) {
+                  LOG.error("Unexpected ZK exception timing out CLOSING region",
+                      ke);
+                  break;
+                }
+                break;
+              case OPEN:
+                LOG.error("Region has been OPEN for too long, " +
+                "we don't know where region was opened so can't do anything");
+                synchronized(regionState) {
+                  regionState.update(regionState.getState());
+                }
+                break;
+
+              case PENDING_CLOSE:
+                LOG.info("Region has been PENDING_CLOSE for too " +
+                    "long, running forced unassign again on region=" +
+                    regionInfo.getRegionNameAsString());
+                  try {
+                    // If the server got the RPC, it will transition the node
+                    // to CLOSING, so only do something here if no node exists
+                    if (!ZKUtil.watchAndCheckExists(watcher,
+                      ZKAssign.getNodeName(watcher, regionInfo.getEncodedName()))) {
+                      // Queue running of an unassign -- do actual unassign
+                      // outside of the regionsInTransition lock.
+                      unassigns.add(regionInfo);
+                    }
+                  } catch (NoNodeException e) {
+                    LOG.debug("Node no longer existed so not forcing another " +
+                      "unassignment");
+                  } catch (KeeperException e) {
+                    LOG.warn("Unexpected ZK exception timing out a region " +
+                      "close", e);
+                  }
+                  break;
+              case CLOSING:
+                LOG.info("Region has been CLOSING for too " +
+                  "long, this should eventually complete or the server will " +
+                  "expire, doing nothing");
+                break;
+            }
           }
         }
       }
-    }
-
-    private void actOnTimeOut(RegionState regionState) {
-      HRegionInfo regionInfo = regionState.getRegion();
-      LOG.info("Regions in transition timed out:  " + regionState);
-      // Expired!  Do a retry.
-      switch (regionState.getState()) {
-        case CLOSED:
-          LOG.info("Region " + regionInfo.getEncodedName() +
-            " has been CLOSED for too long, waiting on queued " +
-            "ClosedRegionHandler to run or server shutdown");
-          // Update our timestamp.
-          synchronized(regionState) {
-            regionState.update(regionState.getState());
-          }
-          break;
-        case OFFLINE:
-          LOG.info("Region has been OFFLINE for too long, " +
-            "reassigning " + regionInfo.getRegionNameAsString() +
-            " to a random server");
-          invokeAssign(regionInfo);
-          break;
-        case PENDING_OPEN:
-          LOG.info("Region has been PENDING_OPEN for too " +
-              "long, reassigning region=" +
-              regionInfo.getRegionNameAsString());
-          invokeAssign(regionInfo);
-          break;
-        case OPENING:
-          processOpeningState(regionInfo);
-          break;
-        case OPEN:
-          LOG.error("Region has been OPEN for too long, " +
-          "we don't know where region was opened so can't do anything");
-          synchronized(regionState) {
-            regionState.update(regionState.getState());
-          }
-          break;
-
-        case PENDING_CLOSE:
-          LOG.info("Region has been PENDING_CLOSE for too " +
-              "long, running forced unassign again on region=" +
-              regionInfo.getRegionNameAsString());
-            try {
-              // If the server got the RPC, it will transition the node
-              // to CLOSING, so only do something here if no node exists
-              if (!ZKUtil.watchAndCheckExists(watcher,
-                ZKAssign.getNodeName(watcher, regionInfo.getEncodedName()))) {
-                // Queue running of an unassign -- do actual unassign
-                // outside of the regionsInTransition lock.
-                invokeUnassign(regionInfo);
-              }
-            } catch (NoNodeException e) {
-              LOG.debug("Node no longer existed so not forcing another " +
-                "unassignment");
-            } catch (KeeperException e) {
-              LOG.warn("Unexpected ZK exception timing out a region " +
-                "close", e);
-            }
-            break;
-        case CLOSING:
-          LOG.info("Region has been CLOSING for too " +
-            "long, this should eventually complete or the server will " +
-            "expire, doing nothing");
-          break;
-      }
-    }
-  }
-  
-  private void processOpeningState(HRegionInfo regionInfo) {
-    LOG.info("Region has been OPENING for too " + "long, reassigning region=" + 
-      regionInfo.getRegionNameAsString());
-    // Should have a ZK node in OPENING state
-    try {
-      String node = ZKAssign.getNodeName(watcher, regionInfo.getEncodedName());
-      Stat stat = new Stat();
-      RegionTransitionData data = ZKAssign.getDataNoWatch(watcher, node, stat);
-      if (data == null) {
-        LOG.warn("Data is null, node " + node + " no longer exists");
-        return;
-      }
-      if (data.getEventType() == EventType.RS_ZK_REGION_OPENED) {
-        LOG.debug("Region has transitioned to OPENED, allowing " + 
-          "watched event handlers to process");
-        return;
-      } else if (data.getEventType() != EventType.RS_ZK_REGION_OPENING) {
-        LOG.warn("While timing out a region in state OPENING, " +
-          "found ZK node in unexpected state: " + data.getEventType());
-        return;
+      // Finish the work for regions in PENDING_CLOSE state
+      for (HRegionInfo hri: unassigns) {
+        unassign(hri, true);
       }
-      // Attempt to transition node into OFFLINE
-      try {
-        data = new RegionTransitionData(EventType.M_ZK_REGION_OFFLINE,
-            regionInfo.getRegionName(), master.getServerName());
-        if (ZKUtil.setData(watcher, node, data.getBytes(), stat.getVersion())) {
-          // Node is now OFFLINE, let's trigger another assignment
-          ZKUtil.getDataAndWatch(watcher, node); // re-set the watch
-          LOG.info("Successfully transitioned region=" +
-            regionInfo.getRegionNameAsString() + " into OFFLINE" +
-            " and forcing a new assignment");
-          invokeAssign(regionInfo);
-        }
-      } catch (KeeperException.NoNodeException nne) {
-        // Node did not exist, can't time this out
+      for (Map.Entry<HRegionInfo, Boolean> e: assigns.entrySet()){
+        assign(e.getKey(), false, e.getValue());
       }
-    } catch (KeeperException ke) {
-      LOG.error("Unexpected ZK exception timing out CLOSING region", ke);
-      return;
     }
   }
-  
-    
-  private void invokeAssign(HRegionInfo regionInfo) {
-    threadPoolExecutorService.submit(new AssignCallable(this, regionInfo));
-  }
-
-  private void invokeUnassign(HRegionInfo regionInfo) {
-    threadPoolExecutorService.submit(new UnAssignCallable(this, regionInfo));
-  }
 
   /**
    * Process shutdown server removing any assignments.
@@ -2382,12 +2266,4 @@ public class AssignmentManager extends Z
   public boolean isServerOnline(String serverName) {
     return this.serverManager.isServerOnline(serverName);
   }
-  /**
-   * Shutdown the threadpool executor service
-   */
-  public void shutdown() {
-    if (null != threadPoolExecutorService) {
-      this.threadPoolExecutorService.shutdown();
-    }
-  }
 }

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/CatalogJanitor.java Wed Nov 30 16:41:07 2011
@@ -157,7 +157,6 @@ class CatalogJanitor extends Chore {
     }
   }
 
-
   /**
    * Get HRegionInfo from passed Map of row values.
    * @param result Map to do lookup in.

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/HMaster.java Wed Nov 30 16:41:07 2011
@@ -965,7 +965,6 @@ implements HMasterInterface, HMasterRegi
 
   @Override
   public void shutdown() {
-    this.assignmentManager.shutdown();
     this.serverManager.shutdownCluster();
     try {
       this.clusterStatusTracker.setClusterDown();

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java Wed Nov 30 16:41:07 2011
@@ -49,7 +49,6 @@ import org.apache.hadoop.hbase.ipc.HRegi
 import org.apache.hadoop.hbase.master.handler.MetaServerShutdownHandler;
 import org.apache.hadoop.hbase.master.handler.ServerShutdownHandler;
 import org.apache.hadoop.hbase.master.metrics.MasterMetrics;
-import org.apache.hadoop.hbase.regionserver.RegionOpeningState;
 import org.apache.hadoop.hbase.regionserver.Leases.LeaseStillHeldException;
 
 /**
@@ -559,20 +558,16 @@ public class ServerManager {
    * <p>
    * @param server server to open a region
    * @param region region to open
-   * @param versionOfOfflineNode that needs to be present in the offline node
-   * when RS tries to change the state from OFFLINE to other states.
    */
-  public RegionOpeningState sendRegionOpen(final HServerInfo server,
-      HRegionInfo region, int versionOfOfflineNode)
+  public void sendRegionOpen(HServerInfo server, HRegionInfo region)
   throws IOException {
     HRegionInterface hri = getServerConnection(server);
     if (hri == null) {
-      LOG.warn("Attempting to send OPEN RPC to server " + server.toString() +
-        " failed because no RPC connection found to this server");
-      return RegionOpeningState.FAILED_OPENING;
+      LOG.warn("Attempting to send OPEN RPC to server " + server.getServerName()
+          + " failed because no RPC connection found to this server");
+      return;
     }
-    return (versionOfOfflineNode == -1) ? hri.openRegion(region) : hri
-        .openRegion(region, versionOfOfflineNode);
+    hri.openRegion(region);
   }
 
   /**

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Wed Nov 30 16:41:07 2011
@@ -67,7 +67,6 @@ import org.apache.hadoop.hbase.HRegionIn
 import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HServerInfo;
 import org.apache.hadoop.hbase.HServerLoad;
-import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.MasterAddressTracker;
 import org.apache.hadoop.hbase.NotServingRegionException;
@@ -2125,40 +2124,24 @@ public class HRegionServer implements HR
 
   // Region open/close direct RPCs
 
-  @QosPriority(priority=HIGH_QOS)
-  public RegionOpeningState openRegion(HRegionInfo region)
-  throws IOException {
-    return openRegion(region, -1);
-  }
   @Override
   @QosPriority(priority=HIGH_QOS)
-  public RegionOpeningState openRegion(HRegionInfo region, int versionOfOfflineNode)
+  public void openRegion(HRegionInfo region)
   throws IOException {
     if (this.regionsInTransitionInRS.contains(region.getEncodedNameAsBytes())) {
       throw new RegionAlreadyInTransitionException("open", region.getEncodedName());
     }
-    HRegion onlineRegion = this.getFromOnlineRegions(region.getEncodedName());
-    if (null != onlineRegion) {
-      LOG.warn("Attempted open of " + region.getEncodedName()
-          + " but already online on this server");
-      return RegionOpeningState.ALREADY_OPENED;
-    }
     LOG.info("Received request to open region: " +
       region.getRegionNameAsString());
     if (this.stopped) throw new RegionServerStoppedException();
     this.regionsInTransitionInRS.add(region.getEncodedNameAsBytes());
-    // Need to pass the expected version in the constructor.
     if (region.isRootRegion()) {
-      this.service.submit(new OpenRootHandler(this, this, region,
-          versionOfOfflineNode));
-    } else if (region.isMetaRegion()) {
-      this.service.submit(new OpenMetaHandler(this, this, region,
-          versionOfOfflineNode));
+      this.service.submit(new OpenRootHandler(this, this, region));
+    } else if(region.isMetaRegion()) {
+      this.service.submit(new OpenMetaHandler(this, this, region));
     } else {
-      this.service.submit(new OpenRegionHandler(this, this, region,
-          versionOfOfflineNode));
+      this.service.submit(new OpenRegionHandler(this, this, region));
     }
-    return RegionOpeningState.OPENED;
   }
 
   @Override

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenMetaHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenMetaHandler.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenMetaHandler.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenMetaHandler.java Wed Nov 30 16:41:07 2011
@@ -31,12 +31,6 @@ import org.apache.hadoop.hbase.regionser
 public class OpenMetaHandler extends OpenRegionHandler {
   public OpenMetaHandler(final Server server,
       final RegionServerServices rsServices, HRegionInfo regionInfo) {
-    super(server,rsServices,  regionInfo, EventType.M_RS_OPEN_META, -1);
-  }
-  public OpenMetaHandler(final Server server,
-      final RegionServerServices rsServices, HRegionInfo regionInfo,
-      int versionOfOfflineNode) {
-    super(server, rsServices, regionInfo, EventType.M_RS_OPEN_META,
-        versionOfOfflineNode);
+    super(server,rsServices,  regionInfo, EventType.M_RS_OPEN_META);
   }
 }

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRegionHandler.java Wed Nov 30 16:41:07 2011
@@ -49,27 +49,18 @@ public class OpenRegionHandler extends E
   // the total open. We'll fail the open if someone hijacks our znode; we can
   // tell this has happened if version is not as expected.
   private volatile int version = -1;
-  //version of the offline node that was set by the master
-  private volatile int versionOfOfflineNode = -1;
 
   public OpenRegionHandler(final Server server,
       final RegionServerServices rsServices, HRegionInfo regionInfo) {
-    this(server, rsServices, regionInfo, EventType.M_RS_OPEN_REGION, -1);
-  }
-  public OpenRegionHandler(final Server server,
-      final RegionServerServices rsServices, HRegionInfo regionInfo,
-      int versionOfOfflineNode) {
-    this(server, rsServices, regionInfo, EventType.M_RS_OPEN_REGION,
-        versionOfOfflineNode);
+    this(server, rsServices, regionInfo, EventType.M_RS_OPEN_REGION);
   }
 
   protected OpenRegionHandler(final Server server,
       final RegionServerServices rsServices, final HRegionInfo regionInfo,
-      EventType eventType, int versionOfOfflineNode) {
+      EventType eventType) {
     super(server, eventType);
     this.rsServices = rsServices;
     this.regionInfo = regionInfo;
-    this.versionOfOfflineNode = versionOfOfflineNode;
   }
 
   public HRegionInfo getRegionInfo() {
@@ -101,8 +92,7 @@ public class OpenRegionHandler extends E
 
       // If fails, just return.  Someone stole the region from under us.
       // Calling transitionZookeeperOfflineToOpening initalizes this.version.
-      if (!transitionZookeeperOfflineToOpening(encodedName,
-          versionOfOfflineNode)) {
+      if (!transitionZookeeperOfflineToOpening(encodedName)) {
         LOG.warn("Region was hijacked? It no longer exists, encodedName=" +
           encodedName);
         return;
@@ -313,18 +303,15 @@ public class OpenRegionHandler extends E
    * Transition ZK node from OFFLINE to OPENING.
    * @param encodedName Name of the znode file (Region encodedName is the znode
    * name).
-   * @param versionOfOfflineNode - version Of OfflineNode that needs to be compared
-   * before changing the node's state from OFFLINE
    * @return True if successful transition.
    */
-  boolean transitionZookeeperOfflineToOpening(final String encodedName,
-      int versionOfOfflineNode) {
+  boolean transitionZookeeperOfflineToOpening(final String encodedName) {
     // TODO: should also handle transition from CLOSED?
     try {
       // Initialize the znode version.
-      this.version = ZKAssign.transitionNode(server.getZooKeeper(), regionInfo,
-          server.getServerName(), EventType.M_ZK_REGION_OFFLINE,
-          EventType.RS_ZK_REGION_OPENING, versionOfOfflineNode);
+      this.version =
+        ZKAssign.transitionNodeOpening(server.getZooKeeper(),
+          regionInfo, server.getServerName());
     } catch (KeeperException e) {
       LOG.error("Error transition from OFFLINE to OPENING for region=" +
         encodedName, e);

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRootHandler.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRootHandler.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRootHandler.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/regionserver/handler/OpenRootHandler.java Wed Nov 30 16:41:07 2011
@@ -29,15 +29,8 @@ import org.apache.hadoop.hbase.regionser
  * This is executed after receiving an OPEN RPC from the master for root.
  */
 public class OpenRootHandler extends OpenRegionHandler {
-  
   public OpenRootHandler(final Server server,
       final RegionServerServices rsServices, HRegionInfo regionInfo) {
-    super(server, rsServices, regionInfo, EventType.M_RS_OPEN_ROOT, -1);
-  }
-  public OpenRootHandler(final Server server,
-      final RegionServerServices rsServices, HRegionInfo regionInfo,
-      int versionOfOfflineNode) {
-    super(server, rsServices, regionInfo, EventType.M_RS_OPEN_ROOT,
-        versionOfOfflineNode);
+    super(server, rsServices, regionInfo, EventType.M_RS_OPEN_ROOT);
   }
 }

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/zookeeper/ZKAssign.java Wed Nov 30 16:41:07 2011
@@ -211,6 +211,7 @@ public class ZKAssign {
     }
   }
 
+
   /**
    * Creates or force updates an unassigned node to the OFFLINE state for the
    * specified region.
@@ -226,48 +227,11 @@ public class ZKAssign {
    * @param zkw zk reference
    * @param region region to be created as offline
    * @param serverName server event originates from
-   * @return the version of the znode created in OFFLINE state, -1 if
-   *         unsuccessful.
    * @throws KeeperException if unexpected zookeeper exception
    * @throws KeeperException.NodeExistsException if node already exists
    */
-  public static int createOrForceNodeOffline(ZooKeeperWatcher zkw,
-      HRegionInfo region, String serverName) throws KeeperException {
-    return createOrForceNodeOffline(zkw, region, serverName, false, true);
-  }
-
-  /**
-   * Creates or force updates an unassigned node to the OFFLINE state for the
-   * specified region.
-   * <p>
-   * Attempts to create the node but if it exists will force it to transition to
-   * and OFFLINE state.
-   * <p>
-   * Sets a watcher on the unassigned region node if the method is successful.
-   * 
-   * <p>
-   * This method should be used when assigning a region.
-   * 
-   * @param zkw
-   *          zk reference
-   * @param region
-   *          region to be created as offline
-   * @param serverName
-   *          server event originates from
-   * @param hijack
-   *          - true if to be hijacked and reassigned, false otherwise
-   * @param allowCreation
-   *          - true if the node has to be created newly, false otherwise
-   * @throws KeeperException
-   *           if unexpected zookeeper exception
-   * @return the version of the znode created in OFFLINE state, -1 if
-   *         unsuccessful.
-   * @throws KeeperException.NodeExistsException
-   *           if node already exists
-   */
-  public static int createOrForceNodeOffline(ZooKeeperWatcher zkw,
-      HRegionInfo region, String serverName,
-      boolean hijack, boolean allowCreation)
+  public static boolean createOrForceNodeOffline(ZooKeeperWatcher zkw,
+      HRegionInfo region, String serverName)
   throws KeeperException {
     LOG.debug(zkw.prefix("Creating (or updating) unassigned node for " +
       region.getEncodedName() + " with OFFLINE state"));
@@ -275,49 +239,14 @@ public class ZKAssign {
         EventType.M_ZK_REGION_OFFLINE, region.getRegionName(), serverName);
     synchronized(zkw.getNodes()) {
       String node = getNodeName(zkw, region.getEncodedName());
-      Stat stat = new Stat();
       zkw.sync(node);
       zkw.getNodes().add(node);
       int version = ZKUtil.checkExists(zkw, node);
-      if (version == -1) {
-        // While trying to transit a node to OFFLINE that was in previously in 
-        // OPENING state but before it could transit to OFFLINE state if RS had 
-        // opened the region then the Master deletes the assigned region znode. 
-        // In that case the znode will not exist. So we should not
-        // create the znode again which will lead to double assignment.
-        if (hijack && !allowCreation) {
-          return -1;
-        }
-        return ZKUtil.createAndWatch(zkw, node, data.getBytes());
+      if(version == -1) {
+        ZKUtil.createAndWatch(zkw, node, data.getBytes());
       } else {
-        RegionTransitionData curDataInZNode = ZKAssign.getDataNoWatch(zkw, region
-            .getEncodedName(), stat);
-        // Do not move the node to OFFLINE if znode is in any of the following
-        // state.
-        // Because these are already executed states.
-        if (hijack && null != curDataInZNode) {
-          EventType eventType = curDataInZNode.getEventType();
-          if (eventType.equals(EventType.RS_ZK_REGION_CLOSING)
-              || eventType.equals(EventType.RS_ZK_REGION_CLOSED)
-              || eventType.equals(EventType.RS_ZK_REGION_OPENED)) {
-            return -1;
-          }
-        }
-
-        boolean setData = false;
-        try {
-          setData = ZKUtil.setData(zkw, node, data.getBytes(), version);
-          // Setdata throws KeeperException which aborts the Master. So we are
-          // catching it here.
-          // If just before setting the znode to OFFLINE if the RS has made any
-          // change to the
-          // znode state then we need to return -1.
-        } catch (KeeperException kpe) {
-          LOG.info("Version mismatch while setting the node to OFFLINE state.");
-          return -1;
-        }
-        if (!setData) {
-          return -1;
+        if (!ZKUtil.setData(zkw, node, data.getBytes(), version)) {
+          return false;
         } else {
           // We successfully forced to OFFLINE, reset watch and handle if
           // the state changed in between our set and the watch
@@ -325,12 +254,12 @@ public class ZKAssign {
             ZKAssign.getData(zkw, region.getEncodedName());
           if (curData.getEventType() != data.getEventType()) {
             // state changed, need to process
-            return -1;
+            return false;
           }
         }
       }
-      return stat.getVersion() + 1;
     }
+    return true;
   }
 
   /**
@@ -791,18 +720,6 @@ public class ZKAssign {
         "the node existed but was version " + stat.getVersion() +
         " not the expected version " + expectedVersion));
         return -1;
-    } else if (beginState.equals(EventType.M_ZK_REGION_OFFLINE)
-        && endState.equals(EventType.RS_ZK_REGION_OPENING)
-        && expectedVersion == -1 && stat.getVersion() != 0) {
-      // the below check ensures that double assignment doesnot happen.
-      // When the node is created for the first time then the expected version
-      // that is passed will be -1 and the version in znode will be 0.
-      // In all other cases the version in znode will be > 0.
-      LOG.warn(zkw.prefix("Attempt to transition the " + "unassigned node for "
-          + encoded + " from " + beginState + " to " + endState + " failed, "
-          + "the node existed but was version " + stat.getVersion()
-          + " not the expected version " + expectedVersion));
-      return -1;
     }
 
     // Verify it is in expected state

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestCatalogJanitor.java Wed Nov 30 16:41:07 2011
@@ -52,6 +52,7 @@ import org.junit.Test;
 import org.mockito.Mockito;
 
 public class TestCatalogJanitor {
+
   /**
    * Pseudo server for below tests.
    */
@@ -64,7 +65,8 @@ public class TestCatalogJanitor {
       this.c = htu.getConfiguration();
       // Set hbase.rootdir into test dir.
       FileSystem fs = FileSystem.get(this.c);
-      Path rootdir = fs.makeQualified(new Path(this.c.get(HConstants.HBASE_DIR)));
+      Path rootdir =
+        fs.makeQualified(HBaseTestingUtility.getTestDir(HConstants.HBASE_DIR));
       this.c.set(HConstants.HBASE_DIR, rootdir.toString());
       this.ct = Mockito.mock(CatalogTracker.class);
       HRegionInterface hri = Mockito.mock(HRegionInterface.class);
@@ -181,12 +183,12 @@ public class TestCatalogJanitor {
   @Test
   public void testCleanParent() throws IOException {
     HBaseTestingUtility htu = new HBaseTestingUtility();
-    setRootDirAndCleanIt(htu, "testCleanParent");
     Server server = new MockServer(htu);
     MasterServices services = new MockMasterServices(server);
     CatalogJanitor janitor = new CatalogJanitor(server, services);
     // Create regions.
-    HTableDescriptor htd = createHTableDescriptor();
+    HTableDescriptor htd = new HTableDescriptor("table");
+    htd.addFamily(new HColumnDescriptor("family"));
     HRegionInfo parent =
       new HRegionInfo(htd, Bytes.toBytes("aaa"), Bytes.toBytes("eee"));
     HRegionInfo splita =
@@ -195,7 +197,12 @@ public class TestCatalogJanitor {
       new HRegionInfo(htd, Bytes.toBytes("ccc"), Bytes.toBytes("eee"));
     // Test that when both daughter regions are in place, that we do not
     // remove the parent.
-    Result r = createResult(parent, splita, splitb);
+    List<KeyValue> kvs = new ArrayList<KeyValue>();
+    kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
+      HConstants.SPLITA_QUALIFIER, Writables.getBytes(splita)));
+    kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
+      HConstants.SPLITB_QUALIFIER, Writables.getBytes(splitb)));
+    Result r = new Result(kvs);
     // Add a reference under splitA directory so we don't clear out the parent.
     Path rootdir = services.getMasterFileSystem().getRootDir();
     Path tabledir =
@@ -213,159 +220,4 @@ public class TestCatalogJanitor {
     assertTrue(fs.delete(p, true));
     assertTrue(janitor.cleanParent(parent, r));
   }
-
-  /**
-   * Make sure parent gets cleaned up even if daughter is cleaned up before it.
-   * @throws IOException
-   * @throws InterruptedException 
-   */
-  @Test
-  public void testParentCleanedEvenIfDaughterGoneFirst()
-  throws IOException, InterruptedException {
-    HBaseTestingUtility htu = new HBaseTestingUtility();
-    setRootDirAndCleanIt(htu, "testParentCleanedEvenIfDaughterGoneFirst");
-    Server server = new MockServer(htu);
-    MasterServices services = new MockMasterServices(server);
-    CatalogJanitor janitor = new CatalogJanitor(server, services);
-    final HTableDescriptor htd = createHTableDescriptor();
-
-    // Create regions: aaa->eee, aaa->ccc, aaa->bbb, bbb->ccc, etc.
-
-    // Parent
-    HRegionInfo parent = new HRegionInfo(htd.getName(), Bytes.toBytes("aaa"),
-      Bytes.toBytes("eee"));
-    // Sleep a second else the encoded name on these regions comes out
-    // same for all with same start key and made in same second.
-    Thread.sleep(1001);
-
-    // Daughter a
-    HRegionInfo splita = new HRegionInfo(htd.getName(), Bytes.toBytes("aaa"),
-      Bytes.toBytes("ccc"));
-    Thread.sleep(1001);
-    // Make daughters of daughter a; splitaa and splitab.
-    HRegionInfo splitaa = new HRegionInfo(htd.getName(), Bytes.toBytes("aaa"),
-      Bytes.toBytes("bbb"));
-    HRegionInfo splitab = new HRegionInfo(htd.getName(), Bytes.toBytes("bbb"),
-      Bytes.toBytes("ccc"));
-
-    // Daughter b
-    HRegionInfo splitb = new HRegionInfo(htd.getName(), Bytes.toBytes("ccc"),
-      Bytes.toBytes("eee"));
-    Thread.sleep(1001);
-    // Make Daughters of daughterb; splitba and splitbb.
-    HRegionInfo splitba = new HRegionInfo(htd.getName(), Bytes.toBytes("ccc"),
-      Bytes.toBytes("ddd"));
-    HRegionInfo splitbb = new HRegionInfo(htd.getName(), Bytes.toBytes("ddd"),
-      Bytes.toBytes("eee"));
-
-    // First test that our Comparator works right up in CatalogJanitor.
-    // Just fo kicks.
-    SortedMap<HRegionInfo, Result> regions =
-      new TreeMap<HRegionInfo, Result>(new CatalogJanitor.SplitParentFirstComparator());
-    // Now make sure that this regions map sorts as we expect it to.
-    regions.put(parent, createResult(parent, splita, splitb));
-    regions.put(splitb, createResult(splitb, splitba, splitbb));
-    regions.put(splita, createResult(splita, splitaa, splitab));
-    // Assert its properly sorted.
-    int index = 0;
-    for (Map.Entry<HRegionInfo, Result> e: regions.entrySet()) {
-      if (index == 0) {
-        assertTrue(e.getKey().getEncodedName().equals(parent.getEncodedName()));
-      } else if (index == 1) {
-        assertTrue(e.getKey().getEncodedName().equals(splita.getEncodedName()));
-      } else if (index == 2) {
-        assertTrue(e.getKey().getEncodedName().equals(splitb.getEncodedName()));
-      }
-      index++;
-    }
-
-    // Now play around with the cleanParent function.  Create a ref from splita
-    // up to the parent.
-    Path splitaRef =
-      createReferences(services, htd, parent, splita, Bytes.toBytes("ccc"), false);
-    // Make sure actual super parent sticks around because splita has a ref.
-    assertFalse(janitor.cleanParent(parent, regions.get(parent)));
-
-    //splitba, and split bb, do not have dirs in fs.  That means that if
-    // we test splitb, it should get cleaned up.
-    assertTrue(janitor.cleanParent(splitb, regions.get(splitb)));
-
-    // Now remove ref from splita to parent... so parent can be let go and so
-    // the daughter splita can be split (can't split if still references).
-    // BUT make the timing such that the daughter gets cleaned up before we
-    // can get a chance to let go of the parent.
-    FileSystem fs = FileSystem.get(htu.getConfiguration());
-    assertTrue(fs.delete(splitaRef, true));
-    // Create the refs from daughters of splita.
-    Path splitaaRef =
-      createReferences(services, htd, splita, splitaa, Bytes.toBytes("bbb"), false);
-    Path splitabRef =
-      createReferences(services, htd, splita, splitab, Bytes.toBytes("bbb"), true);
-
-    // Test splita.  It should stick around because references from splitab, etc.
-    assertFalse(janitor.cleanParent(splita, regions.get(splita)));
-
-    // Now clean up parent daughter first.  Remove references from its daughters.
-    assertTrue(fs.delete(splitaaRef, true));
-    assertTrue(fs.delete(splitabRef, true));
-    assertTrue(janitor.cleanParent(splita, regions.get(splita)));
-
-    // Super parent should get cleaned up now both splita and splitb are gone.
-    assertTrue(janitor.cleanParent(parent, regions.get(parent)));
-  }
-
-  private String setRootDirAndCleanIt(final HBaseTestingUtility htu,
-      final String subdir)
-  throws IOException {
-    Path testdir = HBaseTestingUtility.getTestDir(subdir);
-    FileSystem fs = FileSystem.get(htu.getConfiguration());
-    if (fs.exists(testdir)) assertTrue(fs.delete(testdir, true));
-    htu.getConfiguration().set(HConstants.HBASE_DIR, testdir.toString());
-    return htu.getConfiguration().get(HConstants.HBASE_DIR);
-  }
-
-  /**
-   * @param services Master services instance.
-   * @param htd
-   * @param parent
-   * @param daughter
-   * @param midkey
-   * @param top True if we are to write a 'top' reference.
-   * @return Path to reference we created.
-   * @throws IOException
-   */
-  private Path createReferences(final MasterServices services,
-      final HTableDescriptor htd, final HRegionInfo parent,
-      final HRegionInfo daughter, final byte [] midkey, final boolean top)
-  throws IOException {
-    Path rootdir = services.getMasterFileSystem().getRootDir();
-    Path tabledir = HTableDescriptor.getTableDir(rootdir, parent.getTableName());
-    Path storedir = Store.getStoreHomedir(tabledir, daughter.getEncodedName(),
-      htd.getColumnFamilies()[0].getName());
-    Reference ref = new Reference(midkey,
-      top? Reference.Range.top: Reference.Range.bottom);
-    long now = System.currentTimeMillis();
-    // Reference name has this format: StoreFile#REF_NAME_PARSER
-    Path p = new Path(storedir, Long.toString(now) + "." + parent.getEncodedName());
-    FileSystem fs = services.getMasterFileSystem().getFileSystem();
-    ref.write(fs, p);
-    return p;
-  }
-
-  private Result createResult(final HRegionInfo parent, final HRegionInfo a,
-      final HRegionInfo b)
-  throws IOException {
-    List<KeyValue> kvs = new ArrayList<KeyValue>();
-    kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
-      HConstants.SPLITA_QUALIFIER, Writables.getBytes(a)));
-    kvs.add(new KeyValue(parent.getRegionName(), HConstants.CATALOG_FAMILY,
-      HConstants.SPLITB_QUALIFIER, Writables.getBytes(b)));
-    return new Result(kvs);
-  }
-
-  private HTableDescriptor createHTableDescriptor() {
-    HTableDescriptor htd = new HTableDescriptor("t");
-    htd.addFamily(new HColumnDescriptor("f"));
-    return htd;
-  }
-}
\ No newline at end of file
+}

Modified: hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java?rev=1208502&r1=1208501&r2=1208502&view=diff
==============================================================================
--- hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java (original)
+++ hbase/branches/0.90/src/test/java/org/apache/hadoop/hbase/master/TestZKBasedOpenCloseRegion.java Wed Nov 30 16:41:07 2011
@@ -32,7 +32,6 @@ import org.apache.hadoop.hbase.HBaseTest
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HRegionInfo;
 import org.apache.hadoop.hbase.MiniHBaseCluster;
-import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.hadoop.hbase.client.HTable;
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
@@ -112,12 +111,31 @@ public class TestZKBasedOpenCloseRegion 
     HRegionInfo hri = getNonMetaRegion(regionServer.getOnlineRegions());
     LOG.debug("Asking RS to close region " + hri.getRegionNameAsString());
 
+    AtomicBoolean closeEventProcessed = new AtomicBoolean(false);
     AtomicBoolean reopenEventProcessed = new AtomicBoolean(false);
 
+    EventHandlerListener closeListener =
+      new ReopenEventListener(hri.getRegionNameAsString(),
+          closeEventProcessed, EventType.RS_ZK_REGION_CLOSED);
+    cluster.getMaster().executorService.
+      registerListener(EventType.RS_ZK_REGION_CLOSED, closeListener);
+
+    EventHandlerListener openListener =
+      new ReopenEventListener(hri.getRegionNameAsString(),
+          reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
+    cluster.getMaster().executorService.
+      registerListener(EventType.RS_ZK_REGION_OPENED, openListener);
+
     LOG.info("Unassign " + hri.getRegionNameAsString());
+    cluster.getMaster().assignmentManager.unassign(hri);
 
-    regionServer.closeRegion(hri, false); 
+    while (!closeEventProcessed.get()) {
+      Threads.sleep(100);
+    }
 
+    while (!reopenEventProcessed.get()) {
+      Threads.sleep(100);
+    }
     
     //Test a region is reopened on a same region server.
     reopenEventProcessed.set(false);    
@@ -129,7 +147,7 @@ public class TestZKBasedOpenCloseRegion 
     assertTrue(master.isActiveMaster());
     
     hri = getNonMetaRegion(regionServer.getOnlineRegions());
-    EventHandlerListener openListener =
+    openListener =
       new ReopenEventListener(hri.getRegionNameAsString(),
           reopenEventProcessed, EventType.RS_ZK_REGION_OPENED);
     cluster.getMaster().executorService.



Mime
View raw message