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
567b3b54
Commit
567b3b54
authored
Feb 05, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added code to commit acked entry
parent
a40a6241
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
7 deletions
+6
-7
assignment2/replic_kvstore.go
assignment2/replic_kvstore.go
+6
-7
No files found.
assignment2/replic_kvstore.go
View file @
567b3b54
...
...
@@ -75,12 +75,12 @@ func NewRaft(config *ClusterConfig, thisServerId int, commitCh chan LogEntry) (*
}
//goroutine that monitors channel for commiting log entry
func
monitor_commitCh
(
c
<-
chan
LogEntry
)
{
//unidirectional -- can only read from the channel
func
monitor_commitCh
(
raft
*
Raft
,
c
<-
chan
LogEntry
)
{
//unidirectional -- can only read from the channel
for
{
//var temp LogEntry
temp
:=
<-
c
//receive from the channel
temp
.
(
*
LogEntryData
)
.
committed
=
tr
ue
//
now update key value
store here
temp
:=
<-
c
//receive from the channel
raft
.
log_array
[
temp
.
(
*
LogEntryData
)
.
id
]
.
committed
=
true
//commit the val
ue
//
update the kv
store here
}
}
...
...
@@ -89,9 +89,6 @@ func monitor_ackCh(rft *Raft, ack_ch <-chan int, log_entry LogEntry) {
acks_received
:=
0
num_servers
:=
len
(
rft
.
cluster_config
.
Servers
)
required_acks
:=
num_servers
/
2
if
num_servers
%
2
==
0
{
required_acks
++
}
for
{
temp
:=
<-
ack_ch
...
...
@@ -128,6 +125,8 @@ func (raft *Raft) Append(data []byte) (LogEntry, error) {
raft
.
log_array
=
append
(
raft
.
log_array
,
temp
)
ackChan
:=
make
(
chan
int
)
go
monitor_ackCh
(
raft
,
ackChan
,
temp
)
for
_
,
server
:=
range
cluster_config
.
Servers
[
1
:
]
{
go
func
(
ackChan
chan
int
)
{
client
,
err
:=
rpc
.
Dial
(
"tcp"
,
server
.
Hostname
+
":"
+
strconv
.
Itoa
(
server
.
LogPort
))
...
...
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