-
Notifications
You must be signed in to change notification settings - Fork 1
/
pbc.go
44 lines (40 loc) · 875 Bytes
/
pbc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
//
// pbservice client application
//
// export GOPATH=~/6.824
// go build viewd.go
// go build pbd.go
// go build pbc.go
// ./viewd /tmp/rtm-v &
// ./pbd /tmp/rtm-v /tmp/rtm-1 &
// ./pbd /tmp/rtm-v /tmp/rtm-2 &
// ./pbc /tmp/rtm-v key1 value1
// ./pbc /tmp/rtm-v key1
//
// change "rtm" to your user name.
// start the pbd programs in separate windows and kill
// and restart them to exercise fault tolerance.
//
import "pbservice"
import "os"
import "fmt"
func usage() {
fmt.Printf("Usage: pbc viewport key\n")
fmt.Printf(" pbc viewport key value\n")
os.Exit(1)
}
func main() {
if len(os.Args) == 3 {
// get
ck := pbservice.MakeClerk(os.Args[1], "")
v := ck.Get(os.Args[2])
fmt.Printf("%v\n", v)
} else if len(os.Args) == 4 {
// put
ck := pbservice.MakeClerk(os.Args[1], "")
ck.Put(os.Args[2], os.Args[3])
} else {
usage()
}
}