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
e6e02994
Commit
e6e02994
authored
Apr 18, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove useless RPCs, use reply for further communication
parent
f18eef0f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
156 additions
and
178 deletions
+156
-178
assignment4/src/raft/raft.go
assignment4/src/raft/raft.go
+130
-154
assignment4/src/server.go
assignment4/src/server.go
+26
-24
No files found.
assignment4/src/raft/raft.go
View file @
e6e02994
This diff is collapsed.
Click to expand it.
assignment4/src/server.go
View file @
e6e02994
...
...
@@ -73,27 +73,27 @@ type Reply struct {
//arguments: pointer to argument struct (has LogEntryData), pointer to reply struct
//returns: error
//receiver: pointer to AppendEntries
func
(
t
*
RaftRPCService
)
AppendRPC
(
args
*
raft
.
AppendRPC
,
reply
*
Reply
)
error
{
func
(
t
*
RaftRPCService
)
AppendRPC
(
args
*
raft
.
AppendRPC
,
reply
*
raft
.
Append
Reply
)
error
{
Info
.
Println
(
"append RPC invoked"
)
rft
.
AddToEventChannel
(
args
)
reply
.
X
=
1
temp
:=
rft
.
FetchAppendReply
()
.
(
*
raft
.
AppendReply
)
reply
.
CurrentTerm
=
temp
.
CurrentTerm
reply
.
Reply
=
temp
.
Reply
reply
.
Fid
=
temp
.
Fid
reply
.
LogLength
=
temp
.
LogLength
return
nil
/*Info.Println("Append Entries RPC invoked", (*args).GetLsn(), (*args).GetData(), (*args).GetCommitted())
rft.LogArray = append(rft.LogArray, raft.NewLogEntry((*args).GetData(), (*args).GetCommitted(), nil))
reply.X = 1
return nil*/
}
func
(
t
*
RaftRPCService
)
AppendReplyRPC
(
args
*
raft
.
AppendReply
,
reply
*
Reply
)
error
{
Info
.
Println
(
"append reply to leader RPC invoked"
)
rft
.
AddToEventChannel
(
args
)
reply
.
X
=
1
return
nil
/*Info.Println("Append Entries RPC invoked", (*args).GetLsn(), (*args).GetData(), (*args).GetCommitted())
rft.LogArray = append(rft.LogArray, raft.NewLogEntry((*args).GetData(), (*args).GetCommitted(), nil))
reply.X = 1
return nil*/
}
//
func (t *RaftRPCService) AppendReplyRPC(args *raft.AppendReply, reply *Reply) error {
//
Info.Println("append reply to leader RPC invoked")
//
rft.AddToEventChannel(args)
//
reply.X = 1
//
return nil
//
/*Info.Println("Append Entries RPC invoked", (*args).GetLsn(), (*args).GetData(), (*args).GetCommitted())
//
rft.LogArray = append(rft.LogArray, raft.NewLogEntry((*args).GetData(), (*args).GetCommitted(), nil))
//
reply.X = 1
//
return nil*/
//
}
//RPC for follower server. To let followers know that and entry can be committed.
//arguments: pointer to argument struct (has LogEntry), pointer to reply struct
...
...
@@ -107,19 +107,21 @@ func (t *RaftRPCService) CommitRPC(args *raft.CommitData, reply *Reply) error {
return
nil
}
func
(
t
*
RaftRPCService
)
VoteRequestRPC
(
args
*
raft
.
VoteRequest
,
reply
*
Reply
)
error
{
func
(
t
*
RaftRPCService
)
VoteRequestRPC
(
args
*
raft
.
VoteRequest
,
reply
*
raft
.
VoteRequest
Reply
)
error
{
Info
.
Println
(
"Request Vote RPC received"
)
rft
.
AddToEventChannel
(
args
)
reply
.
X
=
1
temp
:=
rft
.
FetchVoteReply
()
.
(
*
raft
.
VoteRequestReply
)
reply
.
CurrentTerm
=
temp
.
CurrentTerm
reply
.
Reply
=
temp
.
Reply
return
nil
}
func
(
t
*
RaftRPCService
)
CastVoteRPC
(
args
*
raft
.
VoteRequestReply
,
reply
*
Reply
)
error
{
Info
.
Println
(
"Cast Vote RPC received"
)
rft
.
AddToMonitorVotesChannel
(
args
)
reply
.
X
=
1
return
nil
}
//
func (t *RaftRPCService) CastVoteRPC(args *raft.VoteRequestReply, reply *Reply) error {
//
Info.Println("Cast Vote RPC received")
//
rft.AddToMonitorVotesChannel(args)
//
reply.X = 1
//
return nil
//
}
//Initialize all the things necessary for start the server for inter raft communication.
//The servers are running on ports 20000+serverId. {0..4}
...
...
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