Skip to content

Commit 9ab0489

Browse files
binlijinApache9
authored andcommitted
HBASE-23231 ReplicationSource do not update metrics after refresh (#778)
Signed-off-by: stack <stack@apache.org> Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 19adfee commit 9ab0489

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
@@ -555,7 +555,12 @@ public void terminate(String reason, Exception cause) {
555555
terminate(reason, cause, true);
556556
}
557557

558-
public void terminate(String reason, Exception cause, boolean join) {
558+
@Override
559+
public void terminate(String reason, Exception cause, boolean clearMetrics) {
560+
terminate(reason, cause, clearMetrics, true);
561+
}
562+
563+
public void terminate(String reason, Exception cause, boolean clearMetrics, boolean join) {
559564
if (cause == null) {
560565
LOG.info("{} Closing source {} because: {}", logPeerId(), this.queueId, reason);
561566
} else {
@@ -616,7 +621,9 @@ public void terminate(String reason, Exception cause, boolean join) {
616621
}
617622
}
618623
}
619-
this.metrics.clear();
624+
if (clearMetrics) {
625+
this.metrics.clear();
626+
}
620627
}
621628

622629
@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 -> {

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)