Add RaftActorLeadershipTransferCohort and implement transfer in Leader 08/31508/5
authorTom Pantelis <tpanteli@brocade.com>
Wed, 16 Dec 2015 08:57:15 +0000 (03:57 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Mon, 21 Dec 2015 11:32:01 +0000 (06:32 -0500)
commitdb8fed63e18fccd2721fa7e189b2278a4f240f2c
tree76341332593c9c636f3b9b4f1d135ce4f9e07b8a
parent156a5dd91d9cb249d36c2b88c71b32b83d9332bf
Add RaftActorLeadershipTransferCohort and implement transfer in Leader

Added a transferLeadership method to Leader that takes a
RaftActorLeadershipTransferCohort to be notified when transfer is
complete.

The leader looks for a follower via AppendEntriesReply whose cached
matchIndex matches the leader's last index. If one is found, it sends
an additional AppendEntries to ensure the follower has applied all its
log entries to its state. It then sends an ElectionTimeout to immediately
start an electioni and notifies the RaftActorLeadershipTransferCohort
via transferComplete.

If no matching follower is found initially, the leader tries again at
the next heartbeat interval via AppendEntriesReply. This continues until
either a matching follower is found or the election timeout period
elapses. The latter is checked at each heartbeat interval via
beforeSendHeartbeat. On time out, it notifies the
RaftActorLeadershipTransferCohort via abortTransfer.

Change-Id: I841e13fdde27ee57b9789a4df6f69bf9901c1e79
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActorLeadershipTransferCohort.java [new file with mode: 0644]
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/Leader.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java