+ public RaftActorBehavior handleMessage(final ActorRef sender, final Object message) {
+ if (message instanceof ElectionTimeout) {
+ log.debug("{}: Received ElectionTimeout", logName());
+
+ if (votesRequired == 0) {
+ // If there are no peers then we should be a Leader
+ // We wait for the election timeout to occur before declare
+ // ourselves the leader. This gives enough time for a leader
+ // who we do not know about (as a peer)
+ // to send a message to the candidate
+
+ return internalSwitchBehavior(RaftState.Leader);
+ }