-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.go
More file actions
115 lines (112 loc) · 2.46 KB
/
Copy pathinit.go
File metadata and controls
115 lines (112 loc) · 2.46 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
package main
import (
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Name: "raft",
Usage: "A simple Raft implementation",
Commands: []*cli.Command{
{
Name: "start",
Usage: "Start the Raft node",
Action: func(c *cli.Context) error {
id := c.Int("id")
conf := c.String("conf")
writeBatchSize := c.Int("write-batch-size")
readBatchSize := c.Int("read-batch-size")
debug := c.Bool("debug")
asyncLog := c.Bool("async-log")
r := NewRaft(id, conf, writeBatchSize, readBatchSize, debug, asyncLog)
r.Run()
return nil
},
Flags: []cli.Flag{
&cli.IntFlag{
Name: "id",
Usage: "Node ID",
Required: true,
},
&cli.StringFlag{
Name: "conf",
Usage: "Path to config file",
Value: "cluster.conf",
},
&cli.IntFlag{
Name: "write-batch-size",
Usage: "Raft disk write batch size",
Value: 128,
},
&cli.IntFlag{
Name: "read-batch-size",
Usage: "Raft read batch size",
Value: 128,
},
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug logging",
Value: false,
},
&cli.BoolFlag{
Name: "async-log",
Usage: "Enable asynchronous disk writes",
Value: false,
},
},
},
{
Name: "client",
Usage: "Run the benchmark client",
Action: func(c *cli.Context) error {
conf := c.String("conf")
workers := c.Int("workers")
numKeys := c.Int("keys")
debug := c.Bool("debug")
workload := 50
switch c.String("workload") {
case "ycsb-a":
workload = 50
case "ycsb-b":
workload = 5
case "ycsb-c":
workload = 0
}
client := NewClient(conf, workers, numKeys, workload, debug)
client.Run()
return nil
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "conf",
Usage: "Path to config file",
Value: "cluster.conf",
},
&cli.IntFlag{
Name: "workers",
Usage: "Number of concurrent workers",
Value: 1,
},
&cli.StringFlag{
Name: "workload",
Usage: "Workload type (ycsb-a, ycsb-b, ycsb-c)",
Value: "ycsb-a",
},
&cli.IntFlag{
Name: "keys",
Usage: "Number of keys to use in benchmark",
Value: 6,
},
&cli.BoolFlag{
Name: "debug",
Usage: "Enable debug logging",
Value: false,
},
},
},
},
}
if err := app.Run(os.Args); err != nil {
panic(err)
}
}