-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappC.go
More file actions
71 lines (56 loc) · 1.33 KB
/
Copy pathappC.go
File metadata and controls
71 lines (56 loc) · 1.33 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
/*
Transaction with table C
Add row in C, then SelectAll
Usage:
In another terminal:
go run lbs.go 0.0.0.0:9990
In another terminal:
go run server.go 0.0.0.0:9991 0.0.0.0:9990
In this terminal
go run app.go
*/
package main
import (
"./client"
"./dbStructs"
"./shared"
"fmt"
"os"
"strconv"
"time"
)
func main() {
// TODO provide as cmd arguments
if len(os.Args[1:]) < 2 {
panic("Incorrect number of arguments given")
}
lbsAddr := os.Args[1]
localIP := os.Args[2]
crashPointArg := os.Args[3]
crashPoint, _ := strconv.Atoi(crashPointArg)
_, err := client.StartClient(lbsAddr, localIP)
if shared.CheckError(err) != nil {
fmt.Println(err)
return
}
time.Sleep(time.Second * 1)
//op0 := dbStructs.Operation{
// Type: dbStructs.SelectAll,
// TableName: "A"}
//
//op1 := dbStructs.Operation{
// Type: dbStructs.SelectAll,
// TableName: "B"}
newRow := map[string]string{"tv_show": "The Office"}
op9 := dbStructs.Operation{
Type: dbStructs.Set,
TableName: "C",
Key: "newRow",
Value: dbStructs.Row{Key: "newRow", Data: newRow}}
op10 := dbStructs.Operation{
Type: dbStructs.SelectAll,
TableName: "C"}
txn2 := dbStructs.Transaction{Operations: []dbStructs.Operation{op9, op10}}
client.NewTransaction(txn2, shared.CrashPoint(crashPoint))
fmt.Println("Finished Transaction 3")
}