Commit 7a0f540c authored by Sushant Mahajan's avatar Sushant Mahajan

added KVStore replication code

parent 4948a724
......@@ -46,7 +46,8 @@ type ClusterConfig struct {
}
type SharedLog interface {
Append(data []byte) (LogEntry, error)
Append(data []byte, conn net.Conn) (LogEntry, error)
AddToChannel(entry LogEntry)
}
// Raft information
......@@ -216,6 +217,11 @@ func (rft *Raft) Append(data []byte, conn net.Conn) (LogEntry, error) {
return temp, nil
}
//AddToChannel
func (rft *Raft) AddToChannel(entry LogEntry) {
rft.commitCh <- entry
}
func NewServerConfig(serverId int) (*ServerConfig, error) {
server := new(ServerConfig)
server.Id = serverId
......
......@@ -79,6 +79,7 @@ func (t *AppendEntries) AppendEntriesRPC(args *raft.LogEntryData, reply *Reply)
func (t *AppendEntries) CommitRPC(args *raft.LogEntryData, reply *Reply) error {
Info.Println("Commit RPC invoked")
rft.LogArray[(*args).GetLsn()].SetCommitted(true)
rft.AddToChannel(args)
reply.X = 1
return nil
}
......
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