@@ -32,6 +32,8 @@ import (
32
32
33
33
const (
34
34
DEFAULT_CONTAINER_IMAGE = "opencurvedocker/curvebs:v1.2"
35
+ FORMAT_TYPE_DATA = "data"
36
+ FORMAT_TYPE_WAL = "wal"
35
37
)
36
38
37
39
/*
@@ -40,14 +42,18 @@ const (
40
42
* - machine2
41
43
* - machine3
42
44
* disk:
43
- * - /dev/sda:/data/chunkserver0:10 # device:mount_path:format_percent
44
- * - /dev/sdb:/data/chunkserver1:10
45
- * - /dev/sdc:/data/chunkserver2:10
45
+ * - data:/dev/sda:/data/chunkserver0:10 # fortmat_type:device:mount_path:format_percent
46
+ * - data:/dev/sdb:/data/chunkserver1:10
47
+ * - data:/dev/sdc:/data/chunkserver2:10
48
+ * - wal:/dev/nvme0n1p1:/data/wal/chunkserver0:10
49
+ * - wal:/dev/nvme0n1p2:/data/wal/chunkserver1:10
50
+ * - wal:/dev/nvme0n1p3:/data/wal/chunkserver2:10
46
51
*/
47
52
type (
48
53
FormatConfig struct {
49
54
ContainerIamge string
50
55
Host string
56
+ Type string
51
57
Device string
52
58
MountPoint string
53
59
FormtPercent int
@@ -64,12 +70,15 @@ type (
64
70
65
71
func NewFormatConfig (containerImage , host , disk string ) (* FormatConfig , error ) {
66
72
items := strings .Split (disk , ":" )
67
- if len (items ) != 3 {
73
+ if len (items ) != 4 {
68
74
return nil , errno .ERR_INVALID_DISK_FORMAT .S (disk )
69
75
}
70
76
71
- device , mountPoint , percent := items [0 ], items [1 ], items [2 ]
72
- if ! strings .HasPrefix (device , "/" ) {
77
+ formatType , device , mountPoint , percent := items [0 ], items [1 ], items [2 ], items [3 ]
78
+ if formatType != FORMAT_TYPE_DATA && formatType != FORMAT_TYPE_WAL {
79
+ return nil , errno .ERR_INVALID_FORMAT_TYPE .
80
+ F ("formatType: %s" , formatType )
81
+ } else if ! strings .HasPrefix (device , "/" ) {
73
82
return nil , errno .ERR_INVALID_DEVICE .
74
83
F ("device: %s" , device )
75
84
} else if ! strings .HasPrefix (mountPoint , "/" ) {
@@ -89,6 +98,7 @@ func NewFormatConfig(containerImage, host, disk string) (*FormatConfig, error) {
89
98
return & FormatConfig {
90
99
ContainerIamge : containerImage ,
91
100
Host : host ,
101
+ Type : formatType ,
92
102
Device : device ,
93
103
MountPoint : mountPoint ,
94
104
FormtPercent : formatPercent ,
@@ -136,6 +146,7 @@ func ParseFormat(filename string) ([]*FormatConfig, error) {
136
146
137
147
func (fc * FormatConfig ) GetContainerImage () string { return fc .ContainerIamge }
138
148
func (fc * FormatConfig ) GetHost () string { return fc .Host }
149
+ func (fc * FormatConfig ) GetFormatType () string { return fc .Type }
139
150
func (fc * FormatConfig ) GetDevice () string { return fc .Device }
140
151
func (fc * FormatConfig ) GetMountPoint () string { return fc .MountPoint }
141
152
func (fc * FormatConfig ) GetFormatPercent () int { return fc .FormtPercent }
0 commit comments