This commit adds a small 10ms delay to the heartbeat when there is only
one node in the cluster. This code needs a larger fix to avoid heartbeats
with a single node cluster but this should work well in the short term.
This commit changes the state handling of the raft log. The actions
for related to each raft state are strictly confined within that state's
loop. To transition between states, the raft log now much clean up all
its actions before moving on.
This fixes issues where goroutines were kicked off for one state but
were delayed in their scheduling so they would begin after the log
had already changed to another state.
This commit refactors the raft package to more loosely couple the individual parts. The clock is now broken into
an interface that signals individual actions in the log. The transport has been mocked to allow more control over
the log tests. The handler's log has been mocked to separate its testing from the log itself.
Fails on travis:
UN TestHTTPHandler_HandleHeartbeat
[raft] 2015/01/30 06:52:42 log open: created at /tmp/raft-667391350, with ID 0, term 0, last applied index of 0
[raft] 2015/01/30 06:52:42 log state change: stopped => leader
[raft] 2015/01/30 06:52:42 log initialize: promoted to 'leader' with cluster ID 1, log ID 1, term 1
panic: runtime error: slice bounds out of range
goroutine 32 [running]:
github.com/influxdb/influxdb/raft.func·007(0x0, 0x0)
/home/travis/gopath/src/github.com/influxdb/influxdb/raft/log.go:953 +0x5d5
Wait()ing for the log to be applied can take 2 loops. Due to this, the
timer used to trigger the 3rd check is pushed too far into the future.
So push the clock even farther into the future so the test doesn't hang
and can then be re-enabled.
Wait()ing for the log the be applied can take 2 loops. Due to this the
timer used to trigger the 3rd check is pushed too far into the future.
So push the clock even farther into the future.
As a result, all Travis testing can be re-enabled.