Commit dffef763 authored by Sushant Mahajan's avatar Sushant Mahajan

fixed compilation issues due to constant declarations in raft

parent 19eb5b7e
......@@ -158,6 +158,6 @@ func HandleClient(conn net.Conn, rft *raft.Raft) {
//log.Fatal("encode error:", err)
}
rft.Append(buffer.Bytes())
rft.Append(buffer.Bytes(), conn)
}
}
......@@ -525,7 +525,7 @@ func InitKVStore() {
func MonitorCommitChannel(ch chan LogEntry) {
for {
temp := <-ch
//temp := <-ch
}
}
......
......@@ -2,6 +2,7 @@ package raft
import (
"log"
"net"
"net/rpc"
"strconv"
"sync"
......@@ -10,9 +11,9 @@ import (
//constant values used
const (
ClientPORT = 9000
LogPORT = 20000
AckTIMEOUT = 5
CLIENT_PORT = 9000
LOG_PORT = 20000
ACK_TIMEOUT = 5
)
// Logger
......
......@@ -103,7 +103,7 @@ func main() {
rft, _ := raft.NewRaft(clusterConfig, sid, commitCh)
raft.InitKVStore()
go raft.MonitorCommitChannel(commitCh)
go raft.MonitorCommitChannel(commitCh) //for kvstore
go initClientCommunication(server, rft, ch1)
go initInterServerCommunication(server, rft, ch2)
......
......@@ -53,14 +53,14 @@ func testServersCommunic(i int, t *testing.T) {
//on trying to connect with the followers the client should get redirect err from the followers
func testConnectFollower(t *testing.T) {
for i := 2; i < NUM_SERVERS; i++ { //the followers start at second position
server_port := raft.LogPORT + i
server_port := raft.LOG_PORT + i
conn, err := net.Dial("tcp", ":"+strconv.Itoa(server_port))
if err != nil {
t.Error("Error in connecting the server at port: " + strconv.Itoa(server_port))
} else {
time.Sleep(time.Millisecond)
sending := []byte("set mykey1 100 3\r\nlul\r\n")
expecting := []byte("ERR_REDIRECT 127.0.0.1 " + strconv.Itoa(raft.LogPORT+1) + "\r\n" + "ERR_REDIRECT 127.0.0.1 " + strconv.Itoa(raft.CLIENT_PORT+1) + "\r\n")
expecting := []byte("ERR_REDIRECT 127.0.0.1 " + strconv.Itoa(raft.LOG_PORT+1) + "\r\n" + "ERR_REDIRECT 127.0.0.1 " + strconv.Itoa(raft.CLIENT_PORT+1) + "\r\n")
conn.Write(sending)
buffer := make([]byte, 1024)
conn.Read(buffer)
......@@ -86,7 +86,7 @@ func testNoReply(t *testing.T) {
{[]byte("cas mykey1 0 1 6 noreply\r\n"), []byte("ERRCMDERR\r\n")},
}
server_port := raft.LogPORT + 1
server_port := raft.LOG_PORT + 1
conn, err := net.Dial("tcp", ":"+strconv.Itoa(server_port))
if err != 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