Complete Candidate behavior implementation

Change-Id: I483ec7d0a3430e186decda7ac45258b47132694b
Signed-off-by: Moiz Raja <moraja@cisco.com>
Properly handle RequestVote in all states

Change-Id: I31987824a2219be230e439ecb152e031c749d4ef
Signed-off-by: Moiz Raja <moraja@cisco.com>
Implement handling of AppendEntries from a recipient perspective

This commit includes everything that a recipient will do when it receives an AppendEntries
except applying of the state to the state machine

Change-Id: I9131b7b73624527efb1a7cb7f0c999fa03f90dfd
Signed-off-by: Moiz Raja <moraja@cisco.com>
Test RaftActor using a simple program

Change-Id: Id0a8091c8f6ee89178bf774be398647c60a25d03
Signed-off-by: Moiz Raja <moraja@cisco.com>
Test handling of the Replicate message by the Leader

Refactored some code, added comments and a test

Change-Id: I0719dbdb4f1f6da611b090faa6cabc84b85e50df
Signed-off-by: Moiz Raja <moraja@cisco.com>
Initial implementation of saving and installing snapshots

This commit basically sketches out how creating and installing snapshots would fit into
the overall design. This has not been tested yet.

Change-Id: I0c575049e8dbda6b63e49dab80ff0980546029d3
Signed-off-by: Moiz Raja <moraja@cisco.com>
Test driver and changes related to it

Change-Id: I6f638dd4f4ce56be2ad31f056394568adeba165c
Signed-off-by: Kamal Rameshan <kramesha@cisco.com>
Signed-off-by: Moiz Raja <moraja@cisco.com>
Fix issue when adding new peers

- There a couple of cases that were not being handled correctly
in Follower#handleAppendEntries this had to be fixed
- ReplicatedLogImpl#size was not properly reported

Change-Id: I8af214cb46a5bae844d1e20e8788502255ffeab5
Signed-off-by: Moiz Raja <moraja@cisco.com>
Remove the confusion around suggestedState

The code has been refactored so that it is clear how exactly a state is
applied. Earlier the state was being passed around and the decision of which
state was returned was not clear.

Tests were modified as appropriate.

Change-Id: Ifb3d339affcc206d1358119defd4b7400e247f8b
Signed-off-by: Moiz Raja <moraja@cisco.com>
Fix bug in ReplicatedLogImpl#removeFrom and use akka-persistence for removing entries

The way things were coded in removeFrom assumed that when a set of entries was deleted
from the persistent log the sequence number would be reset. This is most likely to not be
the case.

Switched to usage which is more appropriate for akka-persistence namely to persist
the operation to delete entries in the akka-persistence journal and on recovery take the
appropriate action.

Also since now we are using the akka-persistence journal purely for persistence we can safely
add other stuff to the journal and so I added UpdateElectionTerm also to the journal. This
takes care of persisting the election information in the same journal.

Change-Id: I34202535711660f19b4cdd9e71a7b55fde7433ce
Signed-off-by: Moiz Raja <moraja@cisco.com>
Enhance code documentation and add TODOs

This commit is based on a code walk through done with Colin Dixon and
Abhishek Kumar.

TODOs and FIXMEs have been added to guide further development.

The major things that need to be completed are,
1. Installing snapshots
2. Adding and removing a new peer with consensus
3. Optimizing AppendEntries (faster synchronization)

Change-Id: Ic788e050fe8fa591176a927906004fd2277e29fa
Signed-off-by: Moiz Raja <moraja@cisco.com>