Commit 5fa947dd authored by Sushant Mahajan's avatar Sushant Mahajan

enforce log on followers

parent b045968a
...@@ -58,7 +58,7 @@ type ClusterConfig struct { ...@@ -58,7 +58,7 @@ type ClusterConfig struct {
} }
type ClientAppend struct { type ClientAppend struct {
logEntry *LogEntry logEntry *LogEntryData
} }
type VoteRequest struct { type VoteRequest struct {
...@@ -476,6 +476,26 @@ func (rft *Raft) candidate() int { ...@@ -476,6 +476,26 @@ func (rft *Raft) candidate() int {
} }
} }
func (rft *Raft) enforceLog() {
req := &AppendRPC{
term: rft.currentTerm,
leaderId: rft.id,
leaderCommit: rft.commitIndex,
}
for i := 0; i < len(rft.nextIndex); i++ {
if len(rft.LogArray)-1 >= rft.nextIndex[i] {
req.entries := rft.LogArray[rft.nextIndex[i]:len(rft.LogArray)]
req.prevLogIndex:=rft.nextIndex[i]-1
req.prevLogTerm:=rft.LogArray[rft.nextIndex[i]-1].Term
if !rafts[i+1].isLeader{
}
}
}
}
func (rft *Raft) leader() int { func (rft *Raft) leader() int {
rft.LogL("became leader") rft.LogL("became leader")
heartbeat := time.NewTimer(time.Millisecond * HEARTBEAT_TIMEOUT) heartbeat := time.NewTimer(time.Millisecond * HEARTBEAT_TIMEOUT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment