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
600b6e45
Commit
600b6e45
authored
Feb 04, 2015
by
Harshit Pande
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code to run different servers and server configuration set up
parent
80cc07bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
assignment2/replic_kvstore.go
assignment2/replic_kvstore.go
+47
-0
assignment2/runner.go
assignment2/runner.go
+32
-0
No files found.
assignment2/replic_kvstore.go
0 → 100644
View file @
600b6e45
package
main
import
(
//"log"
//"net"
//"net/rpc"
"fmt"
"os"
"reflect"
"strconv"
)
//constant values used
const
(
CLIENT_PORT
=
9000
)
type
ServerConfig
struct
{
Id
int
// Id of server. Must be unique
Hostname
string
// name or ip of host
ClientPort
int
// port at which server listens to client messages.
LogPort
int
// tcp port for inter-replica protocol messages.
}
type
ClusterConfig
struct
{
Path
string
// Directory for persistent log
Servers
[]
ServerConfig
// All servers in this cluster
}
func
NewServerConfig
(
server_id
int
)
(
*
ServerConfig
,
error
)
{
this_server
:=
new
(
ServerConfig
)
this_server
.
Id
=
server_id
this_server
.
Hostname
=
"127.0.0.1"
this_server
.
ClientPort
=
CLIENT_PORT
this_server
.
LogPort
=
CLIENT_PORT
+
server_id
return
this_server
,
nil
}
func
main
()
{
server_id
,
err
:=
strconv
.
Atoi
(
os
.
Args
[
1
])
if
err
!=
nil
{
fmt
.
Println
(
"argument "
,
os
.
Args
[
1
],
"is not string"
)
}
this_server
,
_
:=
NewServerConfig
(
server_id
)
fmt
.
Println
(
reflect
.
TypeOf
(
this_server
))
}
assignment2/runner.go
0 → 100644
View file @
600b6e45
package
main
import
(
//"os"
"fmt"
//"log"
"os/exec"
"strconv"
//"syscall"
)
//constant values used
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
main
()
{
TestServersCommunic
()
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