Skip to content

Commit

Permalink
HBASE-23231 ReplicationSource do not update metrics after refresh (#778)
Browse files Browse the repository at this point in the history
Signed-off-by: stack <stack@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
  • Loading branch information
binlijin authored and Apache9 committed Oct 31, 2019
1 parent 19adfee commit 9ab0489
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,12 @@ public void terminate(String reason, Exception cause) {
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 {
Expand Down Expand Up @@ -616,7 +621,9 @@ public void terminate(String reason, Exception cause, boolean join) {
}
}
}
this.metrics.clear();
if (clearMetrics) {
this.metrics.clear();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ void addHFileRefs(TableName tableName, byte[] family, List<Pair<Path, Path>> pai
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ public void refreshSources(String peerId) throws IOException {
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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,14 @@ public void terminate(String reason) {

@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
Expand Down

0 comments on commit 9ab0489

Please sign in to comment.