forked from TrueCloudLab/frostfs-node
[#1118] services/control: return error counter in ListShards
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
7fb15fa1d0
commit
ed50cf6207
7 changed files with 40 additions and 5 deletions
|
@ -479,7 +479,8 @@ func prettyPrintShards(cmd *cobra.Command, ii []*control.ShardInfo) {
|
|||
cmd.Printf("Shard %s:\nMode: %s\n"+
|
||||
pathPrinter("Metabase", i.GetMetabasePath())+
|
||||
pathPrinter("Blobstor", i.GetBlobstorPath())+
|
||||
pathPrinter("Write-cache", i.GetWritecachePath())+"\n",
|
||||
pathPrinter("Write-cache", i.GetWritecachePath())+
|
||||
fmt.Sprintf("Error count: %d\n", i.GetErrorCount()),
|
||||
base58.Encode(i.Shard_ID),
|
||||
mode,
|
||||
)
|
||||
|
|
|
@ -17,7 +17,9 @@ func (e *StorageEngine) DumpInfo() (i Info) {
|
|||
i.Shards = make([]shard.Info, 0, len(e.shards))
|
||||
|
||||
for _, sh := range e.shards {
|
||||
i.Shards = append(i.Shards, sh.DumpInfo())
|
||||
info := sh.DumpInfo()
|
||||
info.ErrorCount = sh.errorCount.Load()
|
||||
i.Shards = append(i.Shards, info)
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -25,6 +25,9 @@ type Info struct {
|
|||
|
||||
// Weight parameters of the shard.
|
||||
WeightValues WeightValues
|
||||
|
||||
// ErrorCount contains amount of errors occurred in shard operations.
|
||||
ErrorCount uint32
|
||||
}
|
||||
|
||||
// DumpInfo returns information about the Shard.
|
||||
|
|
|
@ -45,6 +45,7 @@ func (s *Server) ListShards(_ context.Context, req *control.ListShardsRequest) (
|
|||
}
|
||||
|
||||
si.SetMode(mode)
|
||||
si.SetErrorCount(sh.ErrorCount)
|
||||
|
||||
shardInfos = append(shardInfos, si)
|
||||
}
|
||||
|
|
|
@ -342,6 +342,11 @@ func (x *ShardInfo) SetMode(v ShardMode) {
|
|||
x.Mode = v
|
||||
}
|
||||
|
||||
// SetErrorCount sets shard's error counter.
|
||||
func (x *ShardInfo) SetErrorCount(count uint32) {
|
||||
x.ErrorCount = count
|
||||
}
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
shardInfoIDFNum
|
||||
|
@ -349,6 +354,7 @@ const (
|
|||
shardInfoBlobstorFNum
|
||||
shardInfoWriteCacheFNum
|
||||
shardInfoModeFNum
|
||||
shardInfoErrorCountFNum
|
||||
)
|
||||
|
||||
// StableSize returns binary size of shard information
|
||||
|
@ -367,6 +373,7 @@ func (x *ShardInfo) StableSize() int {
|
|||
size += proto.StringSize(shardInfoBlobstorFNum, x.BlobstorPath)
|
||||
size += proto.StringSize(shardInfoWriteCacheFNum, x.WritecachePath)
|
||||
size += proto.EnumSize(shardInfoModeFNum, int32(x.Mode))
|
||||
size += proto.UInt32Size(shardInfoErrorCountFNum, x.ErrorCount)
|
||||
|
||||
return size
|
||||
}
|
||||
|
@ -422,7 +429,14 @@ func (x *ShardInfo) StableMarshal(buf []byte) ([]byte, error) {
|
|||
|
||||
offset += n
|
||||
|
||||
_, err = proto.EnumMarshal(shardInfoModeFNum, buf[offset:], int32(x.Mode))
|
||||
n, err = proto.EnumMarshal(shardInfoModeFNum, buf[offset:], int32(x.Mode))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
offset += n
|
||||
|
||||
_, err = proto.EnumMarshal(shardInfoErrorCountFNum, buf[offset:], int32(x.ErrorCount))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
15
pkg/services/control/types.pb.go
generated
15
pkg/services/control/types.pb.go
generated
|
@ -398,6 +398,8 @@ type ShardInfo struct {
|
|||
WritecachePath string `protobuf:"bytes,4,opt,name=writecache_path,json=writecachePath,proto3" json:"writecache_path,omitempty"`
|
||||
// Work mode of the shard.
|
||||
Mode ShardMode `protobuf:"varint,5,opt,name=mode,proto3,enum=control.ShardMode" json:"mode,omitempty"`
|
||||
// Amount of errors occured.
|
||||
ErrorCount uint32 `protobuf:"varint,6,opt,name=errorCount,proto3" json:"errorCount,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ShardInfo) Reset() {
|
||||
|
@ -467,6 +469,13 @@ func (x *ShardInfo) GetMode() ShardMode {
|
|||
return ShardMode_SHARD_MODE_UNDEFINED
|
||||
}
|
||||
|
||||
func (x *ShardInfo) GetErrorCount() uint32 {
|
||||
if x != nil {
|
||||
return x.ErrorCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Administrator-defined Attributes of the NeoFS Storage Node.
|
||||
//
|
||||
// `Attribute` is a Key-Value metadata pair. Key name must be a valid UTF-8
|
||||
|
@ -603,7 +612,7 @@ var file_pkg_services_control_types_proto_rawDesc = []byte{
|
|||
0x05, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x12, 0x27, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18,
|
||||
0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x2e,
|
||||
0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x22,
|
||||
0xc1, 0x01, 0x0a, 0x09, 0x53, 0x68, 0x61, 0x72, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x0a,
|
||||
0xe1, 0x01, 0x0a, 0x09, 0x53, 0x68, 0x61, 0x72, 0x64, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x19, 0x0a,
|
||||
0x08, 0x73, 0x68, 0x61, 0x72, 0x64, 0x5f, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x49, 0x44, 0x12, 0x23, 0x0a, 0x0d, 0x6d, 0x65, 0x74, 0x61,
|
||||
0x62, 0x61, 0x73, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
|
@ -615,7 +624,9 @@ var file_pkg_services_control_types_proto_rawDesc = []byte{
|
|||
0x74, 0x65, 0x63, 0x61, 0x63, 0x68, 0x65, 0x50, 0x61, 0x74, 0x68, 0x12, 0x26, 0x0a, 0x04, 0x6d,
|
||||
0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x74,
|
||||
0x72, 0x6f, 0x6c, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d,
|
||||
0x6f, 0x64, 0x65, 0x2a, 0x4e, 0x0a, 0x0c, 0x4e, 0x65, 0x74, 0x6d, 0x61, 0x70, 0x53, 0x74, 0x61,
|
||||
0x6f, 0x64, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0a, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x2a, 0x4e, 0x0a, 0x0c, 0x4e, 0x65, 0x74, 0x6d, 0x61, 0x70, 0x53, 0x74, 0x61,
|
||||
0x74, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e,
|
||||
0x44, 0x45, 0x46, 0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4f, 0x4e, 0x4c,
|
||||
0x49, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x4f, 0x46, 0x46, 0x4c, 0x49, 0x4e, 0x45,
|
||||
|
|
|
@ -136,6 +136,9 @@ message ShardInfo {
|
|||
|
||||
// Work mode of the shard.
|
||||
ShardMode mode = 5;
|
||||
|
||||
// Amount of errors occured.
|
||||
uint32 errorCount = 6;
|
||||
}
|
||||
|
||||
// Work mode of the shard.
|
||||
|
|
Loading…
Reference in a new issue