Skip to content

Commit 4e73df5

Browse files
Cyber-SiKuwu-hanqing
authored andcommitted
[feat]tools-v2: add space
1. fix README.md 2. add bs list space 3 fix some error in bs list logicalpool Signed-off-by: Cyber-SiKu <[email protected]>
1 parent 46269a9 commit 4e73df5

File tree

9 files changed

+538
-109
lines changed

9 files changed

+538
-109
lines changed

tools-v2/README.md

Lines changed: 193 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,22 @@ A tool for CurveFS & CurveBs.
4747
- [list server](#list-server)
4848
- [list client](#list-client)
4949
- [list dir](#list-dir)
50+
- [list space](#list-space)
5051
- [query](#query-1)
5152
- [query file](#query-file)
53+
- [query chunk](#query-chunk)
54+
- [query segment](#query-segment)
5255
- [status](#status-1)
5356
- [staus etcd](#staus-etcd)
5457
- [staus mds](#staus-mds)
5558
- [delete](#delete-1)
5659
- [delete peer](#delete-peer)
5760
- [update](#update)
5861
- [update peer](#update-peer)
62+
- [update file](#update-file)
63+
- [create](#create-1)
64+
- [create file](#create-file)
65+
- [create dir](#create-dir)
5966
- [Comparison of old and new commands](#comparison-of-old-and-new-commands)
6067
- [curve fs](#curve-fs)
6168
- [curve bs](#curve-bs)
@@ -884,6 +891,26 @@ Output:
884891
+------+-------------+----------+-----------------+------------+---------------------+---------------+-------------+
885892
```
886893

894+
##### list space
895+
896+
show curvebs all disk type space, include total space and used space
897+
898+
```bash
899+
curve bs list space
900+
```
901+
902+
Output:
903+
904+
```bash
905+
+----------+---------+---------+---------+------------+---------+
906+
| TYPE | TOTAL | USED | LEFT | RECYCLABLE | CREATED |
907+
+----------+---------+---------+---------+------------+---------+
908+
| physical | *** GiB | *** GiB | *** GiB | - | - |
909+
+----------+---------+---------+---------+------------+---------+
910+
| logical | *** GiB | *** GiB | *** GiB | *** GiB | *** GiB |
911+
+----------+---------+---------+---------+------------+---------+
912+
```
913+
887914
### query
888915

889916
##### query file
@@ -909,6 +936,56 @@ Output:
909936
+------+------+----------------+-------+--------+---------+--------+-----+---------------------+--------------+---------+-----------------+----------+
910937
```
911938

939+
##### query chunk
940+
941+
query the location of the chunk corresponding to the offset
942+
943+
Usage:
944+
945+
```bash
946+
curve bs query chunk --path /test1 --offset 1008600000
947+
```
948+
949+
Output:
950+
951+
```bash
952+
+-------+-------------+---------+------------+----------------------+
953+
| CHUNK | LOGICALPOOL | COPYSET | GROUP | LOCATION |
954+
+-------+-------------+---------+------------+----------------------+
955+
| 61 | 1 | 61 | 4294967357 | ***.***.***.***:**** |
956+
| | | | | ***.***.***.***:**** |
957+
| | | | | ***.***.***.***:**** |
958+
+-------+-------------+---------+------------+----------------------+
959+
```
960+
961+
##### query segment
962+
963+
query the segments info of the file
964+
965+
Usage:
966+
967+
```bash
968+
curve bs query seginfo --path /test1
969+
```
970+
971+
Output:
972+
973+
```bash
974+
+-------------+-------------+-----------+------------+---------+-------+
975+
| LOGICALPOOL | SEGMENTSIZE | CHUNKSIZE | START | COPYSET | CHUNK |
976+
+-------------+-------------+-----------+------------+---------+-------+
977+
| 1 | 1073741824 | 16777216 | 0 | 1 | 1 |
978+
+ + + + +---------+-------+
979+
| ...... |
980+
+ + + +------------+---------+-------+
981+
| | | | 9663676416 | 1 | 101 |
982+
+ + + + +---------+-------+
983+
| ...... |
984+
+ + + + +---------+-------+
985+
| | | | | 99 | 99 |
986+
+-------------+-------------+-----------+------------+---------+-------+
987+
```
988+
912989
### status
913990

914991
#### staus etcd
@@ -1003,71 +1080,127 @@ Output:
10031080
+----------------------+---------+---------+--------+
10041081
```
10051082

1083+
#### update file
1084+
1085+
expand pagefile
1086+
1087+
Usage:
1088+
```bash
1089+
curve bs update file --path /test2/test1 --size 10
1090+
```
1091+
1092+
Output:
1093+
```
1094+
+---------+
1095+
| RESULT |
1096+
+---------+
1097+
| success |
1098+
+---------+
1099+
```
1100+
1101+
### create
1102+
1103+
#### create file
1104+
1105+
create pagefile
1106+
1107+
Usage:
1108+
```bash
1109+
curve bs create file --path /test2/test4 --size 10GiB
1110+
```
1111+
1112+
Output:
1113+
```
1114+
+---------+
1115+
| RESULT |
1116+
+---------+
1117+
| success |
1118+
+---------+
1119+
```
1120+
1121+
#### create dir
1122+
1123+
create directory
1124+
1125+
Usage:
1126+
```bash
1127+
curve bs create dir --path /test2/test5
1128+
```
1129+
1130+
Output:
1131+
```
1132+
+---------+
1133+
| RESULT |
1134+
+---------+
1135+
| success |
1136+
+---------+
1137+
```
1138+
10061139
## Comparison of old and new commands
10071140

10081141
### curve fs
10091142

1010-
| old | new |
1011-
| ---- | ---- |
1012-
| curvefs_tool check-copyset | curve fs check copyset |
1013-
| curvefs_tool create-fs | curve fs create fs |
1014-
| curvefs_tool create-topology | curve fs create topology |
1015-
| curvefs_tool delete-fs | curve fs delete fs |
1016-
| curvefs_tool list-copyset | curve fs list copyset |
1017-
| curvefs_tool list-fs | curve fs list fs |
1018-
| curvefs_tool list-fs | curve fs list mountpoint |
1019-
| curvefs_tool list-partition | curve fs list partition |
1020-
| curvefs_tool query-copyset | curve fs query copyset |
1021-
| curvefs_tool query-fs | curve fs query fs |
1022-
| curvefs_tool query-inode | curve fs query inode |
1023-
| curvefs_tool query-metaserver | curve fs query metaserver |
1024-
| curvefs_tool query-partition | curve fs query partition |
1025-
| curvefs_tool status-mds | curve fs status mds |
1026-
| curvefs_tool status-metaserver | curve fs status metaserver |
1027-
| curvefs_tool status-etcd | curve fs status etcd |
1028-
| curvefs_tool status-copyset | curve fs status copyset |
1029-
| curvefs_tool status-cluster | curve fs status cluster |
1030-
| curvefs_tool umount-fs | curve fs umount fs |
1031-
| curvefs_tool usage-inode | curve fs usage inode |
1032-
| curvefs_tool usage-metadata | curve fs usage metadata |
1143+
| old | new |
1144+
| ------------------------------ | -------------------------- |
1145+
| curvefs_tool check-copyset | curve fs check copyset |
1146+
| curvefs_tool create-fs | curve fs create fs |
1147+
| curvefs_tool create-topology | curve fs create topology |
1148+
| curvefs_tool delete-fs | curve fs delete fs |
1149+
| curvefs_tool list-copyset | curve fs list copyset |
1150+
| curvefs_tool list-fs | curve fs list fs |
1151+
| curvefs_tool list-fs | curve fs list mountpoint |
1152+
| curvefs_tool list-partition | curve fs list partition |
1153+
| curvefs_tool query-copyset | curve fs query copyset |
1154+
| curvefs_tool query-fs | curve fs query fs |
1155+
| curvefs_tool query-inode | curve fs query inode |
1156+
| curvefs_tool query-metaserver | curve fs query metaserver |
1157+
| curvefs_tool query-partition | curve fs query partition |
1158+
| curvefs_tool status-mds | curve fs status mds |
1159+
| curvefs_tool status-metaserver | curve fs status metaserver |
1160+
| curvefs_tool status-etcd | curve fs status etcd |
1161+
| curvefs_tool status-copyset | curve fs status copyset |
1162+
| curvefs_tool status-cluster | curve fs status cluster |
1163+
| curvefs_tool umount-fs | curve fs umount fs |
1164+
| curvefs_tool usage-inode | curve fs usage inode |
1165+
| curvefs_tool usage-metadata | curve fs usage metadata |
10331166

10341167
### curve bs
10351168

1036-
| old | new |
1037-
| ---- | ---- |
1169+
| old | new |
1170+
| -------------------------------- | -------------------------- |
10381171
| curve_ops_tool logical-pool-list | curve bs list logical-pool |
1039-
| curve_ops_tool get -fileName= | curve bs query file -path |
1040-
| curve_ops_tool etcd-status | curve bs status etcd |
1041-
| curve_ops_tool mds-status | curve bs status mds |
1042-
| curve_ops_tool server-list | curve bs list server |
1043-
| curve_ops_tool client-list | curve bs list client |
1044-
| curve_ops_tool delete | curve bs delete file |
1045-
| curve_ops_tool list | curve bs list dir |
1046-
| create | curve bs create file/dir |
1047-
| seginfo | curve bs query seginfo |
1048-
| chunk-location | curve bs query chunk |
1049-
| remove-peer | curve bs delete peer |
1050-
| reset-peer | curve bs update peer |
1051-
| space | |
1052-
| status | |
1053-
| chunkserver-status | |
1054-
| client-status | |
1055-
| snapshot-clone-status | |
1056-
| copysets-status | |
1057-
| chunkserver-list | |
1058-
| cluster-status | |
1059-
| clean-recycle | |
1060-
| check-consistency | |
1061-
| transfer-leader | |
1062-
| do-snapshot | |
1063-
| do-snapshot-all | |
1064-
| check-chunkserver | |
1065-
| check-copyset | |
1066-
| check-server | |
1067-
| check-operator | |
1068-
| list-may-broken-vol | |
1069-
| set-copyset-availflag | |
1070-
| update-throttle | |
1071-
| rapid-leader-schedule | |
1072-
| set-scan-state | |
1073-
| scan-status | |
1172+
| curve_ops_tool get -fileName= | curve bs query file -path |
1173+
| curve_ops_tool etcd-status | curve bs status etcd |
1174+
| curve_ops_tool mds-status | curve bs status mds |
1175+
| curve_ops_tool server-list | curve bs list server |
1176+
| curve_ops_tool client-list | curve bs list client |
1177+
| curve_ops_tool delete | curve bs delete file |
1178+
| curve_ops_tool list | curve bs list dir |
1179+
| create | curve bs create file/dir |
1180+
| seginfo | curve bs query seginfo |
1181+
| chunk-location | curve bs query chunk |
1182+
| remove-peer | curve bs delete peer |
1183+
| reset-peer | curve bs update peer |
1184+
| space | curve bs list space |
1185+
| status | |
1186+
| chunkserver-status | |
1187+
| client-status | |
1188+
| snapshot-clone-status | |
1189+
| copysets-status | |
1190+
| chunkserver-list | |
1191+
| cluster-status | |
1192+
| clean-recycle | |
1193+
| check-consistency | |
1194+
| transfer-leader | |
1195+
| do-snapshot | |
1196+
| do-snapshot-all | |
1197+
| check-chunkserver | |
1198+
| check-copyset | |
1199+
| check-server | |
1200+
| check-operator | |
1201+
| list-may-broken-vol | |
1202+
| set-copyset-availflag | |
1203+
| update-throttle | |
1204+
| rapid-leader-schedule | |
1205+
| set-scan-state | |
1206+
| scan-status | |

tools-v2/internal/error/error.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ var (
405405
ErrBsCreateFileOrDirectoryType = func() *CmdError {
406406
return NewInternalCmdError(48, "create file or directory fail, err: %s")
407407
}
408+
ErrBsListLogicalPoolInfo = func() *CmdError {
409+
return NewInternalCmdError(49, "list logical pool info fail, the error is: %s")
410+
}
408411

409412
// http error
410413
ErrHttpUnreadableResult = func() *CmdError {

tools-v2/internal/utils/metric.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,11 @@ func GetPoolLogicalCapacitySubUri(poolName string) string {
3333
func GetPoolLogicalAllocSubUri(poolName string) string {
3434
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_logicalAlloc")
3535
}
36+
37+
func GetPoolTotalChunkSizeName(poolName string) string {
38+
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_chunkSizeTotalBytes")
39+
}
40+
41+
func GetPoolUsedChunkSizeName(poolName string) string {
42+
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_chunkSizeUsedBytes")
43+
}

tools-v2/internal/utils/row.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const (
3636
ROW_COPYSET_ID = "copysetId"
3737
ROW_COPYSET_KEY = "copysetKey"
3838
ROW_CREATE_TIME = "createTime"
39+
ROW_CREATED = "created"
3940
ROW_CTIME = "ctime"
4041
ROW_DUMMY_ADDR = "dummyAddr"
4142
ROW_END = "end"
@@ -59,6 +60,7 @@ const (
5960
ROW_LEADER_PEER = "leaderPeer"
6061
ROW_LEFT = "left"
6162
ROW_LENGTH = "length"
63+
ROW_LOCATION = "location"
6264
ROW_LOG_GAP = "logGap"
6365
ROW_LOGICALPOOL = "logicalpool"
6466
ROW_METASERVER = "metaserver"
@@ -85,6 +87,7 @@ const (
8587
ROW_PORT = "port"
8688
ROW_READONLY = "readonly"
8789
ROW_REASON = "reason"
90+
ROW_RECYCLABLE = "recyclable"
8891
ROW_RECYCLE = "recycle"
8992
ROW_RESULT = "result"
9093
ROW_SCAN = "scan"
@@ -105,7 +108,6 @@ const (
105108
ROW_USED = "used"
106109
ROW_VERSION = "version"
107110
ROW_ZONE = "zone"
108-
ROW_LOCATION = "location"
109111

110112
// s3
111113
ROW_S3CHUNKINFO_CHUNKID = "s3ChunkId"
@@ -114,14 +116,17 @@ const (
114116
ROW_S3CHUNKINFO_SIZE = "s3Size"
115117

116118
// vale
117-
ROW_VALUE_ADD = "add"
118-
ROW_VALUE_DEL = "del"
119-
ROW_VALUE_DNE = "DNE"
120-
ROW_VALUE_OFFLINE = "offline"
121-
ROW_VALUE_UNKNOWN = "unknown"
122-
ROW_VALUE_SUCCESS = "success"
123-
ROW_VALUE_FAILED = "failed"
124-
ROW_VALUE_NULL = "null"
119+
ROW_VALUE_ADD = "add"
120+
ROW_VALUE_DEL = "del"
121+
ROW_VALUE_DNE = "DNE"
122+
ROW_VALUE_FAILED = "failed"
123+
ROW_VALUE_LOGICAL = "logical"
124+
ROW_VALUE_NO_VALUE = "-"
125+
ROW_VALUE_NULL = "null"
126+
ROW_VALUE_OFFLINE = "offline"
127+
ROW_VALUE_PHYSICAL = "physical"
128+
ROW_VALUE_SUCCESS = "success"
129+
ROW_VALUE_UNKNOWN = "unknown"
125130
)
126131

127132
// topology type

tools-v2/internal/utils/string.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const (
4141
IP_PORT_REGEX = "((\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]):([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-4]\\d{4}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]))|(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])"
4242
PATH_REGEX = `^(/[^/ ]*)+/?$`
4343
FS_NAME_REGEX = "^([a-z0-9]+\\-?)+$"
44+
45+
ROOT_PATH = "/"
46+
RECYCLEBIN_PATH = "/RecycleBin"
4447
)
4548

4649
func IsValidAddr(addr string) bool {
@@ -146,7 +149,7 @@ func ToUnderscoredName(src string) string {
146149
if i != 0 && !IsUpper(rune(src[i-1])) && ret[len(ret)-1] != '-' {
147150
ret += "_"
148151
}
149-
ret += string(c-'A'+'a')
152+
ret += string(c - 'A' + 'a')
150153
} else {
151154
ret += string(c)
152155
}

0 commit comments

Comments
 (0)