Skip to content

Commit b89ec35

Browse files
binlijinJenkins
authored andcommitted
HBASE-23231 ReplicationSource do not update metrics after refresh (apache#778)
Signed-off-by: stack <[email protected]> Signed-off-by: Duo Zhang <[email protected]> (cherry picked from commit 06611d6) Change-Id: I64505ca2698431791d00b14ef59e3ebd44e2f623
1 parent 833c43d commit b89ec35

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,12 @@ public void terminate(String reason, Exception cause) {
556556
terminate(reason, cause, true);
557557
}
558558

559-
public void terminate(String reason, Exception cause, boolean join) {
559+
@Override
560+
public void terminate(String reason, Exception cause, boolean clearMetrics) {
561+
terminate(reason, cause, clearMetrics, true);
562+
}
563+
564+
public void terminate(String reason, Exception cause, boolean clearMetrics, boolean join) {
560565
if (cause == null) {
561566
LOG.info("{} Closing source {} because: {}", logPeerId(), this.queueId, reason);
562567
} else {
@@ -615,7 +620,9 @@ public void terminate(String reason, Exception cause, boolean join) {
615620
}
616621
}
617622
}
618-
this.metrics.clear();
623+
if (clearMetrics) {
624+
this.metrics.clear();
625+
}
619626
}
620627

621628
@Override

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceInterface.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ void addHFileRefs(TableName tableName, byte[] family, List<Pair<Path, Path>> pai
9191
*/
9292
void terminate(String reason, Exception cause);
9393

94+
/**
95+
* End the replication
96+
* @param reason why it's terminating
97+
* @param cause the error that's causing it
98+
* @param clearMetrics removes all metrics about this Source
99+
*/
100+
void terminate(String reason, Exception cause, boolean clearMetrics);
101+
94102
/**
95103
* Get the current log that's replicated
96104
* @return the current log

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ public void refreshSources(String peerId) throws IOException {
380380
ReplicationSourceInterface toRemove = this.sources.put(peerId, src);
381381
if (toRemove != null) {
382382
LOG.info("Terminate replication source for " + toRemove.getPeerId());
383-
toRemove.terminate(terminateMessage);
383+
// Do not clear metrics
384+
toRemove.terminate(terminateMessage, null, false);
384385
}
385386
for (SortedSet<String> walsByGroup : walsById.get(peerId).values()) {
386387
walsByGroup.forEach(wal -> src.enqueueLog(new Path(this.logDir, wal)));

hbase-server/src/test/java/org/apache/hadoop/hbase/replication/ReplicationSourceDummy.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ public void terminate(String reason) {
8585

8686
@Override
8787
public void terminate(String reason, Exception e) {
88-
this.metrics.clear();
88+
terminate(reason, e, true);
89+
}
90+
91+
@Override
92+
public void terminate(String reason, Exception e, boolean clearMetrics) {
93+
if (clearMetrics) {
94+
this.metrics.clear();
95+
}
8996
}
9097

9198
@Override

0 commit comments

Comments
 (0)