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
71bae140
Commit
71bae140
authored
Feb 05, 2015
by
Bharath Radhakrishnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
RPC skeleton
parent
cab533d6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
14 deletions
+45
-14
assignment2/replic_kvstore.go
assignment2/replic_kvstore.go
+34
-5
assignment2/runner.go
assignment2/runner.go
+11
-9
No files found.
assignment2/replic_kvstore.go
View file @
71bae140
package
main
import
(
//"log"
//"net"
//"net/rpc"
"fmt"
"log"
"net"
"net/rpc"
"os"
"reflect"
"strconv"
...
...
@@ -26,7 +26,7 @@ type LogEntry interface {
}
type
LogEntryData
struct
{
id
uint64
id
Lsn
data
[]
byte
committed
bool
}
...
...
@@ -54,7 +54,7 @@ type Raft struct {
var
cluster_config
*
ClusterConfig
//make LogEntryData implement the
func
(
entry
*
LogEntryData
)
Lsn
()
uint64
{
func
(
entry
*
LogEntryData
)
Lsn
()
Lsn
{
return
entry
.
id
}
...
...
@@ -96,6 +96,34 @@ func (e ErrRedirect) Error() string {
return
"Redirect to server "
+
strconv
.
Itoa
(
cluster_config
.
Servers
[
0
]
.
Id
)
}
type
Args
struct
{
X
int
}
type
AppendEntries
struct
{}
func
(
t
*
AppendEntries
)
AppendEntriesRPC
(
args
*
Args
,
reply
*
int
)
error
{
*
reply
=
args
.
X
return
nil
}
func
initializeInterServerCommunication
(
this_server
*
ServerConfig
)
{
appendRpc
:=
new
(
AppendEntries
)
rpc
.
Register
(
appendRpc
)
listener
,
e
:=
net
.
Listen
(
"tcp"
,
":"
+
strconv
.
Itoa
(
this_server
.
LogPort
))
if
e
!=
nil
{
log
.
Fatal
(
"listen error:"
,
e
)
}
for
{
if
conn
,
err
:=
listener
.
Accept
();
err
!=
nil
{
log
.
Fatal
(
"accept error: "
+
err
.
Error
())
}
else
{
log
.
Printf
(
"new connection established
\n
"
)
go
rpc
.
ServeConn
(
conn
)
}
}
}
func
main
()
{
server_id
,
err
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
if
err
!=
nil
{
...
...
@@ -111,4 +139,5 @@ func main() {
fmt
.
Println
(
reflect
.
TypeOf
(
this_server
))
fmt
.
Println
(
reflect
.
TypeOf
(
cluster_config
))
initializeInterServerCommunication
(
this_server
)
}
assignment2/runner.go
View file @
71bae140
...
...
@@ -14,19 +14,21 @@ const (
NUM_SERVERS
int
=
5
)
func
TestServersCommunic
()
{
for
i
:=
0
;
i
<
NUM_SERVERS
;
i
++
{
cmd
:=
exec
.
Command
(
"go"
,
"run"
,
"replic_kvstore.go"
,
strconv
.
Itoa
(
i
+
1
),
strconv
.
Itoa
(
NUM_SERVERS
))
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
fmt
.
Println
(
string
(
out
))
func
TestServersCommunic
(
i
int
)
{
cmd
:=
exec
.
Command
(
"go"
,
"run"
,
"replic_kvstore.go"
,
strconv
.
Itoa
(
i
+
1
),
strconv
.
Itoa
(
NUM_SERVERS
))
out
,
err
:=
cmd
.
CombinedOutput
()
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
fmt
.
Println
(
string
(
out
))
}
func
main
()
{
TestServersCommunic
()
for
i
:=
0
;
i
<
NUM_SERVERS
;
i
++
{
go
TestServersCommunic
(
i
)
}
var
dummy_input
string
fmt
.
Scanln
(
&
dummy_input
)
}
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