-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
95 lines (73 loc) · 1.89 KB
/
Copy pathmain.go
File metadata and controls
95 lines (73 loc) · 1.89 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
package main
import (
"context"
"fmt"
"io/ioutil"
"github.com/sevico/filecoinfs-iotools/model"
"github.com/sevico/filecoinfs-iotools/statics"
"github.com/sevico/filecoinfs-iotools/util"
logs "log"
"os"
"path"
"github.com/thecodeteam/goodbye"
"gopkg.in/yaml.v2"
)
var cnf model.Config
func InitConfig(dir string) bool {
configFullName := path.Join(util.GetCwd(), fmt.Sprintf("%s/%s", dir, "config.yaml"))
logs.Printf("【INIT_CONFIG】Use config [%s]", configFullName)
data, err := ioutil.ReadFile(configFullName)
if err != nil {
logs.Fatalf("【INIT_CONFIG】Read config error %v\n", err)
panic(err)
}
if err = yaml.Unmarshal(data, &cnf); err != nil {
logs.Fatalf("【INIT_CONFIG】Unmarshal conf yaml error %v\n", err)
panic(err)
}
logs.Printf("【INIT_CONFIG】Config InitConfig successfully.")
return true
}
func init() {
logs.SetFlags(logs.LstdFlags | logs.Lshortfile)
InitConfig("conf")
HDDChunkSize = cnf.SizeArgs.HDDChunk * 1024 * 1024
SSDChunkSize = cnf.SizeArgs.SSDChunk * 1024
}
func removeNameFiles() {
nameFiles := getNameFiles()
for _, fileName := range nameFiles {
os.Remove(path.Join(cnf.FSPath, fileName))
}
}
func main() {
ctx := context.Background()
defer goodbye.Exit(ctx, -1)
goodbye.Notify(ctx)
go statics.WriteToLog(cnf.DebugLog, cnf.TimeArgs.Samples)
if cnf.SubPathMode {
subDirName, _ = os.Hostname()
}
removeNameFiles()
//conf
if cnf.CleanUp {
os.RemoveAll(cnf.FSPath)
} else {
RecoverGenStatus()
}
os.MkdirAll(path.Join(cnf.FSPath, subDirName, cnf.NameArgs.HDDDirName), os.ModePerm)
os.MkdirAll(path.Join(cnf.FSPath, subDirName, cnf.NameArgs.SSDDirName), os.ModePerm)
for i := 0; i < cnf.TimeArgs.NameRountines; i++ {
go genFile()
}
for i := 0; i < cnf.TimeArgs.GenFileRoutines; i++ {
go genFileName()
}
c.L.Lock()
for int(finishCount) <= cnf.TimeArgs.Threshold+20 {
c.Wait()
}
c.L.Unlock()
RandomReads()
select {}
}