Skip to content

Commit

Permalink
fix(raft): update role metrics when closing or transitioning to inactive
Browse files Browse the repository at this point in the history
(cherry picked from commit 35ea7ba)
  • Loading branch information
deepthidevaki authored and github-actions[bot] committed Nov 29, 2023
1 parent d25c1ae commit b6c6c11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ public void checkThread() {
private RaftRole createRole(final Role role) {
switch (role) {
case INACTIVE:
raftRoleMetrics.becomingInactive();
return new InactiveRole(this);
case PASSIVE:
return new PassiveRole(this);
Expand Down Expand Up @@ -915,6 +916,7 @@ public void transition(final Type type) {

@Override
public void close() {
raftRoleMetrics.becomingInactive();
started = false;
// Unregister protocol listeners.
unregisterHandlers(protocol);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ public RaftRoleMetrics(final String partitionName) {
electionLatency = ELECTION_LATENCY.labels(partitionGroupName, partition);
}

public void becomingInactive() {
role.set(0);
}

public void becomingFollower() {
role.set(1);
}
Expand Down

0 comments on commit b6c6c11

Please sign in to comment.