hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1143530 - in /hbase/trunk: CHANGES.txt src/main/java/org/apache/hadoop/hbase/HRegionInfo.java src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
Date Wed, 06 Jul 2011 19:00:11 GMT
Author: tedyu
Date: Wed Jul  6 19:00:11 2011
New Revision: 1143530

URL: http://svn.apache.org/viewvc?rev=1143530&view=rev
Log:
HBASE-4053  Most of the regions were added into AssignmentManager#servers twice


Modified:
    hbase/trunk/CHANGES.txt
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java

Modified: hbase/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/trunk/CHANGES.txt?rev=1143530&r1=1143529&r2=1143530&view=diff
==============================================================================
--- hbase/trunk/CHANGES.txt (original)
+++ hbase/trunk/CHANGES.txt Wed Jul  6 19:00:11 2011
@@ -150,6 +150,7 @@ Release 0.91.0 - Unreleased
                regions are NOT made online by master
    HBASE-3904  HBA.createTable(final HTableDescriptor desc, byte [][] splitKeys)
                should be synchronous
+   HBASE-4053  Most of the regions were added into AssignmentManager#servers twice
 
   IMPROVEMENTS
    HBASE-3290  Max Compaction Size (Nicolas Spiegelberg via Stack)  

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=1143530&r1=1143529&r2=1143530&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java Wed Jul  6 19:00:11
2011
@@ -708,7 +708,15 @@ public class HRegionInfo extends Version
     }
 
     // Compare end keys.
-    return Bytes.compareTo(this.endKey, o.endKey);
+    result = Bytes.compareTo(this.endKey, o.endKey);
+    if (result != 0) {
+      return result;
+    }
+    if (this.offLine == o.offLine)
+        return 0;
+    if (this.offLine == true) return -1;
+        
+    return 1;
   }
 
   /**

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java?rev=1143530&r1=1143529&r2=1143530&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java Wed Jul
 6 19:00:11 2011
@@ -24,7 +24,6 @@ import java.io.DataOutput;
 import java.io.IOException;
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -36,6 +35,7 @@ import java.util.SortedMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.ConcurrentSkipListSet;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 
@@ -53,9 +53,9 @@ import org.apache.hadoop.hbase.catalog.C
 import org.apache.hadoop.hbase.catalog.MetaReader;
 import org.apache.hadoop.hbase.catalog.RootLocationEditor;
 import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.executor.ExecutorService;
 import org.apache.hadoop.hbase.executor.RegionTransitionData;
+import org.apache.hadoop.hbase.executor.EventHandler.EventType;
 import org.apache.hadoop.hbase.ipc.ServerNotRunningYetException;
 import org.apache.hadoop.hbase.master.LoadBalancer.RegionPlan;
 import org.apache.hadoop.hbase.master.handler.ClosedRegionHandler;
@@ -125,8 +125,8 @@ public class AssignmentManager extends Z
    * with the other under a lock on {@link #regions}
    * @see #regions
    */
