You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/08/03 12:19:07 UTC

[GitHub] [hbase] shahrs87 commented on a change in pull request #3518: HBASE-25881: Create a chore to update age related metrics

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



##########
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
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Evolving
+public class MetricsReplicationSourceRefresherChore extends ScheduledChore {
+
+  private ReplicationSource replicationSource;
+

Review comment:
       nit: extra lines.

##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
##########
@@ -224,6 +224,10 @@ public void init(Configuration conf, FileSystem fs, ReplicationSourceManager man
     this.abortOnError = this.conf.getBoolean("replication.source.regionserver.abort",
       true);
 
+    int duration = this.conf.getInt(MetricsReplicationSourceRefresherChore.DURATION,

Review comment:
       Are we creating a chore for every replication source ? If we have 2-3 peers, this will create that many chores. Instead is it possible to create just 1 chore and initialize with ReplicationSourceManager which has list of all replicationSources and just iterate over them every time this chore wakes up. Thoughts ? 

##########
File path: hbase-server/src/test/java/org/apache/hadoop/hbase/replication/regionserver/TestReplicationSource.java
##########
@@ -662,12 +666,16 @@ public void testAgeOfOldestWal() throws Exception {
       manualEdge.setValue(10);
       // Diff of current time (10) and  log-walgroup-a.8 timestamp will be 2.
       source.enqueueLog(log1);
+      // Sleep for chore to update WAL age
+      Thread.sleep(1000);

Review comment:
       Use Waiter.waitFor method to wait on some condition. That way if the jenkins machine are slow, it will not create flaky tests.

##########
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
+ */
+@InterfaceAudience.Private
+@InterfaceStability.Evolving
+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 replication related metrics. 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: issues-unsubscribe@hbase.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org