hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1519044 - /hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Date Fri, 30 Aug 2013 18:18:20 GMT
Author: liyin
Date: Fri Aug 30 18:18:19 2013
New Revision: 1519044

URL: http://svn.apache.org/r1519044
Log:
[HBASE-8221] [0.89-fb]  ensure that we close the region first, then clean onlineRegions

Author: aaiyer

Summary: ensure that we close the region first, then clean onlineRegions

Test Plan:
push to dev cluster, and stop a RS. ensure that we see 2 rounds of
flush

https://phabricator.fb.com/P2557412

Reviewers: rshroff, liyintang

Reviewed By: liyintang

CC: hbase-eng@

Differential Revision: https://phabricator.fb.com/D950868

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1519044&r1=1519043&r2=1519044&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Fri Aug 30 18:18:19 2013
@@ -2388,13 +2388,14 @@ public class HRegionServer implements HR
           serverInfo.getServerName(), hri.getEncodedName());
       zkUpdater.startRegionCloseEvent(null, false);
     }
-    HRegion region = this.removeFromOnlineRegions(hri);
+    HRegion region = getRegion(hri.getRegionName());
     if (region == null) {
       region = this.removeFromRetryCloseRegions(hri);
     }
     if (region != null) {
       try {
         region.close();
+        this.removeFromOnlineRegions(hri);
       } catch (IOException e) {
         // If region closing fails, add it to retry map.
         this.addToRetryCloseRegions(region);
@@ -2421,7 +2422,6 @@ public class HRegionServer implements HR
     this.lock.writeLock().lock();
     try {
       regionsToClose.addAll(onlineRegions.values());
-      onlineRegions.clear();
     } finally {
       this.lock.writeLock().unlock();
     }
@@ -2436,6 +2436,10 @@ public class HRegionServer implements HR
       }
     }
 
+    return closeRegionsInParallel(regionsToClose);
+  }
+
+  private ArrayList<HRegion> closeRegionsInParallel(List<HRegion> regionsToClose)
{
     // Then, we close the regions
     List<Future<Object>> futures =
         new ArrayList<Future<Object>>(regionsToClose.size());
@@ -2479,6 +2483,7 @@ public class HRegionServer implements HR
         }
         try {
           region.close(abortRequested);
+          removeFromOnlineRegions(region.getRegionInfo());
         } catch (IOException e) {
           cleanup(e, "Error closing " + Bytes.toString(region.getRegionName()));
           throw e;
@@ -2488,31 +2493,6 @@ public class HRegionServer implements HR
     };
   }
 
-  /*
-   * Thread to run close of a region.
-   */
-  private static class RegionCloserThread extends HasThread {
-    private final HRegion r;
-
-    protected RegionCloserThread(final HRegion r) {
-      super(Thread.currentThread().getName() + ".regionCloser." + r.toString());
-      this.r = r;
-    }
-
-    @Override
-    public void run() {
-      try {
-        if (LOG.isDebugEnabled()) {
-          LOG.debug("Closing region " + r.toString());
-        }
-        r.close();
-      } catch (Throwable e) {
-        LOG.error("Error closing region " + r.toString(),
-          RemoteExceptionHandler.checkThrowable(e));
-      }
-    }
-  }
-
   /** Called as the first stage of cluster shutdown. */
   void closeUserRegions() {
     ArrayList<HRegion> regionsToClose = new ArrayList<HRegion>();
@@ -2525,7 +2505,6 @@ public class HRegionServer implements HR
           HRegion r = e.getValue();
           if (!r.getRegionInfo().isMetaRegion()) {
             regionsToClose.add(r);
-            i.remove();
           }
         }
       }
@@ -2533,24 +2512,8 @@ public class HRegionServer implements HR
       this.lock.writeLock().unlock();
     }
     // Run region closes in parallel.
-    List<HasThread> threads = new ArrayList<HasThread>();
-    try {
-      for (final HRegion r : regionsToClose) {
-        RegionCloserThread t = new RegionCloserThread(r);
-        t.start();
-        threads.add(t);
-      }
-    } finally {
-      for (HasThread t : threads) {
-        while (t.isAlive()) {
-          try {
-            t.join();
-          } catch (InterruptedException e) {
-            e.printStackTrace();
-          }
-        }
-      }
-    }
+    closeRegionsInParallel(regionsToClose);
+
     this.quiesced.set(true);
     if (onlineRegions.size() == 0) {
       outboundMsgs.add(REPORT_EXITING);



Mime
View raw message