hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject [1/2] hbase git commit: HBASE-15843 Replace RegionState.getRegionInTransition() Map with a Set
Date Wed, 18 May 2016 20:05:44 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 a9972355c -> e5eea96ca
  refs/heads/master 393bcd69f -> 5ac54e6ab


HBASE-15843 Replace RegionState.getRegionInTransition() Map with a Set


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/5ac54e6a
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/5ac54e6a
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/5ac54e6a

Branch: refs/heads/master
Commit: 5ac54e6abb4e14f3d2fb2e013a7688d7043a60d3
Parents: 393bcd6
Author: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Authored: Wed May 18 12:48:26 2016 -0700
Committer: Matteo Bertozzi <matteo.bertozzi@cloudera.com>
Committed: Wed May 18 12:48:26 2016 -0700

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/ClusterStatus.java  |  9 ++--
 .../hadoop/hbase/protobuf/ProtobufUtil.java     | 15 +++----
 .../hbase/rsgroup/RSGroupAdminServer.java       |  2 +-
 .../master/AssignmentManagerStatusTmpl.jamon    | 43 +++++++++----------
 .../hadoop/hbase/master/AssignmentManager.java  |  8 ++--
 .../org/apache/hadoop/hbase/master/HMaster.java |  4 +-
 .../hadoop/hbase/master/MasterDumpServlet.java  |  9 ++--
 .../hadoop/hbase/master/RegionStates.java       | 44 +++++++++-----------
 .../org/apache/hadoop/hbase/util/HBaseFsck.java | 14 +++----
 .../hadoop/hbase/util/HBaseFsckRepair.java      | 12 ++++--
 .../hbase/coprocessor/TestMasterObserver.java   |  6 +--
 .../hbase/master/TestMasterStatusServlet.java   | 19 ++++-----
 .../TestRegionMergeTransactionOnCluster.java    |  2 +-
 .../TestSplitTransactionOnCluster.java          |  8 ++--
 .../hadoop/hbase/util/TestHBaseFsckOneRS.java   | 17 ++++----
 hbase-shell/src/main/ruby/hbase/admin.rb        |  2 +-
 16 files changed, 103 insertions(+), 111 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
