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