diff --git a/CHANGES.txt b/CHANGES.txt index 38d7f436660..01fc74d9c3f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -271,6 +271,8 @@ Release 0.90.3 - Unreleased HBASE-3794 TestRpcMetrics fails on machine where region server is running (Alex Newman) HBASE-3741 Make HRegionServer aware of the regions it's opening/closing + HBASE-3597 ageOfLastAppliedOp should update after cluster replication + failures IMPROVEMENTS HBASE-3747 ReplicationSource should differanciate remote and local exceptions diff --git a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java index b024f06536c..2e8de8b2b86 100644 --- a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java +++ b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java @@ -578,6 +578,8 @@ public class ReplicationSource extends Thread break; } catch (IOException ioe) { + // Didn't ship anything, but must still age the last time we did + this.metrics.refreshAgeOfLastShippedOp(); if (ioe instanceof RemoteException) { ioe = ((RemoteException) ioe).unwrapRemoteException(); LOG.warn("Can't replicate because of an error on the remote cluster: ", ioe); diff --git a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceMetrics.java b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceMetrics.java index c90eb222814..85b42579eb0 100644 --- a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceMetrics.java +++ b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceMetrics.java @@ -66,6 +66,11 @@ public class ReplicationSourceMetrics implements Updater { public final MetricsIntValue sizeOfLogQueue = new MetricsIntValue("sizeOfLogQueue", registry); + // It's a little dirty to preset the age to now since if we fail + // to replicate the very first time then it will show that age instead + // of nothing (although that might not be good either). + private long lastTimestampForAge = System.currentTimeMillis(); + /** * Constructor used to register the metrics * @param id Name of the source this class is monitoring @@ -90,7 +95,17 @@ public class ReplicationSourceMetrics implements Updater { * @param timestamp write time of the edit */ public void setAgeOfLastShippedOp(long timestamp) { - ageOfLastShippedOp.set(System.currentTimeMillis() - timestamp); + lastTimestampForAge = timestamp; + ageOfLastShippedOp.set(System.currentTimeMillis() - lastTimestampForAge); + } + + /** + * Convenience method to use the last given timestamp to refresh the age + * of the last edit. Used when replication fails and need to keep that + * metric accurate. + */ + public void refreshAgeOfLastShippedOp() { + setAgeOfLastShippedOp(lastTimestampForAge); } @Override