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
89a62c9d
Commit
89a62c9d
authored
Feb 09, 2015
by
Sushant Mahajan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified logentry struct and sharedlog interface
parent
e36c6dbe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
13 deletions
+8
-13
assignment2/src/connhandler/connhandler.go
assignment2/src/connhandler/connhandler.go
+1
-10
assignment2/src/raft/kvstore.go
assignment2/src/raft/kvstore.go
+2
-2
assignment2/src/raft/raft.go
assignment2/src/raft/raft.go
+3
-1
assignment2/src/server.go
assignment2/src/server.go
+2
-0
No files found.
assignment2/src/connhandler/connhandler.go
View file @
89a62c9d
...
...
@@ -116,20 +116,11 @@ func Write(conn net.Conn, msg string) {
conn
.
Write
(
buf
)
}
func
ReplyToClient
(
conn
net
.
Conn
,
writeCh
chan
[]
byte
)
{
for
{
w
:=
<-
writeCh
Write
(
conn
,
string
(
w
))
}
}
func
HandleClient
(
conn
net
.
Conn
,
rft
*
raft
.
Raft
)
{
defer
conn
.
Close
()
//channel for every connection for every client
ch
:=
make
(
chan
[]
byte
)
writeCh
:=
make
(
chan
[]
byte
)
go
MyRead
(
ch
,
conn
)
go
ReplyToClient
(
conn
,
writeCh
)
for
{
command
:=
new
(
utils
.
Command
)
...
...
@@ -167,6 +158,6 @@ func HandleClient(conn net.Conn, rft *raft.Raft) {
//log.Fatal("encode error:", err)
}
rft
.
Append
(
buffer
.
Bytes
()
,
writeCh
)
rft
.
Append
(
buffer
.
Bytes
())
}
}
assignment2/src/raft/kvstore.go
View file @
89a62c9d
...
...
@@ -523,9 +523,9 @@ func InitKVStore() {
table
=
&
KeyValueStore
{
dictionary
:
make
(
map
[
string
]
*
Data
)}
}
func
MonitorCommitChannel
(
ch
chan
LogEntry
,
conn
)
{
func
MonitorCommitChannel
(
ch
chan
LogEntry
)
{
for
{
//do some shit
temp
:=
<-
ch
}
}
...
...
assignment2/src/raft/raft.go
View file @
89a62c9d
...
...
@@ -57,6 +57,7 @@ type LogEntryData struct {
id
Lsn
data
[]
byte
committed
bool
conn
net
.
Conn
}
type
Args
struct
{
...
...
@@ -128,7 +129,7 @@ func (entry *LogEntryData) Committed() bool {
}
//make raft implement the append function
func
(
rft
*
Raft
)
Append
(
data
[]
byte
,
writeCh
chan
[]
byte
)
(
LogEntry
,
error
)
{
func
(
rft
*
Raft
)
Append
(
data
[]
byte
,
conn
net
.
Conn
)
(
LogEntry
,
error
)
{
if
rft
.
id
!=
1
{
return
nil
,
ErrRedirect
(
1
)
}
...
...
@@ -136,6 +137,7 @@ func (rft *Raft) Append(data []byte, writeCh chan []byte) (LogEntry, error) {
temp
.
id
=
1
temp
.
committed
=
false
temp
.
data
=
data
temp
.
conn
=
conn
rft
.
log_array
=
append
(
rft
.
log_array
,
temp
)
ackChan
:=
make
(
chan
int
)
...
...
assignment2/src/server.go
View file @
89a62c9d
...
...
@@ -101,7 +101,9 @@ func main() {
commitCh
:=
make
(
chan
raft
.
LogEntry
)
rft
,
_
:=
raft
.
NewRaft
(
clusterConfig
,
sid
,
commitCh
)
raft
.
InitKVStore
()
go
raft
.
MonitorCommitChannel
(
commitCh
)
go
initClientCommunication
(
server
,
rft
,
ch1
)
go
initInterServerCommunication
(
server
,
rft
,
ch2
)
...
...
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