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
ce3f113b
Commit
ce3f113b
authored
Feb 09, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some logging at important locations
parent
9493496f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
10 deletions
+8
-10
assignment2/src/connhandler/connhandler.go
assignment2/src/connhandler/connhandler.go
+4
-3
assignment2/src/raft/raft.go
assignment2/src/raft/raft.go
+1
-1
assignment2/src/server.go
assignment2/src/server.go
+3
-6
No files found.
assignment2/src/connhandler/connhandler.go
View file @
ce3f113b
...
...
@@ -18,7 +18,7 @@ import (
*parameters: channel to read data from, threshold number of bytes to read
*returns: the value string and error state
*/
func
readValue
(
ch
chan
[]
byte
,
n
uint64
)
([]
byte
,
bool
)
{
func
readValue
(
ch
chan
[]
byte
,
n
uint64
,
logger
*
log
.
Logger
)
([]
byte
,
bool
)
{
//now we need to read the value which should have been sent
valReadLength
:=
uint64
(
0
)
var
v
[]
byte
...
...
@@ -48,6 +48,7 @@ func readValue(ch chan []byte, n uint64) ([]byte, bool) {
//will be true if timeout occurs
if
err
{
logger
.
Println
(
"Timeout"
)
break
}
}
...
...
@@ -126,7 +127,7 @@ func HandleClient(conn net.Conn, rft *raft.Raft, logger *log.Logger) {
for
{
command
:=
new
(
utils
.
Command
)
msg
:=
<-
ch
logger
.
Println
(
"got:"
,
msg
)
logger
.
Println
(
"got:"
,
msg
,
string
(
msg
)
)
if
len
(
msg
)
==
0
{
continue
...
...
@@ -146,7 +147,7 @@ func HandleClient(conn net.Conn, rft *raft.Raft, logger *log.Logger) {
}
if
flag
{
logger
.
Println
(
"numbytes"
,
nr
)
if
v
,
err
:=
readValue
(
ch
,
nr
);
err
{
if
v
,
err
:=
readValue
(
ch
,
nr
,
logger
);
err
{
logger
.
Println
(
"error reading value"
)
Write
(
conn
,
"ERR_CMD_ERR"
)
continue
...
...
assignment2/src/raft/raft.go
View file @
ce3f113b
...
...
@@ -154,7 +154,7 @@ func (rft *Raft) Append(data []byte, conn net.Conn) (LogEntry, error) {
Info
.
Fatal
(
"Dialing:"
,
err
)
}
reply
:=
new
(
Reply
)
args
:=
&
Args
{
7
}
args
:=
temp
appendCall
:=
client
.
Go
(
"AppendEntries.AppendEntriesRPC"
,
args
,
reply
,
nil
)
//let go allocate done channel
appendCall
=
<-
appendCall
.
Done
ackChan
<-
reply
.
X
...
...
assignment2/src/server.go
View file @
ce3f113b
...
...
@@ -20,16 +20,13 @@ var DEBUG = true
type
AppendEntries
struct
{}
type
Args
struct
{
X
int
}
type
Reply
struct
{
X
int
}
func
(
t
*
AppendEntries
)
AppendEntriesRPC
(
args
*
Args
,
reply
*
Reply
)
error
{
reply
.
X
=
args
.
X
func
(
t
*
AppendEntries
)
AppendEntriesRPC
(
args
*
raft
.
LogEntry
,
reply
*
Reply
)
error
{
Info
.
Println
(
"RPC invoked"
)
reply
.
X
=
1
return
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