shahrs87 commented on a change in pull request #3518:
URL: https://github.com/apache/hbase/pull/3518#discussion_r681702358



##########
File path: 
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceRefresherChore.java
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hbase.replication.regionserver;
+
+import java.util.Map;
+import java.util.concurrent.PriorityBlockingQueue;
+
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hbase.ScheduledChore;
+import org.apache.hadoop.hbase.Stoppable;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
+import org.apache.hadoop.hbase.wal.AbstractFSWALProvider;
+import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.yetus.audience.InterfaceStability;
+
+/**
+ * The Class MetricsReplicationSourceRefresherChore for refreshing age related 
replication source
+ * metrics
+ */
[email protected]
[email protected]
+public class MetricsReplicationSourceRefresherChore extends ScheduledChore {
+
+  private ReplicationSource replicationSource;
+
+  private MetricsSource metrics;
+
+  public static final String DURATION = 
"hbase.metrics.replication.source.refresher.duration";
+  public static final int DEFAULT_DURATION_MILLISECONDS = 60000;
+
+  public MetricsReplicationSourceRefresherChore(Stoppable stopper,
+      ReplicationSource replicationSource) {
+    this(DEFAULT_DURATION_MILLISECONDS, stopper, replicationSource);
+  }
+
+  public MetricsReplicationSourceRefresherChore(int duration, Stoppable 
stopper,
+      ReplicationSource replicationSource) {
+    super("MetricsSourceRefresherChore", stopper, duration);
+    this.replicationSource = replicationSource;
+    this.metrics = this.replicationSource.getSourceMetrics();
+  }
+
+  @Override
+  protected void chore() {
+    this.metrics.setOldestWalAge(getOldestWalAge());
+  }
+
+  /*
+   * Returns the age of oldest wal.
+   */
+  long getOldestWalAge() {

Review comment:
       @rahulLiving  There are many `age` related metrics in Replication 
subsytem. We want to update all the metrics from this Chore. I don't think it 
is a good idea to move the implementation from ReplicationSourceLogQueue to 
here.
   What I had in my mind is: Compute `oldestWalTimestamp` (not the age, just 
the timestamp) in `ReplicationSourceLogQueue` and keep it as a class variable. 
Don't calculate the age there. Instead calculate the age in this chore. So for 
some reason if Replication thread is stuck, it will not update 
`oldestWalTimestamp`  and since age is calculated in this chore, it will be 
updated. Does that make sense ?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to