-  private final NavigableMap<ServerName, List<HRegionInfo>> servers =
-    new TreeMap<ServerName, List<HRegionInfo>>();
+  private final NavigableMap<ServerName, Set<HRegionInfo>> servers =
+    new TreeMap<ServerName, Set<HRegionInfo>>();
 
   /**
    * Region to server assignment map.
@@ -182,7 +182,7 @@ public class AssignmentManager extends Z
     // Sync on this.regions because access to this.servers always synchronizes
     // in this order.
     synchronized (this.regions) {
-      for (Map.Entry<ServerName, List<HRegionInfo>> e: servers.entrySet()) {
+      for (Map.Entry<ServerName, Set<HRegionInfo>> e: servers.entrySet()) {
         numServers++;
         totalLoad += e.getValue().size();
       }
@@ -710,7 +710,7 @@ public class AssignmentManager extends Z
   private HRegionInfo findHRegionInfo(final ServerName sn,
       final String encodedName) {
     if (!this.serverManager.isServerOnline(sn)) return null;
-    List<HRegionInfo> hris = this.servers.get(sn);
+    Set<HRegionInfo> hris = this.servers.get(sn);
     HRegionInfo foundHri = null;
     for (HRegionInfo hri: hris) {
       if (hri.getEncodedName().equals(encodedName)) {
@@ -954,7 +954,7 @@ public class AssignmentManager extends Z
     synchronized (this.regions) {
       ServerName sn = this.regions.remove(regionInfo);
       if (sn == null) return;
-      List<HRegionInfo> serverRegions = this.servers.get(sn);
+      Set<HRegionInfo> serverRegions = this.servers.get(sn);
       if (!serverRegions.remove(regionInfo)) {
         LOG.warn("No " + regionInfo + " on " + sn);
       }
@@ -1818,12 +1818,12 @@ public class AssignmentManager extends Z
    * @param hri
    */
   private void addToServers(final ServerName sn, final HRegionInfo hri) {
-    List<HRegionInfo> hris = servers.get(sn);
+    Set<HRegionInfo> hris = servers.get(sn);
     if (hris == null) {
-      hris = new ArrayList<HRegionInfo>();
+      hris = new ConcurrentSkipListSet<HRegionInfo>();
       servers.put(sn, hris);
     }
-    hris.add(hri);
+    if (!hris.contains(hri)) hris.add(hri);
   }
 
   /**
@@ -1865,13 +1865,8 @@ public class AssignmentManager extends Z
     }
     synchronized (this.regions) {
       this.regions.remove(hri);
-      for (List<HRegionInfo> regions : this.servers.values()) {
-        for (int i=0;i<regions.size();i++) {
-          if (regions.get(i).equals(hri)) {
-            regions.remove(i);
-            break;
-          }
-        }
+      for (Set<HRegionInfo> regions : this.servers.values()) {
+        regions.remove(hri);
       }
     }
     clearRegionPlan(hri);
@@ -2124,7 +2119,7 @@ public class AssignmentManager extends Z
     Set<HRegionInfo> deadRegions = null;
     List<RegionState> rits = new ArrayList<RegionState>();
     synchronized (this.regions) {
-      List<HRegionInfo> assignedRegions = this.servers.remove(sn);
+      Set<HRegionInfo> assignedRegions = this.servers.remove(sn);
       if (assignedRegions == null || assignedRegions.isEmpty()) {
         // No regions on this server, we are done, return empty list of RITs
         return rits;
@@ -2184,7 +2179,7 @@ public class AssignmentManager extends Z
     Map<ServerName, List<HRegionInfo>> result = null;
     synchronized (this.regions) {
       result = new HashMap<ServerName, List<HRegionInfo>>(this.servers.size());
-      for (Map.Entry<ServerName, List<HRegionInfo>> e: this.servers.entrySet())
{
+      for (Map.Entry<ServerName, Set<HRegionInfo>> e: this.servers.entrySet())
{
         result.put(e.getKey(), new ArrayList<HRegionInfo>(e.getValue()));
       }
     }
@@ -2224,8 +2219,8 @@ public class AssignmentManager extends Z
   void unassignCatalogRegions() {
     this.servers.entrySet();
     synchronized (this.regions) {
-      for (Map.Entry<ServerName, List<HRegionInfo>> e: this.servers.entrySet())
{
-        List<HRegionInfo> regions = e.getValue();
+      for (Map.Entry<ServerName, Set<HRegionInfo>> e: this.servers.entrySet())
{
+        Set<HRegionInfo> regions = e.getValue();
         if (regions == null || regions.isEmpty()) continue;
         for (HRegionInfo hri: regions) {
           if (hri.isMetaRegion()) {
@@ -2237,30 +2232,6 @@ public class AssignmentManager extends Z
   }
 
   /**
-   * Assigns list of user regions in round-robin fashion, if any.
-   * @param sync True if we are to wait on all assigns.
-   * @param startup True if this is server startup time.
-   * @throws InterruptedException
-   * @throws IOException
-   */
-  void bulkAssignUserRegions(final HRegionInfo [] regions,
-      final List<ServerName> servers, final boolean sync)
-  throws IOException {
-    Map<ServerName, List<HRegionInfo>> bulkPlan =
-      LoadBalancer.roundRobinAssignment(Arrays.asList(regions), servers);
-    LOG.info("Bulk assigning " + regions.length + " region(s) " +
-      "round-robin across " + servers.size() + " server(s)");
-    // Use fixed count thread pool assigning.
-    BulkAssigner ba = new GeneralBulkAssigner(this.master, bulkPlan, this);
-    try {
-      ba.bulkAssign(sync);
-    } catch (InterruptedException e) {
-      throw new IOException("InterruptedException bulk assigning", e);
-    }
-    LOG.info("Bulk assigning done");
-  }
-
-  /**
    * State of a Region while undergoing transitions.
    */
   public static class RegionState implements Writable {



Mime
View raw message