GitHub: https://github.com/JadoreThompson/kv-store.git
Branch: feature/raft
I'm implementing raft consensus algorithm and encountering a logical error during testing.
Within my current implement, each node uses the RaftManager class. The RaftManager is a co-ordinator class holding a connection to the current controller, a broker server of it's own and connections to peer broker servers. When an election is triggered, the node looking to be elected will trigger the state of the manager to be set to candidate. Each broker connection will see this state update and send a vote request to the broker. The broker will send a response to the vote request back to the corresponding client. The client will then provide the response to the manager. The manager will then increment vote count if the node was granted a vote and if voteCount >= majority then the state is changed from CANDIDATE to CONTROLLER. This state change is again viewed by the broker clients who will send a leader elected message to the broker. The broker is then to close the client connection since it's no longer a broker and provide the message to the manager which will close the connection to the current controller and connect to the new controller.
The issue I'm facing is that only the broker which provided the last vote to bring voteCouont to majority is the one receiving the leader elected message although each client is successfully sending the message. Meaning all other nodes aren't being updated.