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
79fb8fc8
Commit
79fb8fc8
authored
Feb 04, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed redirect error
parent
a8826caf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
assignment2/replic_kvstore.go
assignment2/replic_kvstore.go
+9
-8
No files found.
assignment2/replic_kvstore.go
View file @
79fb8fc8
...
@@ -51,8 +51,7 @@ type Raft struct {
...
@@ -51,8 +51,7 @@ type Raft struct {
//some good stuff needs to go here
//some good stuff needs to go here
commitCh
chan
*
LogEntryData
commitCh
chan
*
LogEntryData
cluster
*
ClusterConfig
//cluster
cluster
*
ClusterConfig
//cluster
id
uint64
//leader
id
uint64
//current server id
commitCh
chan
LogEntry
}
}
var
cluster_config
*
ClusterConfig
var
cluster_config
*
ClusterConfig
...
@@ -63,7 +62,6 @@ func monitor_commitCh(c <-chan *LogEntryData) { //unidirectional -- can only rea
...
@@ -63,7 +62,6 @@ func monitor_commitCh(c <-chan *LogEntryData) { //unidirectional -- can only rea
var
temp
*
LogEntryData
var
temp
*
LogEntryData
temp
=
<-
c
//receive from the channel
temp
=
<-
c
//receive from the channel
temp
.
committed
=
true
temp
.
committed
=
true
//now update key value store here
//now update key value store here
}
}
}
}
...
@@ -83,17 +81,20 @@ func (entry *LogEntryData) Committed() bool {
...
@@ -83,17 +81,20 @@ func (entry *LogEntryData) Committed() bool {
//make raft implement the append function
//make raft implement the append function
func
(
raft
*
Raft
)
Append
(
data
[]
byte
)
(
LogEntry
,
error
)
{
func
(
raft
*
Raft
)
Append
(
data
[]
byte
)
(
LogEntry
,
error
)
{
if
raft
.
server
.
I
d
!=
0
{
if
raft
.
i
d
!=
0
{
return
nil
,
raft
.
Id
return
nil
,
ErrRedirect
(
0
)
}
}
temp
:=
LogEntry
{
1
,
data
,
false
}
temp
:=
&
LogEntryData
{
1
,
data
,
false
}
//broadcast to other servers
//broadcast to other servers
//wait for acks
//wait for acks
//send commit on channel
//send commit on channel
raft
.
commitCh
<-
temp
raft
.
commitCh
<-
temp
return
temp
,
nil
}
}
func
AppendEntriesRPC
()
func
AppendEntriesRPC
()
{
}
func
NewServerConfig
(
server_id
int
)
(
*
ServerConfig
,
error
)
{
func
NewServerConfig
(
server_id
int
)
(
*
ServerConfig
,
error
)
{
server
:=
new
(
ServerConfig
)
server
:=
new
(
ServerConfig
)
...
@@ -118,7 +119,7 @@ func NewClusterConfig(num_servers int) (*ClusterConfig, error) {
...
@@ -118,7 +119,7 @@ func NewClusterConfig(num_servers int) (*ClusterConfig, error) {
}
}
func
(
e
ErrRedirect
)
Error
()
string
{
func
(
e
ErrRedirect
)
Error
()
string
{
return
"Redirect to server "
+
strconv
.
Itoa
(
cluster_config
.
Servers
[
0
]
.
Id
)
return
"Redirect to server "
+
strconv
.
Itoa
(
0
)
}
}
func
main
()
{
func
main
()
{
...
...
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