You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2019/10/31 02:46:57 UTC

[hbase] branch branch-2 updated: HBASE-23231 ReplicationSource do not update metrics after refresh (#778)

This is an automated email from the ASF dual-hosted git repository.

zhangduo pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 9ab0489  HBASE-23231 ReplicationSource do not update metrics after refresh (#778)
9ab0489 is described below

commit 9ab0489eab966ea4c42a11497c00218175cd2bad
Author: binlijin <bi...@gmail.com>
AuthorDate: Thu Oct 31 09:23:59 2019 +0800

    HBASE-23231 ReplicationSource do not update metrics after refresh (#778)
    
    Signed-off-by: stack <st...@apache.org>
    Signed-off-by: Duo Zhang <zh...@apache.org>
---
 .../hbase/replication/regionserver/ReplicationSource.java     | 11 +++++++++--
 .../replication/regionserver/ReplicationSourceInterface.java  |  8 ++++++++
 .../replication/regionserver/ReplicationSourceManager.java    |  3 ++-
 .../hadoop/hbase/replication/ReplicationSourceDummy.java      |  9 ++++++++-
 4 files changed, 27 insertions(+), 4 deletions(-)

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 41a4e7b..ee423e0 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
@@ -555,7 +555,12 @@ public class ReplicationSource implements ReplicationSourceInterface {
     terminate(reason, cause, true);
   }
 
-  public void terminate(String reason, Exception cause, boolean join) {
+  @Override
+  public void terminate(String reason, Exception cause, boolean clearMetrics) {
+    terminate(reason, cause, clearMetrics, true);
+  }
+
+  public void terminate(String reason, Exception cause, boolean clearMetrics, boolean join) {
     if (cause == null) {
       LOG.info("{} Closing source {} because: {}", logPeerId(), this.queueId, reason);
     } else {
@@ -616,7 +621,9 @@ public class ReplicationSource implements ReplicationSourceInterface {
         }
       }
     }
-    this.metrics.clear();
+    if (clearMetrics) {
+      this.metrics.clear();
+    }
   }
 
   @Override
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
index 91497a4..d287acb 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java
@@ -92,6 +92,14 @@ public interface ReplicationSourceInterface {
   void terminate(String reason, Exception cause);
 
   /**
+   * End the replication
+   * @param reason why it's terminating
+   * @param cause the error that's causing it
+   * @param clearMetrics removes all metrics about this Source
+   */
+  void terminate(String reason, Exception cause, boolean clearMetrics);
+
+  /**
    * Get the current log that's replicated
    * @return the current log
    */
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
index bc5b105..60c49ed 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java
@@ -380,7 +380,8 @@ public class ReplicationSourceManager implements ReplicationListener {
       ReplicationSourceInterface toRemove = this.sources.put(peerId, src);
       if (toRemove != null) {
         LOG.info("Terminate replication source for " + toRemove.getPeerId());
-        toRemove.terminate(terminateMessage);
+        // Do not clear metrics
+        toRemove.terminate(terminateMessage, null, false);
       }
       for (SortedSet<String> walsByGroup : walsById.get(peerId).values()) {
         walsByGroup.forEach(wal -> {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationSourceDummy.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationSourceDummy.java
index ec6ec96..305a818 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationSourceDummy.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationSourceDummy.java
@@ -85,7 +85,14 @@ public class ReplicationSourceDummy implements ReplicationSourceInterface {
 
   @Override
   public void terminate(String reason, Exception e) {
-    this.metrics.clear();
+    terminate(reason, e, true);
+  }
+
+  @Override
+  public void terminate(String reason, Exception e, boolean clearMetrics) {
+    if (clearMetrics) {
+      this.metrics.clear();
+    }
   }
 
   @Override