From 7a2561122c510b5651f593c7d7757e4cfdda7196 Mon Sep 17 00:00:00 2001 From: Sergey Shelukhin Date: Tue, 12 Feb 2019 12:53:17 -0800 Subject: [PATCH] HBASE-28652 Backport HBASE-21785 master reports open regions as RITs and also messes up rit age metric Signed-off-by: Duo Zhang Change-Id: I6894e28e270a3e59a7b66815deec9d81f0981f0b --- .../hbase/master/MetricsAssignmentManagerSourceImpl.java | 4 ++-- .../hadoop/hbase/master/assignment/AssignmentManager.java | 8 +++++++- .../hadoop/hbase/master/assignment/RegionStateNode.java | 6 +++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java index 5512e906b67a..819445bd5861 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/master/MetricsAssignmentManagerSourceImpl.java @@ -117,8 +117,8 @@ public void setRITCountOverThreshold(final int ritCount) { } @Override - public void setRITOldestAge(final long ritCount) { - ritOldestAgeGauge.set(ritCount); + public void setRITOldestAge(final long ritOldestAge) { + ritOldestAgeGauge.set(ritOldestAge); } @Override diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java index 9c85f6a6952b..55d747b0d9ec 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/AssignmentManager.java @@ -1624,7 +1624,13 @@ protected void update(final AssignmentManager am) { private void update(final Collection 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(); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java index 2c61d3d427b5..91c0222facd1 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/assignment/RegionStateNode.java @@ -178,7 +178,11 @@ public boolean isSplit() { 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) {