Skip to content

Commit

Permalink
[feat]tools-v2: add space
Browse files Browse the repository at this point in the history
1. fix README.md
2. add bs list space
3 fix some error in bs list logicalpool

Signed-off-by: Cyber-SiKu <[email protected]>
  • Loading branch information
Cyber-SiKu authored and wu-hanqing committed Apr 24, 2023
1 parent 46269a9 commit 4e73df5
Show file tree
Hide file tree
Showing 9 changed files with 538 additions and 109 deletions.
253 changes: 193 additions & 60 deletions tools-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,22 @@ A tool for CurveFS & CurveBs.
- [list server](#list-server)
- [list client](#list-client)
- [list dir](#list-dir)
- [list space](#list-space)
- [query](#query-1)
- [query file](#query-file)
- [query chunk](#query-chunk)
- [query segment](#query-segment)
- [status](#status-1)
- [staus etcd](#staus-etcd)
- [staus mds](#staus-mds)
- [delete](#delete-1)
- [delete peer](#delete-peer)
- [update](#update)
- [update peer](#update-peer)
- [update file](#update-file)
- [create](#create-1)
- [create file](#create-file)
- [create dir](#create-dir)
- [Comparison of old and new commands](#comparison-of-old-and-new-commands)
- [curve fs](#curve-fs)
- [curve bs](#curve-bs)
Expand Down Expand Up @@ -884,6 +891,26 @@ Output:
+------+-------------+----------+-----------------+------------+---------------------+---------------+-------------+
```

##### list space

show curvebs all disk type space, include total space and used space

```bash
curve bs list space
```

Output:

```bash
+----------+---------+---------+---------+------------+---------+
| TYPE | TOTAL | USED | LEFT | RECYCLABLE | CREATED |
+----------+---------+---------+---------+------------+---------+
| physical | *** GiB | *** GiB | *** GiB | - | - |
+----------+---------+---------+---------+------------+---------+
| logical | *** GiB | *** GiB | *** GiB | *** GiB | *** GiB |
+----------+---------+---------+---------+------------+---------+
```

### query

##### query file
Expand All @@ -909,6 +936,56 @@ Output:
+------+------+----------------+-------+--------+---------+--------+-----+---------------------+--------------+---------+-----------------+----------+
```

##### query chunk

query the location of the chunk corresponding to the offset

Usage:

```bash
curve bs query chunk --path /test1 --offset 1008600000
```

Output:

```bash
+-------+-------------+---------+------------+----------------------+
| CHUNK | LOGICALPOOL | COPYSET | GROUP | LOCATION |
+-------+-------------+---------+------------+----------------------+
| 61 | 1 | 61 | 4294967357 | ***.***.***.***:**** |
| | | | | ***.***.***.***:**** |
| | | | | ***.***.***.***:**** |
+-------+-------------+---------+------------+----------------------+
```

##### query segment

query the segments info of the file

Usage:

```bash
curve bs query seginfo --path /test1
```

Output:

```bash
+-------------+-------------+-----------+------------+---------+-------+
| LOGICALPOOL | SEGMENTSIZE | CHUNKSIZE | START | COPYSET | CHUNK |
+-------------+-------------+-----------+------------+---------+-------+
| 1 | 1073741824 | 16777216 | 0 | 1 | 1 |
+ + + + +---------+-------+
| ...... |
+ + + +------------+---------+-------+
| | | | 9663676416 | 1 | 101 |
+ + + + +---------+-------+
| ...... |
+ + + + +---------+-------+
| | | | | 99 | 99 |
+-------------+-------------+-----------+------------+---------+-------+
```

### status

#### staus etcd
Expand Down Expand Up @@ -1003,71 +1080,127 @@ Output:
+----------------------+---------+---------+--------+
```

#### update file

expand pagefile

Usage:
```bash
curve bs update file --path /test2/test1 --size 10
```

Output:
```
+---------+
| RESULT |
+---------+
| success |
+---------+
```

### create

#### create file

create pagefile

Usage:
```bash
curve bs create file --path /test2/test4 --size 10GiB
```

Output:
```
+---------+
| RESULT |
+---------+
| success |
+---------+
```

#### create dir

create directory

Usage:
```bash
curve bs create dir --path /test2/test5
```

Output:
```
+---------+
| RESULT |
+---------+
| success |
+---------+
```

## Comparison of old and new commands

### curve fs

| old | new |
| ---- | ---- |
| curvefs_tool check-copyset | curve fs check copyset |
| curvefs_tool create-fs | curve fs create fs |
| curvefs_tool create-topology | curve fs create topology |
| curvefs_tool delete-fs | curve fs delete fs |
| curvefs_tool list-copyset | curve fs list copyset |
| curvefs_tool list-fs | curve fs list fs |
| curvefs_tool list-fs | curve fs list mountpoint |
| curvefs_tool list-partition | curve fs list partition |
| curvefs_tool query-copyset | curve fs query copyset |
| curvefs_tool query-fs | curve fs query fs |
| curvefs_tool query-inode | curve fs query inode |
| curvefs_tool query-metaserver | curve fs query metaserver |
| curvefs_tool query-partition | curve fs query partition |
| curvefs_tool status-mds | curve fs status mds |
| curvefs_tool status-metaserver | curve fs status metaserver |
| curvefs_tool status-etcd | curve fs status etcd |
| curvefs_tool status-copyset | curve fs status copyset |
| curvefs_tool status-cluster | curve fs status cluster |
| curvefs_tool umount-fs | curve fs umount fs |
| curvefs_tool usage-inode | curve fs usage inode |
| curvefs_tool usage-metadata | curve fs usage metadata |
| old | new |
| ------------------------------ | -------------------------- |
| curvefs_tool check-copyset | curve fs check copyset |
| curvefs_tool create-fs | curve fs create fs |
| curvefs_tool create-topology | curve fs create topology |
| curvefs_tool delete-fs | curve fs delete fs |
| curvefs_tool list-copyset | curve fs list copyset |
| curvefs_tool list-fs | curve fs list fs |
| curvefs_tool list-fs | curve fs list mountpoint |
| curvefs_tool list-partition | curve fs list partition |
| curvefs_tool query-copyset | curve fs query copyset |
| curvefs_tool query-fs | curve fs query fs |
| curvefs_tool query-inode | curve fs query inode |
| curvefs_tool query-metaserver | curve fs query metaserver |
| curvefs_tool query-partition | curve fs query partition |
| curvefs_tool status-mds | curve fs status mds |
| curvefs_tool status-metaserver | curve fs status metaserver |
| curvefs_tool status-etcd | curve fs status etcd |
| curvefs_tool status-copyset | curve fs status copyset |
| curvefs_tool status-cluster | curve fs status cluster |
| curvefs_tool umount-fs | curve fs umount fs |
| curvefs_tool usage-inode | curve fs usage inode |
| curvefs_tool usage-metadata | curve fs usage metadata |

### curve bs

| old | new |
| ---- | ---- |
| old | new |
| -------------------------------- | -------------------------- |
| curve_ops_tool logical-pool-list | curve bs list logical-pool |
| curve_ops_tool get -fileName= | curve bs query file -path |
| curve_ops_tool etcd-status | curve bs status etcd |
| curve_ops_tool mds-status | curve bs status mds |
| curve_ops_tool server-list | curve bs list server |
| curve_ops_tool client-list | curve bs list client |
| curve_ops_tool delete | curve bs delete file |
| curve_ops_tool list | curve bs list dir |
| create | curve bs create file/dir |
| seginfo | curve bs query seginfo |
| chunk-location | curve bs query chunk |
| remove-peer | curve bs delete peer |
| reset-peer | curve bs update peer |
| space | |
| status | |
| chunkserver-status | |
| client-status | |
| snapshot-clone-status | |
| copysets-status | |
| chunkserver-list | |
| cluster-status | |
| clean-recycle | |
| check-consistency | |
| transfer-leader | |
| do-snapshot | |
| do-snapshot-all | |
| check-chunkserver | |
| check-copyset | |
| check-server | |
| check-operator | |
| list-may-broken-vol | |
| set-copyset-availflag | |
| update-throttle | |
| rapid-leader-schedule | |
| set-scan-state | |
| scan-status | |
| curve_ops_tool get -fileName= | curve bs query file -path |
| curve_ops_tool etcd-status | curve bs status etcd |
| curve_ops_tool mds-status | curve bs status mds |
| curve_ops_tool server-list | curve bs list server |
| curve_ops_tool client-list | curve bs list client |
| curve_ops_tool delete | curve bs delete file |
| curve_ops_tool list | curve bs list dir |
| create | curve bs create file/dir |
| seginfo | curve bs query seginfo |
| chunk-location | curve bs query chunk |
| remove-peer | curve bs delete peer |
| reset-peer | curve bs update peer |
| space | curve bs list space |
| status | |
| chunkserver-status | |
| client-status | |
| snapshot-clone-status | |
| copysets-status | |
| chunkserver-list | |
| cluster-status | |
| clean-recycle | |
| check-consistency | |
| transfer-leader | |
| do-snapshot | |
| do-snapshot-all | |
| check-chunkserver | |
| check-copyset | |
| check-server | |
| check-operator | |
| list-may-broken-vol | |
| set-copyset-availflag | |
| update-throttle | |
| rapid-leader-schedule | |
| set-scan-state | |
| scan-status | |
3 changes: 3 additions & 0 deletions tools-v2/internal/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ var (
ErrBsCreateFileOrDirectoryType = func() *CmdError {
return NewInternalCmdError(48, "create file or directory fail, err: %s")
}
ErrBsListLogicalPoolInfo = func() *CmdError {
return NewInternalCmdError(49, "list logical pool info fail, the error is: %s")
}

// http error
ErrHttpUnreadableResult = func() *CmdError {
Expand Down
8 changes: 8 additions & 0 deletions tools-v2/internal/utils/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,11 @@ func GetPoolLogicalCapacitySubUri(poolName string) string {
func GetPoolLogicalAllocSubUri(poolName string) string {
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_logicalAlloc")
}

func GetPoolTotalChunkSizeName(poolName string) string {
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_chunkSizeTotalBytes")
}

func GetPoolUsedChunkSizeName(poolName string) string {
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_chunkSizeUsedBytes")
}
23 changes: 14 additions & 9 deletions tools-v2/internal/utils/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
ROW_COPYSET_ID = "copysetId"
ROW_COPYSET_KEY = "copysetKey"
ROW_CREATE_TIME = "createTime"
ROW_CREATED = "created"
ROW_CTIME = "ctime"
ROW_DUMMY_ADDR = "dummyAddr"
ROW_END = "end"
Expand All @@ -59,6 +60,7 @@ const (
ROW_LEADER_PEER = "leaderPeer"
ROW_LEFT = "left"
ROW_LENGTH = "length"
ROW_LOCATION = "location"
ROW_LOG_GAP = "logGap"
ROW_LOGICALPOOL = "logicalpool"
ROW_METASERVER = "metaserver"
Expand All @@ -85,6 +87,7 @@ const (
ROW_PORT = "port"
ROW_READONLY = "readonly"
ROW_REASON = "reason"
ROW_RECYCLABLE = "recyclable"
ROW_RECYCLE = "recycle"
ROW_RESULT = "result"
ROW_SCAN = "scan"
Expand All @@ -105,7 +108,6 @@ const (
ROW_USED = "used"
ROW_VERSION = "version"
ROW_ZONE = "zone"
ROW_LOCATION = "location"

// s3
ROW_S3CHUNKINFO_CHUNKID = "s3ChunkId"
Expand All @@ -114,14 +116,17 @@ const (
ROW_S3CHUNKINFO_SIZE = "s3Size"

// vale
ROW_VALUE_ADD = "add"
ROW_VALUE_DEL = "del"
ROW_VALUE_DNE = "DNE"
ROW_VALUE_OFFLINE = "offline"
ROW_VALUE_UNKNOWN = "unknown"
ROW_VALUE_SUCCESS = "success"
ROW_VALUE_FAILED = "failed"
ROW_VALUE_NULL = "null"
ROW_VALUE_ADD = "add"
ROW_VALUE_DEL = "del"
ROW_VALUE_DNE = "DNE"
ROW_VALUE_FAILED = "failed"
ROW_VALUE_LOGICAL = "logical"
ROW_VALUE_NO_VALUE = "-"
ROW_VALUE_NULL = "null"
ROW_VALUE_OFFLINE = "offline"
ROW_VALUE_PHYSICAL = "physical"
ROW_VALUE_SUCCESS = "success"
ROW_VALUE_UNKNOWN = "unknown"
)

// topology type
Expand Down
5 changes: 4 additions & 1 deletion tools-v2/internal/utils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const (
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])"
PATH_REGEX = `^(/[^/ ]*)+/?$`
FS_NAME_REGEX = "^([a-z0-9]+\\-?)+$"

ROOT_PATH = "/"
RECYCLEBIN_PATH = "/RecycleBin"
)

func IsValidAddr(addr string) bool {
Expand Down Expand Up @@ -146,7 +149,7 @@ func ToUnderscoredName(src string) string {
if i != 0 && !IsUpper(rune(src[i-1])) && ret[len(ret)-1] != '-' {
ret += "_"
}
ret += string(c-'A'+'a')
ret += string(c - 'A' + 'a')
} else {
ret += string(c)
}
Expand Down
Loading

0 comments on commit 4e73df5

Please sign in to comment.