Fix missing LeaderStateChanged event 97/42597/4
authorTom Pantelis <tpanteli@brocade.com>
Tue, 26 Jul 2016 15:55:09 +0000 (11:55 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 3 Aug 2016 11:39:41 +0000 (11:39 +0000)
commitfc793885b446b6777ce9d86e7a4867951a8561bb
tree685378eecdf17e5a4e339b9bf7d8c893281bc07a
parent5e590ea1548dd4974ca59f1318a11f2a8651c3b7
Fix missing LeaderStateChanged event

In RaftActor, the logic to detect a leader state change compares the last
valid leader Id with the current behavior leader Id. Consider the
following leader Id change sequence:

  "member-1" -> null (goes leaderless)
  null -> "member-1" (member-1 becomes leader again)

The first state change will send a LeaderStateChanged event to the
ShardManager with null leader Id causing the ShardManager to clean its
primary shard info cache. However for the second state change, no
LeaderStateChanged event is sent b/c the new leader Id is the same as
the last valid/non-null leader Id. Therefore transactions fail due to no
shard leader.

I changed it to use the last leader Id (null or not) for the comparison
so every state change is detected.

Change-Id: I060872d4712e040b60acfc998914b394a40943af
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-akka-raft/src/main/java/org/opendaylight/controller/cluster/raft/RaftActor.java
opendaylight/md-sal/sal-akka-raft/src/test/java/org/opendaylight/controller/cluster/raft/NonVotingFollowerIntegrationTest.java