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
19eb5b7e
Commit
19eb5b7e
authored
Feb 09, 2015
by
Harshit Pande
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mutex added to shared log - facing import errors from package raft while testing
parent
60731d30
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
assignment2/src/raft/raft.go
assignment2/src/raft/raft.go
+9
-3
assignment2/src/server_test.go
assignment2/src/server_test.go
+5
-3
No files found.
assignment2/src/raft/raft.go
View file @
19eb5b7e
...
...
@@ -4,14 +4,15 @@ import (
"log"
"net/rpc"
"strconv"
"sync"
"time"
)
//constant values used
const
(
C
LIENT_
PORT
=
9000
L
OG_PORT
=
8
000
A
CK_
TIMEOUT
=
5
C
lient
PORT
=
9000
L
ogPORT
=
20
000
A
ck
TIMEOUT
=
5
)
// Logger
...
...
@@ -45,6 +46,7 @@ type Raft struct {
commitCh
chan
LogEntry
cluster_config
*
ClusterConfig
//cluster
id
int
//this server id
sync
.
RWMutex
}
type
LogEntry
interface
{
...
...
@@ -128,6 +130,10 @@ func (entry *LogEntryData) Committed() bool {
return
entry
.
committed
}
func
Test
()
{
}
//make raft implement the append function
func
(
rft
*
Raft
)
Append
(
data
[]
byte
,
conn
net
.
Conn
)
(
LogEntry
,
error
)
{
if
rft
.
id
!=
1
{
...
...
assignment2/src/server_test.go
View file @
19eb5b7e
...
...
@@ -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
.
CLIENT_
PORT
+
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\n
lul
\r\n
"
)
expecting
:=
[]
byte
(
"ERR_REDIRECT 127.0.0.1 "
+
strconv
.
Itoa
(
raft
.
CLIENT_
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
.
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
)
...
...
@@ -85,7 +85,9 @@ func testNoReply(t *testing.T) {
{[]
byte
(
"set mykey1 100 3 noreply
\r\n
"
),
[]
byte
(
"ERRCMDERR
\r\n
"
)},
{[]
byte
(
"cas mykey1 0 1 6 noreply
\r\n
"
),
[]
byte
(
"ERRCMDERR
\r\n
"
)},
}
server_port
:=
raft
.
CLIENT_PORT
+
1
server_port
:=
raft
.
LogPORT
+
1
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
))
...
...
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