Skip to content

Commit

Permalink
curve/tools-v2:bs
Browse files Browse the repository at this point in the history
1. add go_package in proto/*.proto
2. add bs proto in mk-proto.sh
3. add bs query file

Signed-off-by: Cyber-SiKu <[email protected]>
  • Loading branch information
Cyber-SiKu committed Sep 8, 2022
1 parent 8d6ee2c commit cedb52a
Show file tree
Hide file tree
Showing 43 changed files with 2,424 additions and 805 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ curvefs/docker/*/curvefs
storage_*

tools-v2/sbin/*
tools-v2/proto/*
tools-v2/proto/proto/*
tools-v2/proto/curvefs/*
tools-v2/*/*.test
tools-v2/__debug_bin
tools-v2/vendor/
2 changes: 1 addition & 1 deletion proto/chunk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ syntax = "proto2";
package curve.chunkserver;

option cc_generic_services = true;

option go_package = "proto/chunk";

// Qos 参数
message QosRequestParas {
Expand Down
1 change: 1 addition & 0 deletions proto/chunkserver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
syntax="proto2";
package curve.chunkserver;
option cc_generic_services = true;
option go_package = "proto/chunkserver";

message ChunkServerMetadata {
required uint32 version = 1;
Expand Down
1 change: 1 addition & 0 deletions proto/cli.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ syntax="proto2";
package curve.chunkserver;

option cc_generic_services = true;
option go_package = "proto/cli";

// 这里都用 logicPoolId, copysetId,进入 rpc service 之后,会转换成 string
// 类型的 groupId,在传给 raft
Expand Down
1 change: 1 addition & 0 deletions proto/cli2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "proto/common.proto";
package curve.chunkserver;

option cc_generic_services = true;
option go_package = "proto/cli2";

// cli.proto 供老的使用保证
message AddPeerRequest2 {
Expand Down
1 change: 1 addition & 0 deletions proto/configuration.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
syntax="proto2";
package curve.chunkserver;
option cc_generic_services = true;
option go_package = "proto/configuration";

// Config service
message ConfigRequest {
Expand Down
1 change: 1 addition & 0 deletions proto/copyset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "proto/common.proto";
package curve.chunkserver;

option cc_generic_services = true;
option go_package = "proto/copyset";

// copyset epoch message,用于epoch序列化和反序列化
message ConfEpoch {
Expand Down
2 changes: 2 additions & 0 deletions proto/curve_storage.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
syntax="proto2";
package curve.chunkserver;

option go_package = "proto/curve_storage";

enum FileSource {
FILE_SOURCE_LOCAL = 0;
FILE_SOURCE_REFERENCE = 1;
Expand Down
1 change: 1 addition & 0 deletions proto/integrity.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
syntax="proto2";
package curve.chunkserver;
option cc_generic_services = true;
option go_package = "proto/integrity";

// Integrity service
enum INTEGRITY_JOB_STATE {
Expand Down
2 changes: 1 addition & 1 deletion proto/nameserver2.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import "proto/common.proto";
package curve.mds;

option cc_generic_services = true;

option go_package = "proto/nameserver2";

// fileinfo
enum FileType {
Expand Down
1 change: 1 addition & 0 deletions proto/schedule.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ syntax="proto2";
package curve.mds.schedule;

option cc_generic_services = true;
option go_package = "proto/schedule";

message RapidLeaderScheduleRequst {
required uint32 logicalPoolID = 1;
Expand Down
2 changes: 2 additions & 0 deletions proto/snapshotcloneserver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ syntax="proto2";
package curve.snapshotcloneserver;

option cc_generic_services = true;
option go_package = "proto/snapshotcloneserver";

/*
message ChunkName {
required string filename = 1;
Expand Down
1 change: 1 addition & 0 deletions proto/topology.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package curve.mds.topology;
// HTTP web can use https://github.com/dcodeIO/protobuf.js to use proto buffer

option cc_generic_services = true;
option go_package = "proto/topology";

enum LogicalPoolType {
PAGEFILE = 0;
Expand Down
3 changes: 2 additions & 1 deletion tools-v2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ proto:

clean:
rm -rf sbin
rm -rf proto/*
rm -rf proto/proto/*
rm -rf proto/curvefs/*
rm -rf go.mod
rm -rf go.sum
17 changes: 16 additions & 1 deletion tools-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,6 @@ Output:
```

#### warmup

#### add
warmup a file(directory), or given a list file contains a list of files(directories) that you want to warmup.

Expand All @@ -781,6 +780,22 @@ curve fs warmup add --filelist /mnt/curvefs/warmup.list

> `curve fs warmup add /mnt/curvefs/warmup` will warmup a file(directory).
> /mnt/curvefs/warmup.list
### bs

#### list

##### list logical-pool

list all logical pool information

Usage:

```
curve bs list logical-pool
```


## Comparison of old and new commands

### curve fs
Expand Down
43 changes: 39 additions & 4 deletions tools-v2/internal/error/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import (
"github.com/opencurve/curve/tools-v2/proto/curvefs/proto/copyset"
"github.com/opencurve/curve/tools-v2/proto/curvefs/proto/mds"
"github.com/opencurve/curve/tools-v2/proto/curvefs/proto/topology"
"github.com/opencurve/curve/tools-v2/proto/proto/nameserver2"
bs_topo_statuscode "github.com/opencurve/curve/tools-v2/proto/proto/topology/statuscode"
)

// It is considered here that the importance of the error is related to the
Expand Down Expand Up @@ -228,6 +230,7 @@ func MergeCmdError(err []*CmdError) CmdError {

var (
ErrSuccess = NewSucessCmdError
Success = ErrSuccess

// internal error
ErrHttpCreateGetRequest = func() *CmdError {
Expand Down Expand Up @@ -269,7 +272,7 @@ var (
ErrUnknownBitmapLocation = func() *CmdError {
return NewInternalCmdError(13, "unknown bitmap location: %s")
}
ErrParseBytes = func() *CmdError {
ErrParse = func() *CmdError {
return NewInternalCmdError(14, "invalid %s: %s")
}
ErrSplitPeer = func() *CmdError {
Expand Down Expand Up @@ -344,6 +347,21 @@ var (
ErrSetxattr = func() *CmdError {
return NewInternalCmdError(33, "setxattr [%s] failed! the error is: %s")
}
ErrBsGetPhysicalPool = func() *CmdError {
return NewInternalCmdError(34, "list physical pool fail, the error is: %s")
}
ErrBsGetAllocatedSize = func() *CmdError {
return NewInternalCmdError(35, "get file allocated fail, the error is: %s")
}
ErrGettimeofday = func() *CmdError {
return NewInternalCmdError(36, "get time of day fail, the error is: %s")
}
ErrBsGetFileInfo = func() *CmdError {
return NewInternalCmdError(37, "get file info fail, the error is: %s")
}
ErrBsGetFileSize = func() *CmdError {
return NewInternalCmdError(37, "get file size fail, the error is: %s")
}

// http error
ErrHttpUnreadableResult = func() *CmdError {
Expand Down Expand Up @@ -465,7 +483,7 @@ var (
case topology.TopoStatusCode_TOPO_OK:
message = "ok"
default:
message = fmt.Sprintf("list Server err: %s", statusCode.String())
message = fmt.Sprintf("list Server fail, err: %s", statusCode.String())
}
return NewRpcReultCmdError(code, message)
}
Expand All @@ -476,7 +494,7 @@ var (
case topology.TopoStatusCode_TOPO_OK:
message = "ok"
default:
message = fmt.Sprintf("delete %s[%s] err: %s", topoType, name, statusCode.String())
message = fmt.Sprintf("delete %s[%s], err: %s", topoType, name, statusCode.String())
}
return NewRpcReultCmdError(code, message)
}
Expand All @@ -487,7 +505,7 @@ var (
case topology.TopoStatusCode_TOPO_OK:
message = "ok"
default:
message = fmt.Sprintf("create %s[%s] err: %s", topoType, name, statusCode.String())
message = fmt.Sprintf("create %s[%s], err: %s", topoType, name, statusCode.String())
}
return NewRpcReultCmdError(code, message)
}
Expand All @@ -504,4 +522,21 @@ var (
}
return NewRpcReultCmdError(code, message)
}
ErrBsListPhysicalPoolRpc = func(statusCode bs_topo_statuscode.TopoStatusCode) *CmdError {
code := int32(statusCode)
message := fmt.Sprintf("Rpc[ListPhysicalPool] status code: %s", bs_topo_statuscode.TopoStatusCode_name[code])
return NewRpcReultCmdError(int(-code), message)
}
ErrBsGetAllocatedSizeRpc = func(statuscode nameserver2.StatusCode, file string) *CmdError {
message := fmt.Sprintf("Rpc[GetFileAllocatedSize] for [%s] status code: %s", file, statuscode.String())
return NewInternalCmdError(int(statuscode), message)
}
ErrBsGetFileInfoRpc = func(statuscode nameserver2.StatusCode, file string) *CmdError {
message := fmt.Sprintf("Rpc[GetFileInfo] for [%s] status code: %s", file, statuscode.String())
return NewInternalCmdError(int(statuscode), message)
}
ErrBsGetFileSizeRpc = func(statuscode nameserver2.StatusCode, file string) *CmdError {
message := fmt.Sprintf("Rpc[GetFileSize] for [%s] status code: %s", file, statuscode.String())
return NewInternalCmdError(int(statuscode), message)
}
)
35 changes: 35 additions & 0 deletions tools-v2/internal/utils/metric.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2022 NetEase Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
* Project: CurveCli
* Created Date: 2022-09-02
* Author: chengyi (Cyber-SiKu)
*/
package cobrautil

const (
kVars = "/vars/"
kLogicalPoolMetricPrefix = "topology_metric_logicalPool_"
)

func GetPoolLogicalCapacitySubUri(poolName string) string {
return kVars + ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_logicalCapacity")
}

func GetPoolLogicalAllocSubUri(poolName string) string {
return kVars+ToUnderscoredName(kLogicalPoolMetricPrefix + poolName + "_logicalAlloc")
}
13 changes: 4 additions & 9 deletions tools-v2/internal/utils/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package process

import (
"log"
"os"
)

type Cache struct {
Expand All @@ -46,17 +47,11 @@ func init() {
// bufs: make([]*bytes.Buffer, 0),
// mtx: &sync.RWMutex{},
}
log.SetOutput(C)
}

func SetShow(show bool) {
if !show {
log.SetOutput(C)
} else {
// C.mtx.Lock()
// defer C.mtx.Unlock()
// for _, buf := range C.bufs {
// fmt.Println(buf.String())
// }
// C.bufs = make([]*bytes.Buffer, 0)
if show {
log.SetOutput(os.Stdout)
}
}
14 changes: 14 additions & 0 deletions tools-v2/internal/utils/row.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,22 @@ package cobrautil

const (
ROW_ADDR = "addr"
ROW_ALLOC = "alloc"
ROW_BLOCKSIZE = "blocksize"
ROW_CAPACITY = "capacity"
ROW_CHILD_LIST = "childList"
ROW_CHILD_TYPE = "childType"
ROW_CHUNK = "chunk"
ROW_COPYSET_ID = "copysetId"
ROW_COPYSET_KEY = "copysetKey"
ROW_CREATE_TIME = "createTime"
ROW_CTIME = "ctime"
ROW_DUMMY_ADDR = "dummyAddr"
ROW_END = "end"
ROW_EPOCH = "epoch"
ROW_EXPLAIN = "explain"
ROW_EXTERNAL_ADDR = "externalAddr"
ROW_FILE_SIZE = "fileSize"
ROW_FS_ID = "fsId"
ROW_FS_NAME = "fsName"
ROW_FS_TYPE = "fsType"
Expand All @@ -56,22 +61,31 @@ const (
ROW_NUM = "num"
ROW_ONLINE_STATE = "onlineState"
ROW_OPERATION = "operation"
ROW_ORIGINAL_PATH = "originalPath"
ROW_OWNER = "owner"
ROW_PARENT = "parent"
ROW_PARTITION_ID = "partitionId"
ROW_PEER_ADDR = "peerAddr"
ROW_PEER_ID = "peerId"
ROW_PEER_NUMBER = "peerNumber"
ROW_PHYPOOLID = "phyPoolID"
ROW_POOL = "pool"
ROW_POOL_ID = "poolId"
ROW_READONLY = "readonly"
ROW_RECYCLE = "recycle"
ROW_RESULT = "result"
ROW_SCAN = "scan"
ROW_SEGMENT = "segment"
ROW_SEQ = "seq"
ROW_SERVER = "server"
ROW_SIZE = "size"
ROW_START = "start"
ROW_STATE = "state"
ROW_STATUS = "status"
ROW_STRIPE = "stripe"
ROW_SUM_IN_DIR = "sumInDir"
ROW_TERM = "term"
ROW_THROTTLE = "throttle"
ROW_TOTAL = "total"
ROW_TYPE = "type"
ROW_USED = "used"
Expand Down
Loading

0 comments on commit cedb52a

Please sign in to comment.