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 0108e57 commit 3152d99
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,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 @@ -595,7 +600,9 @@ public void terminate(String reason, Exception cause, boolean join) {
if (this.replicationEndpoint != null) {
this.replicationEndpoint.stop();
}
metrics.clear();
if (clearMetrics) {
metrics.clear();
}
if (join) {
for (ReplicationSourceShipper worker : workers) {
Threads.shutdown(worker, this.sleepForRetries);
Expand All @@ -611,7 +618,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 @@ -482,7 +482,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 (NavigableSet<String> walsByGroup : walsById.get(peerId).values()) {
walsByGroup.forEach(wal -> src.enqueueLog(new Path(this.logDir, wal)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,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 3152d99

Please sign in to comment.