Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cs733
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sushant Mahajan
cs733
Commits
dffef763
Commit
dffef763
authored
Feb 09, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed compilation issues due to constant declarations in raft
parent
19eb5b7e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
10 additions
and
9 deletions
+10
-9
assignment2/src/connhandler/connhandler.go
assignment2/src/connhandler/connhandler.go
+1
-1
assignment2/src/raft/kvstore.go
assignment2/src/raft/kvstore.go
+1
-1
assignment2/src/raft/raft.go
assignment2/src/raft/raft.go
+4
-3
assignment2/src/server.go
assignment2/src/server.go
+1
-1
assignment2/src/server_test.go
assignment2/src/server_test.go
+3
-3
No files found.
assignment2/src/connhandler/connhandler.go
View file @
dffef763
...
@@ -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
)
}
}
}
}
assignment2/src/raft/kvstore.go
View file @
dffef763
...
@@ -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
}
}
}
}
...
...
assignment2/src/raft/raft.go
View file @
dffef763
...
@@ -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
(
C
lient
PORT
=
9000
C
LIENT_
PORT
=
9000
L
og
PORT
=
20000
L
OG_
PORT
=
20000
A
ck
TIMEOUT
=
5
A
CK_
TIMEOUT
=
5
)
)
// Logger
// Logger
...
...
assignment2/src/server.go
View file @
dffef763
...
@@ -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
)
...
...
assignment2/src/server_test.go
View file @
dffef763
...
@@ -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
.
L
og
PORT
+
i
server_port
:=
raft
.
L
OG_
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\n
lul
\r\n
"
)
sending
:=
[]
byte
(
"set mykey1 100 3
\r\n
lul
\r\n
"
)
expecting
:=
[]
byte
(
"ERR_REDIRECT 127.0.0.1 "
+
strconv
.
Itoa
(
raft
.
L
og
PORT
+
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
.
L
OG_
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
.
L
og
PORT
+
1
server_port
:=
raft
.
L
OG_
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
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment