question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a listener API for tracking cluster member state

See original GitHub issue

Use case and problem

We make a system that uses SOFAJRaft for leader election and we also want to use it for cluster member management. The basic idea that we want to consider our cluster member “live” for our systems as long as it’s “live” for current leader of SOFAJRaft cluster.

As for now SOFAJRaft provides a Node#listAlivePeers() API method that almost sufficient for our task. The missing piece is there is no simple way to track state change for a member. We want to know when a Peer changes state from “live” to “dead” and vice versa.

So as for now we have to periodically poll Node#listAlivePeers(). That works but such polling seems redundant because NodeImpl#stepDownTimer already does all necessary work (in Node#checkDeadNodes0(...)).

Feature suggestion

Please add an API method to register a listener that will be executed when Peer state changes.

We understand that right now “live/dead” is a computed property so such API method will require to store “last reported state value” for listeners. However overhead of this seems to be quite low.

Sample draft of how the listener interface might look like

/**
 * Invoked when current node considers that state of a follower have changed.
 * 
 * Invoked only when current node is the leader.
 *
 * @param peerId peer whose status have changed
 * @param alive true means that specified peer now considered alive
 */
void onPeerStateChange(final PeerId peerId, final boolean alive);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
killme2008commented, Oct 10, 2020

I think this is an useful feature, we put it into next milestone.

0reactions
killme2008commented, Mar 12, 2021

@alexei-osipov Thanks for your reply. I got it. We can extend the ReplicatorStateListener to support this feature in next release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cluster Events
The Membership Listener interface has methods that are invoked for the following events: memberAdded : A new member is added to the cluster....
Read more >
Reliable Services communication overview - Azure
Communicating with a service. The Reliable Services API provides the following libraries to write clients that communicate with services.
Read more >
Cluster and Node Managment Commands - Apache Solr
These API commands work with a SolrCloud cluster at the entire cluster level, or on individual nodes. CLUSTERSTATUS: Cluster Status. Fetch the cluster...
Read more >
Administration interface — envoy 1.25.0-dev-8011f4 ...
List out all configured cluster manager clusters. This information includes all discovered upstream hosts in each cluster along with per host statistics. This ......
Read more >
Starting and Stopping Cluster Members - Oracle Help Center
This chapter includes the following sections: Starting Cache Servers Cache servers are cluster members that are responsible for storing cached data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found