index bc97a95..ffeb51a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ClusterStatus.java
@@ -25,6 +25,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.hadoop.hbase.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.classification.InterfaceStability;
@@ -80,7 +81,7 @@ public class ClusterStatus extends VersionedWritable {
   private Collection<ServerName> deadServers;
   private ServerName master;
   private Collection<ServerName> backupMasters;
-  private Map<String, RegionState> intransition;
+  private Set<RegionState> intransition;
   private String clusterId;
   private String[] masterCoprocessors;
   private Boolean balancerOn;
@@ -90,7 +91,7 @@ public class ClusterStatus extends VersionedWritable {
       final Collection<ServerName> deadServers,
       final ServerName master,
       final Collection<ServerName> backupMasters,
-      final Map<String, RegionState> rit,
+      final Set<RegionState> rit,
       final String[] masterCoprocessors,
       final Boolean balancerOn) {
     this.hbaseVersion = hbaseVersion;
@@ -261,7 +262,7 @@ public class ClusterStatus extends VersionedWritable {
   }
 
   @InterfaceAudience.Private
-  public Map<String, RegionState> getRegionsInTransition() {
+  public Set<RegionState> getRegionsInTransition() {
     return this.intransition;
   }
 
@@ -340,7 +341,7 @@ public class ClusterStatus extends VersionedWritable {
     int ritSize = (intransition != null) ? intransition.size() : 0;
     sb.append("\nNumber of regions in transition: " + ritSize);
     if (ritSize > 0) {
-      for (RegionState state: intransition.values()) {
+      for (RegionState state: intransition) {
         sb.append("\n  " + state.toDescriptiveString());
       }
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
index bbc13ab..e16a3a3 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
@@ -31,10 +31,12 @@ import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.NavigableSet;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
 import org.apache.hadoop.conf.Configuration;
@@ -3528,12 +3530,11 @@ public final class ProtobufUtil {
       backupMasters.add(ProtobufUtil.toServerName(sn));
     }
 
-    Map<String, RegionState> rit = null;
-    rit = new HashMap<String, RegionState>(proto.getRegionsInTransitionList().size());
+    Set<RegionState> rit = null;
+    rit = new HashSet<RegionState>(proto.getRegionsInTransitionList().size());
     for (RegionInTransition region : proto.getRegionsInTransitionList()) {
-      String key = new String(region.getSpec().getValue().toByteArray());
       RegionState value = RegionState.convert(region.getRegionState());
-      rit.put(key, value);
+      rit.add(value);
     }
 
     String[] masterCoprocessors = null;
@@ -3577,11 +3578,11 @@ public final class ProtobufUtil {
     }
 
     if (status.getRegionsInTransition() != null) {
-      for (Map.Entry<String, RegionState> rit : status.getRegionsInTransition().entrySet())
{
-        ClusterStatusProtos.RegionState rs = rit.getValue().convert();
+      for (RegionState rit : status.getRegionsInTransition()) {
+        ClusterStatusProtos.RegionState rs = rit.convert();
         RegionSpecifier.Builder spec =
             RegionSpecifier.newBuilder().setType(RegionSpecifierType.REGION_NAME);
-        spec.setValue(ByteStringer.wrap(Bytes.toBytes(rit.getKey())));
+        spec.setValue(ByteStringer.wrap(rit.getRegion().getRegionName()));
 
         RegionInTransition pbRIT =
             RegionInTransition.newBuilder().setSpec(spec.build()).setRegionState(rs).build();

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
----------------------------------------------------------------------
diff --git a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
index 8725781..7aea464 100644
--- a/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
+++ b/hbase-rsgroup/src/main/java/org/apache/hadoop/hbase/rsgroup/RSGroupAdminServer.java
@@ -191,7 +191,7 @@ public class RSGroupAdminServer extends RSGroupAdmin {
               }
             }
             for (RegionState state :
-                master.getAssignmentManager().getRegionStates().getRegionsInTransition().values())
{
+                master.getAssignmentManager().getRegionStates().getRegionsInTransition())
{
               if (state.getServerName().getHostPort().equals(rs)) {
                 regions.add(state.getRegion());
               }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
index 42334ff..e2ae09d 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/AssignmentManagerStatusTmpl.jamon
@@ -23,38 +23,34 @@ org.apache.hadoop.hbase.master.RegionState;
 org.apache.hadoop.conf.Configuration;
 org.apache.hadoop.hbase.HBaseConfiguration;
 org.apache.hadoop.hbase.HConstants;
-java.util.Iterator;
-java.util.Map;
-java.util.List;
-java.util.ArrayList;
-java.util.Map.Entry;
-java.util.Arrays;
+java.util.HashSet;
+java.util.SortedSet;
 </%import>
 <%args>
 AssignmentManager assignmentManager;
 int limit = 100;
 </%args>
 
-<%java Map<String, RegionState> rit = assignmentManager
+<%java SortedSet<RegionState> rit = assignmentManager
   .getRegionStates().getRegionsInTransitionOrderedByTimestamp(); %>
 
 <%if !rit.isEmpty() %>
 <%java>
-List<String> ritsOverThreshold = new ArrayList<>();
-List<String> ritsTwiceThreshold = new ArrayList<>();
+HashSet<String> ritsOverThreshold = new HashSet<String>();
+HashSet<String> ritsTwiceThreshold = new HashSet<String>();
 // process the map to find region in transition details
 Configuration conf = HBaseConfiguration.create();
 int ritThreshold = conf.getInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 60000);
 int numOfRITOverThreshold = 0;
 long currentTime = System.currentTimeMillis();
-for (Map.Entry<String, RegionState> e : rit.entrySet()) {
-  long ritTime = currentTime - e.getValue().getStamp();
+for (RegionState rs : rit) {
+  long ritTime = currentTime - rs.getStamp();
   if(ritTime > (ritThreshold * 2)) {
      numOfRITOverThreshold++;
-     ritsTwiceThreshold.add(e.getKey());
+     ritsTwiceThreshold.add(rs.getRegion().getEncodedName());
   } else if (ritTime > ritThreshold) {
      numOfRITOverThreshold++;
-     ritsOverThreshold.add(e.getKey());
+     ritsOverThreshold.add(rs.getRegion().getEncodedName());
   }
 }
 
@@ -64,7 +60,7 @@ int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
 </%java>
     <section>
     <h2>Regions in Transition</h2>
-     <p><% numOfRITs %> region(s) in transition.  
+     <p><% numOfRITs %> region(s) in transition.
      <%if !ritsTwiceThreshold.isEmpty()  %>
          <span class="label label-danger" style="font-size:100%;font-weight:normal">
      <%elseif !ritsOverThreshold.isEmpty() %>
@@ -72,14 +68,14 @@ int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
      <%else>
          <span>
      </%if>
-         <% numOfRITOverThreshold %> region(s) in transition for 
+         <% numOfRITOverThreshold %> region(s) in transition for
              more than <% ritThreshold %> milliseconds.
          </span>
      </p>
      <div class="tabbable">
          <div class="tab-content">
          <%java int recordItr = 0; %>
-         <%for Map.Entry<String, RegionState> entry : rit.entrySet() %>
+         <%for RegionState rs : rit %>
              <%if (recordItr % ritsPerPage) == 0 %>
                  <%if recordItr == 0 %>
              <div class="tab-pane active" id="tab_rits<% (recordItr / ritsPerPage)
+ 1 %>">
@@ -89,18 +85,17 @@ int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
                  <table class="table table-striped" style="margin-bottom:0px;"><tr><th>Region</th>
                      <th>State</th><th>RIT time (ms)</th></tr>
              </%if>
- 
-             <%if ritsOverThreshold.contains(entry.getKey()) %>
+
+             <%if ritsOverThreshold.contains(rs.getRegion().getEncodedName()) %>
                      <tr class="alert alert-warning" role="alert">
-             <%elseif ritsTwiceThreshold.contains(entry.getKey()) %>
+             <%elseif ritsTwiceThreshold.contains(rs.getRegion().getEncodedName()) %>
                      <tr class="alert alert-danger" role="alert">
             <%else>
                     <tr>
             </%if>
-                         <td><% entry.getKey() %></td><td>
-                         <% HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(
-                         entry.getValue(), conf) %></td>
-                         <td><% (currentTime - entry.getValue().getStamp()) %>
</td>
+                        <td><% rs.getRegion().getEncodedName() %></td><td>
+                        <% HRegionInfo.getDescriptiveNameFromRegionStateForDisplay(rs,
conf) %></td>
+                        <td><% (currentTime - rs.getStamp()) %> </td>
                      </tr>
                      <%java recordItr++; %>
              <%if (recordItr % ritsPerPage) == 0 %>
@@ -108,7 +103,7 @@ int numOfPages = (int) Math.ceil(numOfRITs * 1.0 / ritsPerPage);
              </div>
          </%if>
          </%for>
-  
+
          <%if (recordItr % ritsPerPage) != 0 %>
              <%for ; (recordItr % ritsPerPage) != 0 ; recordItr++ %>
              <tr><td colspan="3" style="height:61px"></td></tr>

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
index bcf7b7a..f16463f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/AssignmentManager.java
@@ -471,9 +471,9 @@ public class AssignmentManager {
     }
     if (!failover) {
       // If any region except meta is in transition on a live server, it's a failover.
-      Map<String, RegionState> regionsInTransition = regionStates.getRegionsInTransition();
+      Set<RegionState> regionsInTransition = regionStates.getRegionsInTransition();
       if (!regionsInTransition.isEmpty()) {
-        for (RegionState regionState: regionsInTransition.values()) {
+        for (RegionState regionState: regionsInTransition) {
           ServerName serverName = regionState.getServerName();
           if (!regionState.getRegion().isMetaRegion()
               && serverName != null && onlineServers.contains(serverName))
{
@@ -542,7 +542,7 @@ public class AssignmentManager {
           }
         }
       }
-      processRegionsInTransition(regionStates.getRegionsInTransition().values());
+      processRegionsInTransition(regionStates.getRegionsInTransition());
     }
 
     // Now we can safely claim failover cleanup completed and enable
@@ -2010,7 +2010,7 @@ public class AssignmentManager {
     long oldestRITTime = 0;
     int ritThreshold = this.server.getConfiguration().
       getInt(HConstants.METRICS_RIT_STUCK_WARNING_THRESHOLD, 60000);
-    for (RegionState state: regionStates.getRegionsInTransition().values()) {
+    for (RegionState state: regionStates.getRegionsInTransition()) {
       totalRITs++;
       long ritTime = currentTime - state.getStamp();
       if (ritTime > ritThreshold) { // more than the threshold

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index 109097b..f8d0003 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -1254,7 +1254,7 @@ public class HMaster extends HRegionServer implements MasterServices
{
       if (!this.loadBalancerTracker.isBalancerOn()) return false;
       // Only allow one balance run at at time.
       if (this.assignmentManager.getRegionStates().isRegionsInTransition()) {
-        Map<String, RegionState> regionsInTransition =
+        Set<RegionState> regionsInTransition =
           this.assignmentManager.getRegionStates().getRegionsInTransition();
         // if hbase:meta region is in transition, result of assignment cannot be recorded
         // ignore the force flag in that case
@@ -2152,7 +2152,7 @@ public class HMaster extends HRegionServer implements MasterServices
{
 
     String clusterId = fileSystemManager != null ?
       fileSystemManager.getClusterId().toString() : null;
-    Map<String, RegionState> regionsInTransition = assignmentManager != null ?
+    Set<RegionState> regionsInTransition = assignmentManager != null ?
       assignmentManager.getRegionStates().getRegionsInTransition() : null;
     String[] coprocessors = cpHost != null ? getMasterCoprocessors() : null;
     boolean balancerOn = loadBalancerTracker != null ?

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java
index fc5b474..a921ab5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterDumpServlet.java
@@ -24,6 +24,7 @@ import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.util.Date;
 import java.util.Map;
+import java.util.Set;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -116,11 +117,9 @@ public class MasterDumpServlet extends StateDumpServlet {
       return;
     }
 
-    Map<String, RegionState> regionsInTransition =
-      am.getRegionStates().getRegionsInTransition();
-    for (Map.Entry<String, RegionState> e : regionsInTransition.entrySet()) {
-      String rid = e.getKey();
-      RegionState rs = e.getValue();
+    Set<RegionState> regionsInTransition = am.getRegionStates().getRegionsInTransition();
+    for (RegionState rs : regionsInTransition) {
+      String rid = rs.getRegion().getRegionNameAsString();
       out.println("Region " + rid + ": " + rs.toDescriptiveString());
     }
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
index be9758a..9da8033 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/RegionStates.java
@@ -20,6 +20,8 @@ package org.apache.hadoop.hbase.master;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -28,9 +30,9 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.Collections;
-import java.util.Comparator;
+import java.util.SortedSet;
 import java.util.TreeMap;
+import java.util.TreeSet;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
@@ -63,6 +65,15 @@ import org.apache.hadoop.hbase.util.Pair;
 public class RegionStates {
   private static final Log LOG = LogFactory.getLog(RegionStates.class);
 
+  public final static RegionStateStampComparator REGION_STATE_COMPARATOR =
+    new RegionStateStampComparator();
+  private static class RegionStateStampComparator implements Comparator<RegionState>
{
+    @Override
+    public int compare(RegionState l, RegionState r) {
+      return Long.compare(l.getStamp(), r.getStamp());
+    }
+  }
+
   /**
    * Regions currently in transition.
    */
@@ -205,31 +216,16 @@ public class RegionStates {
   /**
    * Get regions in transition and their states
    */
-  @SuppressWarnings("unchecked")
-  public synchronized Map<String, RegionState> getRegionsInTransition() {
-    return (Map<String, RegionState>)regionsInTransition.clone();
+  public synchronized Set<RegionState> getRegionsInTransition() {
+    return new HashSet<RegionState>(regionsInTransition.values());
   }
 
-  @SuppressWarnings("unchecked")
-  public synchronized Map<String, RegionState> getRegionsInTransitionOrderedByTimestamp()
{
-    Map<String, RegionState> rit = (Map<String, RegionState>)regionsInTransition.clone();
-    List<Map.Entry<String, RegionState>> list = new LinkedList<>(rit.entrySet());
-
-    // Compare the RITs' timestamps for ordering.
-    Comparator<Map.Entry<String, RegionState>> c =
-        new Comparator<Map.Entry<String, RegionState>>() {
-      @Override
-      public int compare(Map.Entry<String, RegionState> o1, Map.Entry<String, RegionState>
o2) {
-        return ((Long)o1.getValue().getStamp()).compareTo((Long)o2.getValue().getStamp());
-      }
-    };
-
-    Collections.sort(list, c);
-    Map<String, RegionState> result = new LinkedHashMap<>();
-    for (Map.Entry<String, RegionState> entry : list) {
-      result.put(entry.getKey(), entry.getValue());
+  public synchronized SortedSet<RegionState> getRegionsInTransitionOrderedByTimestamp()
{
+    final TreeSet<RegionState> rit = new TreeSet<RegionState>(REGION_STATE_COMPARATOR);
+    for (RegionState rs: regionsInTransition.values()) {
+      rit.add(rs);
     }
-    return result;
+    return rit;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
index eec5ea4..8666ee6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsck.java
@@ -547,10 +547,10 @@ public class HBaseFsck extends Configured implements Closeable {
     errors.print("Number of requests: " + status.getRequestsCount());
     errors.print("Number of regions: " + status.getRegionsCount());
 
-    Map<String, RegionState> rits = status.getRegionsInTransition();
+    Set<RegionState> rits = status.getRegionsInTransition();
     errors.print("Number of regions in transition: " + rits.size());
     if (details) {
-      for (RegionState state: rits.values()) {
+      for (RegionState state: rits) {
         errors.print("  " + state.toDescriptiveString());
       }
     }
@@ -722,7 +722,7 @@ public class HBaseFsck extends Configured implements Closeable {
     checkAndFixTableLocks();
 
     checkAndFixReplication();
-    
+
     // Remove the hbck lock
     unlockHbck();
 
@@ -3283,7 +3283,7 @@ public class HBaseFsck extends Configured implements Closeable {
       checker.fixExpiredTableLocks();
     }
   }
-  
+
   private void checkAndFixReplication() throws IOException {
     ReplicationChecker checker = new ReplicationChecker(getConf(), zkw, connection, errors);
     checker.checkUnDeletedQueues();
@@ -4214,7 +4214,7 @@ public class HBaseFsck extends Configured implements Closeable {
   public boolean shouldDisableSplitAndMerge() {
     return fixAny || disableSplitAndMerge;
   }
-  
+
   /**
    * Set summary mode.
    * Print only summary of the tables and status (OK or INCONSISTENT)
@@ -4246,7 +4246,7 @@ public class HBaseFsck extends Configured implements Closeable {
     fixTableLocks = shouldFix;
     fixAny |= shouldFix;
   }
-  
+
   /**
    * Set replication fix mode.
    */
@@ -4517,7 +4517,7 @@ public class HBaseFsck extends Configured implements Closeable {
     out.println("");
     out.println(" Replication options");
     out.println("   -fixReplication   Deletes replication queues for removed peers");
-    
+
     out.flush();
     errors.reportError(ERROR_CODE.WRONG_USAGE, sw.toString());
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
index e681789..819816e 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/HBaseFsckRepair.java
@@ -124,10 +124,14 @@ public class HBaseFsckRepair {
     long expiration = timeout + EnvironmentEdgeManager.currentTime();
     while (EnvironmentEdgeManager.currentTime() < expiration) {
       try {
-        Map<String, RegionState> rits=
-            admin.getClusterStatus().getRegionsInTransition();
-
-        if (rits.keySet() != null && !rits.keySet().contains(region.getEncodedName()))
{
+        boolean inTransition = false;
+        for (RegionState rs: admin.getClusterStatus().getRegionsInTransition()) {
+          if (rs.getRegion().equals(region)) {
+            inTransition = true;
+            break;
+          }
+        }
+        if (!inTransition) {
           // yay! no longer RIT
           return;
         }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
index 73917cd..e1c4a1f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestMasterObserver.java
@@ -1916,8 +1916,7 @@ public class TestMasterObserver {
 
       // wait for assignments to finish, if any
       AssignmentManager mgr = master.getAssignmentManager();
-      Collection<RegionState> transRegions =
-        mgr.getRegionStates().getRegionsInTransition().values();
+      Set<RegionState> transRegions = mgr.getRegionStates().getRegionsInTransition();
       for (RegionState state : transRegions) {
         mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
       }
@@ -1953,8 +1952,7 @@ public class TestMasterObserver {
   private void waitForRITtoBeZero(HMaster master) throws Exception {
     // wait for assignments to finish
     AssignmentManager mgr = master.getAssignmentManager();
-    Collection<RegionState> transRegions =
-      mgr.getRegionStates().getRegionsInTransition().values();
+    Set<RegionState> transRegions = mgr.getRegionStates().getRegionsInTransition();
     for (RegionState state : transRegions) {
       mgr.getRegionStates().waitOnRegionToClearRegionsInTransition(state.getRegion());
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
index 135aae5..02f01c4 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
@@ -24,8 +24,8 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.util.HashSet;
 import java.util.List;
-import java.util.NavigableMap;
 import java.util.Set;
+import java.util.TreeSet;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -90,10 +90,8 @@ public class TestMasterStatusServlet {
     // Fake AssignmentManager and RIT
     AssignmentManager am = Mockito.mock(AssignmentManager.class);
     RegionStates rs = Mockito.mock(RegionStates.class);
-    NavigableMap<String, RegionState> regionsInTransition =
-      Maps.newTreeMap();
-    regionsInTransition.put("r1",
-      new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L, FAKE_HOST));
+    Set<RegionState> regionsInTransition = new HashSet<RegionState>();
+    regionsInTransition.add(new RegionState(FAKE_HRI, RegionState.State.CLOSING, 12345L,
FAKE_HOST));
     Mockito.doReturn(rs).when(am).getRegionStates();
     Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
     Mockito.doReturn(am).when(master).getAssignmentManager();
@@ -165,19 +163,18 @@ public class TestMasterStatusServlet {
     RegionStates rs = Mockito.mock(RegionStates.class);
 
     // Add 100 regions as in-transition
-    NavigableMap<String, RegionState> regionsInTransition =
-      Maps.newTreeMap();
+    TreeSet<RegionState> regionsInTransition = new TreeSet<RegionState>(
+      RegionStates.REGION_STATE_COMPARATOR);
     for (byte i = 0; i < 100; i++) {
       HRegionInfo hri = new HRegionInfo(FAKE_TABLE.getTableName(),
           new byte[]{i}, new byte[]{(byte) (i+1)});
-      regionsInTransition.put(hri.getEncodedName(),
+      regionsInTransition.add(
         new RegionState(hri, RegionState.State.CLOSING, 12345L, FAKE_HOST));
     }
     // Add hbase:meta in transition as well
-    regionsInTransition.put(
-        HRegionInfo.FIRST_META_REGIONINFO.getEncodedName(),
+    regionsInTransition.add(
         new RegionState(HRegionInfo.FIRST_META_REGIONINFO,
-                        RegionState.State.CLOSING, 12345L, FAKE_HOST));
+                        RegionState.State.CLOSING, 123L, FAKE_HOST));
     Mockito.doReturn(rs).when(am).getRegionStates();
     Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
     Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransitionOrderedByTimestamp();

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java
index cd4410f..8499335 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionMergeTransactionOnCluster.java
@@ -544,7 +544,7 @@ public class TestRegionMergeTransactionOnCluster {
       if (enabled.get() && req.getTransition(0).getTransitionCode()
           == TransitionCode.READY_TO_MERGE && !resp.hasErrorMessage()) {
         RegionStates regionStates = myMaster.getAssignmentManager().getRegionStates();
-        for (RegionState regionState: regionStates.getRegionsInTransition().values()) {
+        for (RegionState regionState: regionStates.getRegionsInTransition()) {
           // Find the merging_new region and remove it
           if (regionState.isMergingNew()) {
             regionStates.deleteRegion(regionState.getRegion());

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
index fe620e7..e6578bb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestSplitTransactionOnCluster.java
@@ -31,6 +31,7 @@ import java.io.InterruptedIOException;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.atomic.AtomicBoolean;
 
@@ -213,8 +214,7 @@ public class TestSplitTransactionOnCluster {
         @Override
         public boolean evaluate() throws Exception {
           RegionStates regionStates = cluster.getMaster().getAssignmentManager().getRegionStates();
-          Map<String, RegionState> rit = regionStates.getRegionsInTransition();
-          return !rit.containsKey(hri.getEncodedName());
+          return !regionStates.isRegionInTransition(hri.getEncodedName());
         }
       });
     } finally {
@@ -657,7 +657,7 @@ public class TestSplitTransactionOnCluster {
       tableExists = MetaTableAccessor.tableExists(regionServer.getConnection(),
         tableName);
       assertEquals("The specified table should present.", true, tableExists);
-      Map<String, RegionState> rit = cluster.getMaster().getAssignmentManager().getRegionStates()
+      Set<RegionState> rit = cluster.getMaster().getAssignmentManager().getRegionStates()
           .getRegionsInTransition();
       assertTrue(rit.size() == 3);
       cluster.getMaster().getAssignmentManager().regionOffline(st.getFirstDaughter());
@@ -1311,7 +1311,7 @@ public class TestSplitTransactionOnCluster {
       if (enabled.get() && req.getTransition(0).getTransitionCode().equals(
           TransitionCode.READY_TO_SPLIT) && !resp.hasErrorMessage()) {
         RegionStates regionStates = myMaster.getAssignmentManager().getRegionStates();
-        for (RegionState regionState: regionStates.getRegionsInTransition().values()) {
+        for (RegionState regionState: regionStates.getRegionsInTransition()) {
           // Find the merging_new region and remove it
           if (regionState.isSplittingNew()) {
             regionStates.deleteRegion(regionState.getRegion());

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
index a7c0c55..165fea6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/TestHBaseFsckOneRS.java
@@ -80,6 +80,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.Callable;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
@@ -609,7 +610,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
       hbck.close();
     }
   }
-  
+
   @Test (timeout=180000)
   public void testHbckAfterRegionMerge() throws Exception {
     TableName table = TableName.valueOf("testMergeRegionFilesInHdfs");
@@ -1527,7 +1528,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
     // check no errors
     HBaseFsck hbck = doFsck(conf, false);
     assertNoErrors(hbck);
-    
+
     // create peer
     ReplicationAdmin replicationAdmin = new ReplicationAdmin(conf);
     Assert.assertEquals(0, replicationAdmin.getPeersCount());
@@ -1538,7 +1539,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
     replicationAdmin.addPeer("1", rpc, null);
     replicationAdmin.getPeersCount();
     Assert.assertEquals(1, replicationAdmin.getPeersCount());
-    
+
     // create replicator
     ZooKeeperWatcher zkw = new ZooKeeperWatcher(conf, "Test Hbase Fsck", connection);
     ReplicationQueues repQueues =
@@ -1550,7 +1551,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
     Assert.assertEquals(2, repQueues.getAllQueues().size());
     hbck = doFsck(conf, false);
     assertNoErrors(hbck);
-    
+
     // queues for removed peer
     repQueues.addLog("2", "file1");
     repQueues.addLog("2-server2", "file1");
@@ -1559,7 +1560,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
     assertErrors(hbck, new HBaseFsck.ErrorReporter.ERROR_CODE[] {
         HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE,
         HBaseFsck.ErrorReporter.ERROR_CODE.UNDELETED_REPLICATION_QUEUE });
-    
+
     // fix the case
     hbck = doFsck(conf, true);
     hbck = doFsck(conf, false);
@@ -1568,7 +1569,7 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
     Assert.assertEquals(2, repQueues.getAllQueues().size());
     Assert.assertNull(repQueues.getLogsInQueue("2"));
     Assert.assertNull(repQueues.getLogsInQueue("2-sever2"));
-    
+
     replicationAdmin.removePeer("1");
     repQueues.removeAllQueues();
     zkw.close();
@@ -1678,8 +1679,8 @@ public class TestHBaseFsckOneRS extends BaseTestHBaseFsck {
       st.prepare();
       st.stepsBeforePONR(regionServer, regionServer, false);
       AssignmentManager am = cluster.getMaster().getAssignmentManager();
-      Map<String, RegionState> regionsInTransition = am.getRegionStates().getRegionsInTransition();
-      for (RegionState state : regionsInTransition.values()) {
+      Set<RegionState> regionsInTransition = am.getRegionStates().getRegionsInTransition();
+      for (RegionState state : regionsInTransition) {
         am.regionOffline(state.getRegion());
       }
       Map<HRegionInfo, ServerName> regionsMap = new HashMap<HRegionInfo, ServerName>();

http://git-wip-us.apache.org/repos/asf/hbase/blob/5ac54e6a/hbase-shell/src/main/ruby/hbase/admin.rb
----------------------------------------------------------------------
diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb
index 88a6598..d272e62 100644
--- a/hbase-shell/src/main/ruby/hbase/admin.rb
+++ b/hbase-shell/src/main/ruby/hbase/admin.rb
@@ -720,7 +720,7 @@ module Hbase
         puts("version %s" % [ status.getHBaseVersion() ])
         # Put regions in transition first because usually empty
         puts("%d regionsInTransition" % status.getRegionsInTransition().size())
-        for k, v in status.getRegionsInTransition()
+        for v in status.getRegionsInTransition()
           puts("    %s" % [v])
         end
         master = status.getMaster()


Mime
View raw message