HBASE-11617 incorrect AgeOfLastAppliedOp and AgeOfLastShippedOp in replication Metrics when no new replication OP (Demai Ni)

This commit is contained in:
Andrew Purtell 2014-08-23 09:43:12 -07:00
parent 6aba7cf40e
commit 4ba7f67f80
2 changed files with 8 additions and 2 deletions

View File

@ -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;
}

View File

@ -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 <now> to indicate that we're current
this.metrics.setAgeOfLastShippedOp(System.currentTimeMillis());
}
if (sleepForRetries("Nothing to replicate", sleepMultiplier)) {
sleepMultiplier++;