@@ -32,6 +32,8 @@ import (
3232
3333const  (
3434	DEFAULT_CONTAINER_IMAGE  =  "opencurvedocker/curvebs:v1.2" 
35+ 	FORMAT_TYPE_DATA         =  "data" 
36+ 	FORMAT_TYPE_WAL          =  "wal" 
3537)
3638
3739/* 
@@ -40,14 +42,18 @@ const (
4042 *   - machine2 
4143 *   - machine3 
4244 * 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 
4651 */ 
4752type  (
4853	FormatConfig  struct  {
4954		ContainerIamge      string 
5055		Host                string 
56+ 		Type                string 
5157		Device              string 
5258		MountPoint          string 
5359		FormtPercent        int 
@@ -64,12 +70,15 @@ type (
6470
6571func  NewFormatConfig (containerImage , host , disk  string ) (* FormatConfig , error ) {
6672	items  :=  strings .Split (disk , ":" )
67- 	if  len (items ) !=  3  {
73+ 	if  len (items ) !=  4  {
6874		return  nil , errno .ERR_INVALID_DISK_FORMAT .S (disk )
6975	}
7076
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 , "/" ) {
7382		return  nil , errno .ERR_INVALID_DEVICE .
7483			F ("device: %s" , device )
7584	} else  if  ! strings .HasPrefix (mountPoint , "/" ) {
@@ -89,6 +98,7 @@ func NewFormatConfig(containerImage, host, disk string) (*FormatConfig, error) {
8998	return  & FormatConfig {
9099		ContainerIamge : containerImage ,
91100		Host :           host ,
101+ 		Type :           formatType ,
92102		Device :         device ,
93103		MountPoint :     mountPoint ,
94104		FormtPercent :   formatPercent ,
@@ -136,6 +146,7 @@ func ParseFormat(filename string) ([]*FormatConfig, error) {
136146
137147func  (fc  * FormatConfig ) GetContainerImage () string  { return  fc .ContainerIamge  }
138148func  (fc  * FormatConfig ) GetHost () string            { return  fc .Host  }
149+ func  (fc  * FormatConfig ) GetFormatType () string      { return  fc .Type  }
139150func  (fc  * FormatConfig ) GetDevice () string          { return  fc .Device  }
140151func  (fc  * FormatConfig ) GetMountPoint () string      { return  fc .MountPoint  }
141152func  (fc  * FormatConfig ) GetFormatPercent () int      { return  fc .FormtPercent  }
0 commit comments