-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] tools-v2: add bs check server #2463
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ A tool for CurveFS & CurveBs. | |
- [create dir](#create-dir) | ||
- [check](#check-1) | ||
- [check copyset](#check-copyset-1) | ||
- [check server](#check-server) | ||
- [snapshot](#snapshot) | ||
- [snapshot copyset](#snapshot-copyset) | ||
- [Comparison of old and new commands](#comparison-of-old-and-new-commands) | ||
|
@@ -1335,6 +1336,28 @@ Output: | |
+------------+-----------+--------+--------+--------+---------+ | ||
``` | ||
|
||
#### check server | ||
|
||
check copysets health in server | ||
|
||
Usage: | ||
|
||
```shell | ||
curve bs check server --serverid 1 | ||
curve bs check server --ip 127.0.0.1 --port 8200 | ||
``` | ||
|
||
Output: | ||
|
||
```shell | ||
+--------+-----------+-------+------------------+ | ||
| SERVER | IP | TOTAL | UNHEALTHYCOPYSET | | ||
+--------+-----------+-------+------------------+ | ||
| 1 | 127.0.0.1 | 100 | 0(0%) | | ||
+--------+-----------+-------+------------------+ | ||
``` | ||
|
||
|
||
### snapshot | ||
|
||
#### snapshot copyset | ||
|
@@ -1405,6 +1428,7 @@ Output: | |
| curve_ops_tool check-copyset | curve bs check copyset | | ||
| curve_ops_tool client-status | curve bs status client | | ||
| curve_ops_tool check-operator | curve bs check operator | | ||
| curve_ops_tool check-server | curve bs check server | | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Delete line 1444, and please don't delete the blank line at the end. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
| curve_ops_tool snapshot-clone-status | curve bs status snapshotserver | | ||
| curve_ops_tool transfer-leader | curve bs update leader | | ||
| curve_ops_tool do-snapshot | curve bs snapshot copyset | | ||
|
@@ -1417,7 +1441,6 @@ Output: | |
| curve_ops_tool check-consistency | | | ||
| curve_ops_tool do-snapshot-all | | | ||
| curve_ops_tool check-chunkserver | | | ||
| curve_ops_tool check-server | | | ||
| curve_ops_tool list-may-broken-vol | | | ||
| curve_ops_tool set-copyset-availflag | | | ||
| curve_ops_tool rapid-leader-schedule | | | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,142 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
/* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Copyright (c) 2023 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: 2023-05-07 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
* Author: pengpengSir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
package server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"context" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmderror "github.com/opencurve/curve/tools-v2/internal/error" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
basecmd "github.com/opencurve/curve/tools-v2/pkg/cli/command" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/opencurve/curve/tools-v2/pkg/config" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/opencurve/curve/tools-v2/pkg/output" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/opencurve/curve/tools-v2/proto/proto/topology" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"github.com/spf13/cobra" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"google.golang.org/grpc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type GetChunkServerInfosRpc struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Info *basecmd.Rpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Request *topology.ListChunkServerRequest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
topologyClient topology.TopologyServiceClient | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
type GetChunkInfosCommand struct { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
basecmd.FinalCurveCmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Rpc *GetChunkServerInfosRpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Response *topology.ListChunkServerResponse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var _ basecmd.FinalCurveCmdFunc = (*GetChunkInfosCommand)(nil) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func NewChunkInfosCommand() *cobra.Command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return NewGetChunkServerInfosCommand().Cmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func NewGetChunkServerInfosCommand() *GetChunkInfosCommand { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd := &GetChunkInfosCommand{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FinalCurveCmd: basecmd.FinalCurveCmd{}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
basecmd.NewFinalCurveCli(&gCmd.FinalCurveCmd, gCmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return gCmd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gcRpc *GetChunkServerInfosRpc) NewRpcClient(cc grpc.ClientConnInterface) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gcRpc.topologyClient = topology.NewTopologyServiceClient(cc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gcRpc *GetChunkServerInfosRpc) Stub_Func(ctx context.Context) (interface{}, error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return gcRpc.topologyClient.ListChunkServer(ctx, gcRpc.Request) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gCmd *GetChunkInfosCommand) AddFlags() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddBsMdsFlagOption(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddRpcRetryTimesFlag(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddRpcTimeoutFlag(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddBsServerIdOptionFlag(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddBsIpOptionFlag(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AddBsPortOptionFlag(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gCmd *GetChunkInfosCommand) Init(cmd *cobra.Command, args []string) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
timeout := config.GetFlagDuration(gCmd.Cmd, config.RPCTIMEOUT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retrytimes := config.GetFlagInt32(gCmd.Cmd, config.RPCRETRYTIMES) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mdsAddrs, _ := config.GetBsMdsAddrSlice(gCmd.Cmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ip := config.GetFlagString(gCmd.Cmd, config.CURVEBS_IP) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
port := config.GetFlagUint32(gCmd.Cmd, config.CURVEBS_PORT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
serverid := config.GetFlagUint32(gCmd.Cmd, config.CURVEBS_SERVER_ID) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if ip != "" { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rpc := &GetChunkServerInfosRpc{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Request: &topology.ListChunkServerRequest{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Ip: &ip, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Port: &port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Info: basecmd.NewRpc(mdsAddrs, timeout, retrytimes, "ListChunkServer"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Rpc = rpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
rpc := &GetChunkServerInfosRpc{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Request: &topology.ListChunkServerRequest{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ServerID: &serverid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Info: basecmd.NewRpc(mdsAddrs, timeout, retrytimes, "ListChunkServer"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Rpc = rpc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+87
to
+104
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gCmd *GetChunkInfosCommand) Print(cmd *cobra.Command, args []string) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return output.FinalCmdOutput(&gCmd.FinalCurveCmd, gCmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gCmd *GetChunkInfosCommand) ResultPlainOutput() error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return output.FinalCmdOutputPlain(&gCmd.FinalCurveCmd) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func (gCmd *GetChunkInfosCommand) RunCommand(cmd *cobra.Command, args []string) error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
result, err := basecmd.GetRpcResponse(gCmd.Rpc.Info, gCmd.Rpc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err.TypeCode() != cmderror.CODE_SUCCESS { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return err.ToError() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Response = result.(*topology.ListChunkServerResponse) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
func GetChunkserverInfos(caller *cobra.Command) ([]*topology.ChunkServerInfo, *cmderror.CmdError) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd := NewGetChunkServerInfosCommand() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.AlignFlagsValue(caller, gCmd.Cmd, []string{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
config.CURVEBS_MDSADDR, config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEBS_SERVER_ID, config.CURVEBS_IP, config.CURVEBS_PORT, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Cmd.SilenceErrors = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Cmd.SilenceUsage = true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
gCmd.Cmd.SetArgs([]string{"--format", config.FORMAT_NOOUT}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
err := gCmd.Cmd.Execute() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if err != nil { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retErr := cmderror.ErrBsGetChunkServerInfos() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
retErr.Format(err.Error()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil, retErr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return gCmd.Response.ChunkServerInfos, cmderror.Success() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
/* | ||
* Copyright (c) 2023 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: 2023-05-07 | ||
* Author: pengpengSir | ||
*/ | ||
package server | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
cmderror "github.com/opencurve/curve/tools-v2/internal/error" | ||
basecmd "github.com/opencurve/curve/tools-v2/pkg/cli/command" | ||
"github.com/opencurve/curve/tools-v2/pkg/config" | ||
"github.com/opencurve/curve/tools-v2/pkg/output" | ||
"github.com/opencurve/curve/tools-v2/proto/proto/topology" | ||
"github.com/spf13/cobra" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type GetChunkServerCopysetsRpc struct { | ||
Info *basecmd.Rpc | ||
Request *topology.GetCopySetsInChunkServerRequest | ||
topologyClient topology.TopologyServiceClient | ||
} | ||
|
||
type CopysetidsCommand struct { | ||
basecmd.FinalCurveCmd | ||
Rpc *GetChunkServerCopysetsRpc | ||
Response *topology.GetCopySetsInChunkServerResponse | ||
} | ||
|
||
var _ basecmd.FinalCurveCmdFunc = (*CopysetidsCommand)(nil) | ||
|
||
func NewCopysetCommand() *cobra.Command { | ||
return NewCopysetidsCommand().Cmd | ||
} | ||
|
||
func NewCopysetidsCommand() *CopysetidsCommand { | ||
cCmd := &CopysetidsCommand{ | ||
FinalCurveCmd: basecmd.FinalCurveCmd{}, | ||
} | ||
basecmd.NewFinalCurveCli(&cCmd.FinalCurveCmd, cCmd) | ||
return cCmd | ||
} | ||
|
||
func (tRpc *GetChunkServerCopysetsRpc) NewRpcClient(cc grpc.ClientConnInterface) { | ||
tRpc.topologyClient = topology.NewTopologyServiceClient(cc) | ||
} | ||
|
||
func (tRpc *GetChunkServerCopysetsRpc) Stub_Func(ctx context.Context) (interface{}, error) { | ||
return tRpc.topologyClient.GetCopySetsInChunkServer(ctx, tRpc.Request) | ||
} | ||
|
||
func (cCmd *CopysetidsCommand) AddFlags() { | ||
config.AddBsMdsFlagOption(cCmd.Cmd) | ||
config.AddRpcRetryTimesFlag(cCmd.Cmd) | ||
config.AddRpcTimeoutFlag(cCmd.Cmd) | ||
config.AddBsChunkServerIDOptionFlag(cCmd.Cmd) | ||
config.AddBsIpOptionFlag(cCmd.Cmd) | ||
config.AddBsPortOptionFlag(cCmd.Cmd) | ||
} | ||
|
||
func (cCmd *CopysetidsCommand) Init(cmd *cobra.Command, args []string) error { | ||
timeout := config.GetFlagDuration(cCmd.Cmd, config.RPCTIMEOUT) | ||
retrytimes := config.GetFlagInt32(cCmd.Cmd, config.RPCRETRYTIMES) | ||
mdsAddrs, _ := config.GetBsMdsAddrSlice(cCmd.Cmd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not check the error |
||
|
||
chunkserverId := config.GetBsFlagUint32(cCmd.Cmd, config.CURVEBS_CHUNKSERVER_ID) | ||
hostip := config.GetBsFlagString(cCmd.Cmd, config.CURVEBS_IP) | ||
port := config.GetBsFlagUint32(cCmd.Cmd, config.CURVEBS_PORT) | ||
|
||
rpc := &GetChunkServerCopysetsRpc{ | ||
Request: &topology.GetCopySetsInChunkServerRequest{ | ||
ChunkServerID: &chunkserverId, | ||
HostIp: &hostip, | ||
Port: &port, | ||
}, | ||
Info: basecmd.NewRpc(mdsAddrs, timeout, retrytimes, "GetCopysetInChunkServer"), | ||
} | ||
cCmd.Rpc = rpc | ||
return nil | ||
} | ||
|
||
func (cCmd *CopysetidsCommand) Print(cmd *cobra.Command, args []string) error { | ||
return output.FinalCmdOutput(&cCmd.FinalCurveCmd, cCmd) | ||
} | ||
|
||
func (cCmd *CopysetidsCommand) ResultPlainOutput() error { | ||
return output.FinalCmdOutputPlain(&cCmd.FinalCurveCmd) | ||
} | ||
|
||
func (cCmd *CopysetidsCommand) RunCommand(cmd *cobra.Command, args []string) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
result, err := basecmd.GetRpcResponse(cCmd.Rpc.Info, cCmd.Rpc) | ||
|
||
if err.TypeCode() != cmderror.CODE_SUCCESS { | ||
fmt.Print(err.Message) | ||
return err.ToError() | ||
} | ||
|
||
cCmd.Response = result.(*topology.GetCopySetsInChunkServerResponse) | ||
return nil | ||
} | ||
|
||
func GetCopysetids(caller *cobra.Command) (*map[uint32]uint32, *cmderror.CmdError) { | ||
cCmd := NewCopysetidsCommand() | ||
config.AlignFlagsValue(caller, cCmd.Cmd, []string{ | ||
config.CURVEBS_MDSADDR, config.RPCRETRYTIMES, config.RPCTIMEOUT, config.CURVEBS_CHUNKSERVER_ID, | ||
config.CURVEBS_IP, config.CURVEBS_PORT, | ||
}) | ||
cCmd.Cmd.SilenceErrors = true | ||
cCmd.Cmd.SilenceUsage = true | ||
cCmd.Cmd.SetArgs([]string{"--format", config.FORMAT_NOOUT}) | ||
err := cCmd.Cmd.Execute() | ||
if err != nil { | ||
retErr := cmderror.ErrBsGetCopysetStatus() | ||
retErr.Format(err.Error()) | ||
return nil, retErr | ||
} | ||
|
||
copysetID2PoolId := make(map[uint32]uint32) | ||
for _, copysetInfo := range cCmd.Response.GetCopysetInfos() { | ||
copysetID2PoolId[copysetInfo.GetCopysetId()] = copysetInfo.GetLogicalPoolId() | ||
} | ||
|
||
return ©setID2PoolId, cmderror.Success() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Complement the comparison of old and new tools
Comparison of old and new commands
curve bs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done