2021-03-15 11:04:13 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/common"
|
2021-03-15 11:04:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const serviceName = "control.ControlService"
|
|
|
|
|
|
|
|
const (
|
|
|
|
rpcHealthCheck = "HealthCheck"
|
|
|
|
rpcSetNetmapStatus = "SetNetmapStatus"
|
|
|
|
rpcDropObjects = "DropObjects"
|
2021-12-17 15:23:46 +00:00
|
|
|
rpcListShards = "ListShards"
|
2021-12-27 16:12:23 +00:00
|
|
|
rpcSetShardMode = "SetShardMode"
|
2022-01-24 10:13:37 +00:00
|
|
|
rpcDumpShard = "DumpShard"
|
2022-01-25 11:54:35 +00:00
|
|
|
rpcRestoreShard = "RestoreShard"
|
2022-05-16 16:31:50 +00:00
|
|
|
rpcSynchronizeTree = "SynchronizeTree"
|
2022-09-13 10:28:08 +00:00
|
|
|
rpcEvacuateShard = "EvacuateShard"
|
2022-09-21 10:51:51 +00:00
|
|
|
rpcFlushCache = "FlushCache"
|
2023-04-07 11:21:05 +00:00
|
|
|
rpcDoctor = "Doctor"
|
2021-03-15 11:04:13 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// HealthCheck executes ControlService.HealthCheck RPC.
|
|
|
|
func HealthCheck(
|
|
|
|
cli *client.Client,
|
|
|
|
req *HealthCheckRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*HealthCheckResponse, error) {
|
|
|
|
wResp := &healthCheckResponseWrapper{
|
|
|
|
m: new(HealthCheckResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcHealthCheck), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SetNetmapStatus executes ControlService.SetNetmapStatus RPC.
|
|
|
|
func SetNetmapStatus(
|
|
|
|
cli *client.Client,
|
|
|
|
req *SetNetmapStatusRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*SetNetmapStatusResponse, error) {
|
|
|
|
wResp := &setNetmapStatusResponseWrapper{
|
|
|
|
m: new(SetNetmapStatusResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSetNetmapStatus), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// DropObjects executes ControlService.DropObjects RPC.
|
|
|
|
func DropObjects(
|
|
|
|
cli *client.Client,
|
|
|
|
req *DropObjectsRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*DropObjectsResponse, error) {
|
|
|
|
wResp := &dropObjectsResponseWrapper{
|
|
|
|
m: new(DropObjectsResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDropObjects), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
2021-12-17 15:23:46 +00:00
|
|
|
|
|
|
|
// ListShards executes ControlService.ListShards RPC.
|
|
|
|
func ListShards(
|
|
|
|
cli *client.Client,
|
|
|
|
req *ListShardsRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*ListShardsResponse, error) {
|
2021-12-29 15:12:40 +00:00
|
|
|
wResp := &listShardsResponseWrapper{
|
2021-12-17 15:23:46 +00:00
|
|
|
m: new(ListShardsResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcListShards), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
2021-12-27 16:12:23 +00:00
|
|
|
|
|
|
|
// SetShardMode executes ControlService.SetShardMode RPC.
|
|
|
|
func SetShardMode(
|
|
|
|
cli *client.Client,
|
|
|
|
req *SetShardModeRequest,
|
|
|
|
opts ...client.CallOption,
|
|
|
|
) (*SetShardModeResponse, error) {
|
|
|
|
wResp := &setShardModeResponseWrapper{
|
|
|
|
m: new(SetShardModeResponse),
|
|
|
|
}
|
|
|
|
|
|
|
|
wReq := &requestWrapper{
|
|
|
|
m: req,
|
|
|
|
}
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSetShardMode), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.m, nil
|
|
|
|
}
|
2022-01-24 10:13:37 +00:00
|
|
|
|
|
|
|
// DumpShard executes ControlService.DumpShard RPC.
|
|
|
|
func DumpShard(cli *client.Client, req *DumpShardRequest, opts ...client.CallOption) (*DumpShardResponse, error) {
|
2022-01-24 12:22:47 +00:00
|
|
|
wResp := &dumpShardResponseWrapper{new(DumpShardResponse)}
|
2022-01-24 10:13:37 +00:00
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDumpShard), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.DumpShardResponse, nil
|
|
|
|
}
|
2022-01-25 11:54:35 +00:00
|
|
|
|
|
|
|
// RestoreShard executes ControlService.DumpShard RPC.
|
|
|
|
func RestoreShard(cli *client.Client, req *RestoreShardRequest, opts ...client.CallOption) (*RestoreShardResponse, error) {
|
|
|
|
wResp := &restoreShardResponseWrapper{new(RestoreShardResponse)}
|
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcRestoreShard), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.RestoreShardResponse, nil
|
|
|
|
}
|
2022-05-16 16:31:50 +00:00
|
|
|
|
|
|
|
// SynchronizeTree executes ControlService.SynchronizeTree RPC.
|
|
|
|
func SynchronizeTree(cli *client.Client, req *SynchronizeTreeRequest, opts ...client.CallOption) (*SynchronizeTreeResponse, error) {
|
|
|
|
wResp := &synchronizeTreeResponseWrapper{new(SynchronizeTreeResponse)}
|
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcSynchronizeTree), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.SynchronizeTreeResponse, nil
|
|
|
|
}
|
2022-09-13 10:28:08 +00:00
|
|
|
|
|
|
|
// EvacuateShard executes ControlService.EvacuateShard RPC.
|
|
|
|
func EvacuateShard(cli *client.Client, req *EvacuateShardRequest, opts ...client.CallOption) (*EvacuateShardResponse, error) {
|
|
|
|
wResp := &evacuateShardResponseWrapper{new(EvacuateShardResponse)}
|
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcEvacuateShard), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.EvacuateShardResponse, nil
|
|
|
|
}
|
2022-09-21 10:51:51 +00:00
|
|
|
|
|
|
|
// FlushCache executes ControlService.FlushCache RPC.
|
|
|
|
func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallOption) (*FlushCacheResponse, error) {
|
|
|
|
wResp := &flushCacheResponseWrapper{new(FlushCacheResponse)}
|
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcFlushCache), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.FlushCacheResponse, nil
|
|
|
|
}
|
2023-04-07 11:21:05 +00:00
|
|
|
|
|
|
|
// Doctor executes ControlService.Doctor RPC.
|
|
|
|
func Doctor(cli *client.Client, req *DoctorRequest, opts ...client.CallOption) (*DoctorResponse, error) {
|
|
|
|
wResp := &doctorResponseWrapper{new(DoctorResponse)}
|
|
|
|
wReq := &requestWrapper{m: req}
|
|
|
|
|
|
|
|
err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcDoctor), wReq, wResp, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return wResp.DoctorResponse, nil
|
|
|
|
}
|