-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappB.go
More file actions
84 lines (64 loc) · 1.68 KB
/
Copy pathappB.go
File metadata and controls
84 lines (64 loc) · 1.68 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
/*
Transaction with tables A, B
Delete row in A, add row in B, then join them
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"}
op2 := dbStructs.Operation{
Type: dbStructs.Join,
TableName: "A",
SecondTableName: "B",
FirstTableColumn: "key",
SecondTableColumn: "emp_id"}
newRow2 := map[string]string{"name": "Jim", "age": "50", "gender": "M"}
newRow3 := map[string]string{"company": "Microsoft", "emp_id": "test3"}
op7 := dbStructs.Operation{
Type: dbStructs.Set,
TableName: "A",
Key: "test3",
Value: dbStructs.Row{Key: "test3", Data: newRow2}}
op8 := dbStructs.Operation{
Type: dbStructs.Set,
TableName: "B",
Key: "k3",
Value: dbStructs.Row{Key: "k3", Data: newRow3}}
txn1 := dbStructs.Transaction{Operations: []dbStructs.Operation{op7, op8, op0, op1, op2}}
client.NewTransaction(txn1, shared.CrashPoint(crashPoint))
fmt.Println("Finished Transaction 2")
}