Bug 2194: Modify FindPrimary to check for leader 64/16164/18
authorTom Pantelis <tpanteli@brocade.com>
Tue, 24 Mar 2015 18:46:21 +0000 (14:46 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Tue, 24 Mar 2015 19:12:39 +0000 (15:12 -0400)
Write-only transaactions now bypass sending the CreateTransaction
message to the shard however we still need to check if the shard has
a leader.

So I modified the ShardManager to check for this on FindPrimaryShard
message utilizing the RoleChanged and LeaderStateChanged events recently
added. On FindPrimaryShard, if the shard is not ready, ie its role is
Candidate or it has no leaderId or is not initialized, the sender is
recorded and a timeout schedule is started. If the shard becomes ready,
the success message is sent to the sender. If the timer expires, an error
message is sent to the sender, either ActorNotInitilized or
NoShardLeaderException.

I also changed the ShardInformation peerAddresses map to String key
instead of ShardIdentifier for convenient lookup of the leaderId to
obviate the need to parse a ShardIdentifier from a String. The key is
not used/needed as a ShardIdentifier and the Shard converts the keys to
Strings anyway so it made sense to define the key as String. Several
unit tests had to be changed as a result of this.

In ActorContext#findPrimaryShardAsync, I added a check for
NoShardLeaderException.  I also removed the synchronous findPrimaryShard
and findPrimaryShardOrNull methods to avoid having to duplicate the
exception handling. ActorContext#broadcast was the only caller and it
should use findPrimaryShardAsync anyway.

Change-Id: I22bc661314b25812024b7d274afb390768408b0b
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>

No differences found