hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1143534 - in /hbase/branches/0.90: 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:05:31 GMT
Author: tedyu
Date: Wed Jul  6 19:05:31 2011
New Revision: 1143534

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


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

Modified: hbase/branches/0.90/CHANGES.txt
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/CHANGES.txt?rev=1143534&r1=1143533&r2=1143534&view=diff
==============================================================================
--- hbase/branches/0.90/CHANGES.txt (original)
+++ hbase/branches/0.90/CHANGES.txt Wed Jul  6 19:05:31 2011
@@ -56,6 +56,7 @@ Release 0.90.4 - 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
 
   IMPROVEMENT
    HBASE-3882  hbase-config.sh needs to be updated so it can auto-detects the

Modified: hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java?rev=1143534&r1=1143533&r2=1143534&view=diff
==============================================================================
--- hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java (original)
+++ hbase/branches/0.90/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java Wed Jul  6
19:05:31 2011
@@ -656,7 +656,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/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=1143534&r1=1143533&r2=1143534&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 Jul  6 19:05:31 2011
@@ -35,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 org.apache.commons.logging.Log;
@@ -122,8 +123,8 @@ public class AssignmentManager extends Z
    * with the other under a lock on {@link #regions}
    * @see #regions
    */
-  private final NavigableMap<HServerInfo, List<HRegionInfo>> servers =
-    new TreeMap<HServerInfo, List<HRegionInfo>>();
+  private final NavigableMap<HServerInfo, Set<HRegionInfo>> servers =
+    new TreeMap<HServerInfo, Set<HRegionInfo>>();
 
   /**
    * Region to server assignment map.
@@ -779,7 +780,7 @@ public class AssignmentManager extends Z
     synchronized (this.regions) {
       HServerInfo serverInfo = this.regions.remove(regionInfo);
       if (serverInfo == null) return;
-      List<HRegionInfo> serverRegions = this.servers.get(serverInfo);
+      Set<HRegionInfo> serverRegions = this.servers.get(serverInfo);
       if (!serverRegions.remove(regionInfo)) {
         LOG.warn("No " + regionInfo + " on " + serverInfo);
       }
@@ -1590,12 +1591,12 @@ public class AssignmentManager extends Z
    * @param hri
    */
   private void addToServers(final HServerInfo hsi, final HRegionInfo hri) {
-    List<HRegionInfo> hris = servers.get(hsi);
+    Set<HRegionInfo> hris = servers.get(hsi);
     if (hris == null) {
-      hris = new ArrayList<HRegionInfo>();
+      hris = new ConcurrentSkipListSet<HRegionInfo>();
       servers.put(hsi, hris);
     }
-    hris.add(hri);
+    if (!hris.contains(hri)) hris.add(hri);
   }
 
   /**
@@ -1639,13 +1640,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);
@@ -1900,7 +1896,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(hsi);
+      Set<HRegionInfo> assignedRegions = this.servers.remove(hsi);
       if (assignedRegions == null || assignedRegions.isEmpty()) {
         // No regions on this server, we are done, return empty list of RITs
         return rits;
@@ -1987,7 +1983,7 @@ public class AssignmentManager extends Z
     Map<HServerInfo, List<HRegionInfo>> result = null;
     synchronized (this.regions) {
       result = new HashMap<HServerInfo, List<HRegionInfo>>(this.servers.size());
-      for (Map.Entry<HServerInfo, List<HRegionInfo>> e: this.servers.entrySet())
{
+      for (Map.Entry<HServerInfo, Set<HRegionInfo>> e: this.servers.entrySet())
{
         List<HRegionInfo> shallowCopy = new ArrayList<HRegionInfo>(e.getValue());
         HServerInfo clone = new HServerInfo(e.getKey());
         // Set into server load the number of regions this server is carrying



Mime
View raw message