[#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 27 additions and 3 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
|
||||
}
|
||||
|
|
BIN
pkg/services/control/types.pb.go
generated
BIN
pkg/services/control/types.pb.go
generated
Binary file not shown.
|
@ -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