[#1118] services/control: return error counter in ListShards

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-01-31 18:23:19 +03:00 committed by Alex Vanin
parent 7fb15fa1d0
commit ed50cf6207
7 changed files with 27 additions and 3 deletions

View file

@ -479,7 +479,8 @@ func prettyPrintShards(cmd *cobra.Command, ii []*control.ShardInfo) {
cmd.Printf("Shard %s:\nMode: %s\n"+ cmd.Printf("Shard %s:\nMode: %s\n"+
pathPrinter("Metabase", i.GetMetabasePath())+ pathPrinter("Metabase", i.GetMetabasePath())+
pathPrinter("Blobstor", i.GetBlobstorPath())+ 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), base58.Encode(i.Shard_ID),
mode, mode,
) )

View file

@ -17,7 +17,9 @@ func (e *StorageEngine) DumpInfo() (i Info) {
i.Shards = make([]shard.Info, 0, len(e.shards)) i.Shards = make([]shard.Info, 0, len(e.shards))
for _, sh := range 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 return

View file

@ -25,6 +25,9 @@ type Info struct {
// Weight parameters of the shard. // Weight parameters of the shard.
WeightValues WeightValues WeightValues WeightValues
// ErrorCount contains amount of errors occurred in shard operations.
ErrorCount uint32
} }
// DumpInfo returns information about the Shard. // DumpInfo returns information about the Shard.

View file

@ -45,6 +45,7 @@ func (s *Server) ListShards(_ context.Context, req *control.ListShardsRequest) (
} }
si.SetMode(mode) si.SetMode(mode)
si.SetErrorCount(sh.ErrorCount)
shardInfos = append(shardInfos, si) shardInfos = append(shardInfos, si)
} }

View file

@ -342,6 +342,11 @@ func (x *ShardInfo) SetMode(v ShardMode) {
x.Mode = v x.Mode = v
} }
// SetErrorCount sets shard's error counter.
func (x *ShardInfo) SetErrorCount(count uint32) {
x.ErrorCount = count
}
const ( const (
_ = iota _ = iota
shardInfoIDFNum shardInfoIDFNum
@ -349,6 +354,7 @@ const (
shardInfoBlobstorFNum shardInfoBlobstorFNum
shardInfoWriteCacheFNum shardInfoWriteCacheFNum
shardInfoModeFNum shardInfoModeFNum
shardInfoErrorCountFNum
) )
// StableSize returns binary size of shard information // 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(shardInfoBlobstorFNum, x.BlobstorPath)
size += proto.StringSize(shardInfoWriteCacheFNum, x.WritecachePath) size += proto.StringSize(shardInfoWriteCacheFNum, x.WritecachePath)
size += proto.EnumSize(shardInfoModeFNum, int32(x.Mode)) size += proto.EnumSize(shardInfoModeFNum, int32(x.Mode))
size += proto.UInt32Size(shardInfoErrorCountFNum, x.ErrorCount)
return size return size
} }
@ -422,7 +429,14 @@ func (x *ShardInfo) StableMarshal(buf []byte) ([]byte, error) {
offset += n 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 { if err != nil {
return nil, err return nil, err
} }

Binary file not shown.

View file

@ -136,6 +136,9 @@ message ShardInfo {
// Work mode of the shard. // Work mode of the shard.
ShardMode mode = 5; ShardMode mode = 5;
// Amount of errors occured.
uint32 errorCount = 6;
} }
// Work mode of the shard. // Work mode of the shard.