HBASE-21785 master reports open regions as RITs and also messes up rit age metric
authorSergey Shelukhin <sershe@apache.org>
Tue, 12 Feb 2019 20:53:17 +0000 (12:53 -0800)
committerSergey Shelukhin <sershe@apache.org>
Tue, 12 Feb 2019 20:53:17 +0000 (12:53 -0800)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java
hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java

index e8ab7d7..a702f70 100644 (file)
@@ -82,8 +82,8 @@ public class MetricsAssignmentManagerSourceImpl
   }
 
   @Override
-  public void setRITOldestAge(final long ritCount) {
-    ritOldestAgeGauge.set(ritCount);
+  public void setRITOldestAge(final long ritOldestAge) {
+    ritOldestAgeGauge.set(ritOldestAge);
   }
 
   @Override
index c12f806..2d0c3be 100644 (file)
@@ -1195,7 +1195,13 @@ public class AssignmentManager {
     private void update(final Collection<RegionState> regions, final long currentTime) {
       for (RegionState state: regions) {
         totalRITs++;
-        final long ritTime = currentTime - state.getStamp();
+        final long ritStartedMs = state.getStamp();
+        if (ritStartedMs == 0) {
+          // Don't output bogus values to metrics if they accidentally make it here.
+          LOG.warn("The RIT {} has no start time", state.getRegion());
+          continue;
+        }
+        final long ritTime = currentTime - ritStartedMs;
         if (ritTime > ritThreshold) {
           if (ritsOverThreshold == null) {
             ritsOverThreshold = new HashMap<String, RegionState>();
index 087d9bc..7dbdbee 100644 (file)
@@ -169,7 +169,11 @@ public class RegionStateNode implements Comparable<RegionStateNode> {
 
   public long getLastUpdate() {
     TransitRegionStateProcedure proc = this.procedure;
-    return proc != null ? proc.getLastUpdate() : lastUpdate;
+    if (proc != null) {
+      long lastUpdate = proc.getLastUpdate();
+      return lastUpdate != 0 ? lastUpdate : proc.getSubmittedTime();
+    }
+    return lastUpdate;
   }
 
   public void setLastHost(final ServerName serverName) {