Initial heartbeats not sent by Leader 25/15125/3
authortpantelis <tpanteli@brocade.com>
Mon, 9 Feb 2015 06:52:19 +0000 (01:52 -0500)
committertpantelis <tpanteli@brocade.com>
Tue, 10 Feb 2015 00:34:17 +0000 (19:34 -0500)
commitae3b5e9fca4f01878dae38b42e5d52598c4bddda
treeb2a8d6c57472bddc734d490198e7d70c9d21d25e
parent726ee824671781b5031c0108794c22bd0d96eaad
Initial heartbeats not sent by Leader

When a Leader instance is created, it immediately sends out heartbeats
to the followers. However recent changes broke this behavior as
sendAppendEntries now checks if the follower's timeSinceLastActivity >=
heartbeat interval. However, in this case, timeSinceLastActivity is 0 so
the initial heartbeats aren't sent out. Also, on replication, it seems
that sendAppendEntries should always send AppendEntries. So we want to
disable this checking in these 2 cases. We only want check
timeSinceLastActivity if it's initiated by a scheduled heartbeat.

To resolve this, I changed the Leader constructor to directly call
sendAppendEntries instead of scheduling SendHeartbeat with delay 0. I
now pass in the interval to sendAppendEntries. The scheduled heartbeat
passes in the actual heartbeat interval and the oher 2 calls pass in 0.

Several unit tests in LeaderTest had to be changed due to the new
behavior.

Change-Id: I138db649b49ca18070a3247312521daf0dabc88e
Signed-off-by: tpantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/behaviors/AbstractLeader.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/MockRaftActorContext.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/behaviors/LeaderTest.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/utils/MessageCollectorActor.java