-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestLBS.go
More file actions
143 lines (121 loc) · 3.99 KB
/
Copy pathtestLBS.go
File metadata and controls
143 lines (121 loc) · 3.99 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
package main
import (
"os"
"net/rpc"
"fmt"
"./shared"
"github.com/DistributedClocks/GoVector/govec"
)
func main() {
lbsAddr := os.Args[1]
c, err := rpc.Dial("tcp", lbsAddr)
shared.CheckError(err)
Logger := govec.InitGoVector("testLBS", "ddbsTestLBS")
var reply shared.TableNamesReply
var buf []byte
var msg string
buf = Logger.PrepareSend("Sending LBS.AddMappings", "msg")
args := shared.TableNamesArg{
ServerIpAddress: "127.0.0.1",
TableNames: []string{"A", "B", "C"},
GoVector: buf,
}
err = c.Call("LBS.AddMappings", &args, &reply)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.AddMappings", reply.GoVector, &msg)
buf = Logger.PrepareSend("Sending LBS.AddMappings", "msg")
args2 := shared.TableNamesArg{
ServerIpAddress: "127.0.0.2",
TableNames: []string{"B", "C", "D"},
GoVector: buf,
}
err = c.Call("LBS.AddMappings", &args2, &reply)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.AddMappings", reply.GoVector, &msg)
var servers shared.ServerPeers
buf = Logger.PrepareSend("Sending LBS.GetPeers", "msg")
args3 := shared.TableNamesArg{
ServerIpAddress: "127.0.0.3",
TableNames: []string{"A", "B", "C", "D"},
GoVector: buf,
}
err = c.Call("LBS.GetPeers", &args3, &servers)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.GetPeers", servers.GoVector, &msg)
for tableName, listOfIps := range servers.Servers {
fmt.Println("LBS.GetPeers table=", tableName, "ips=", listOfIps)
}
buf = Logger.PrepareSend("Sending LBS.GetServers", "msg")
args4 := shared.TableNamesArg{
TableNames: []string{"A", "B", "C", "D"},
GoVector: buf,
}
err = c.Call("LBS.GetServers", &args4, &reply)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.GetServers", reply.GoVector, &msg)
for tableName, ip := range reply.TableNameToServers {
fmt.Println("LBS.GetServers table=", tableName, "ip=", ip)
}
buf = Logger.PrepareSend("Sending LBS.RemoveMappings", "msg")
args5 := shared.TableNamesArg{
ServerIpAddress: "127.0.0.2",
GoVector: buf,
}
err = c.Call("LBS.RemoveMappings", &args5, &reply)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.RemoveMappings", reply.GoVector, &msg)
fmt.Println("AFTER REMOVING:")
var servers2 shared.ServerPeers
buf = Logger.PrepareSend("Sending LBS.GetPeers", "msg")
args6 := shared.TableNamesArg{
ServerIpAddress: "127.0.0.3",
TableNames: []string{"A", "B", "C", "D"},
GoVector: buf,
}
err = c.Call("LBS.GetPeers", &args6, &servers2)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.GetPeers", servers2.GoVector, &msg)
for tableName, listOfIps := range servers2.Servers {
fmt.Println("LBS.GetPeers table=", tableName, "ips=", listOfIps)
}
var reply2 shared.TableNamesReply
buf = Logger.PrepareSend("Sending LBS.GetServers", "msg")
args7 := shared.TableNamesArg{
TableNames: []string{"A", "B", "C"},
GoVector: buf,
}
err = c.Call("LBS.GetServers", &args7, &reply2)
shared.CheckError(err)
Logger.UnpackReceive("Received LBS.GetServers", reply2.GoVector, &msg)
for tableName, ip := range reply2.TableNameToServers {
fmt.Println("LBS.GetServers table=", tableName, "ip=", ip)
}
//args8 := shared.TableNamesArg{
// ServerIpAddress: "127.0.0.3",
// TableNames: []string{"A", "B", "C", "D"},
//}
//err = c.Call("LBS.GetPeers", &args8, &servers)
//CheckError(err)
//
//for tableName, listOfIps := range servers.Servers {
// err, ips := keysToArray(listOfIps)
// CheckError(err)
// fmt.Println("LBS.GetPeers table=", tableName, "ips=", ips)
//}
var reply3 shared.TableNamesReply
buf = Logger.PrepareSend("Sending LBS.GetServers", "msg")
args9 := shared.TableNamesArg{
TableNames: []string{"A", "B", "C", "D"},
GoVector: buf,
}
err = c.Call("LBS.GetServers", &args9, &reply3)
shared.CheckError(err)
if err == nil {
Logger.UnpackReceive("Received LBS.GetServers", reply3.GoVector, &msg)
for tableName, ip := range reply3.TableNameToServers {
fmt.Println("LBS.GetServers table=", tableName, "ip=", ip)
}
} else {
Logger.LogLocalEvent("Not received LBS.GetServers")
}
}