From d281ffb1399c4172ada285fd8ff4ba7751084b6a Mon Sep 17 00:00:00 2001 From: Andrew Purtell Date: Sat, 23 Aug 2014 09:43:12 -0700 Subject: [PATCH] HBASE-11617 incorrect AgeOfLastAppliedOp and AgeOfLastShippedOp in replication Metrics when no new replication OP (Demai Ni) --- .../hadoop/hbase/replication/regionserver/MetricsSink.java | 7 +++++-- .../hbase/replication/regionserver/ReplicationSource.java | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsSink.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsSink.java index 2a715c09b45..d649edfdcea 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsSink.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsSink.java @@ -47,8 +47,11 @@ public class MetricsSink { * @return the age that was set */ public long setAgeOfLastAppliedOp(long timestamp) { - lastTimestampForAge = timestamp; - long age = System.currentTimeMillis() - lastTimestampForAge; + long age = 0; + if (lastTimestampForAge != timestamp) { + lastTimestampForAge = timestamp; + age = System.currentTimeMillis() - lastTimestampForAge; + } rms.setGauge(SINK_AGE_OF_LAST_APPLIED_OP, age); return age; } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java index 22c80be1b90..087476f9355 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java @@ -393,6 +393,9 @@ public class ReplicationSource extends Thread // Reset the sleep multiplier if nothing has actually gone wrong if (!gotIOE) { sleepMultiplier = 1; + // if there was nothing to ship and it's not an error + // set "ageOfLastShippedOp" to to indicate that we're current + this.metrics.setAgeOfLastShippedOp(System.currentTimeMillis()); } if (sleepForRetries("Nothing to replicate", sleepMultiplier)) { sleepMultiplier++;