[#1048] node: Fill shard's info with its components' infos

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-12-20 13:03:06 +03:00 committed by Alex Vanin
parent 0e5410603e
commit 284188f8f9
3 changed files with 29 additions and 2 deletions

View file

@ -3,6 +3,7 @@ package shard
import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
)
// Info groups the information about Shard.
@ -17,7 +18,7 @@ type Info struct {
BlobStorInfo blobstor.Info
// Information about the Write Cache.
WriteCacheInfo blobstor.Info
WriteCacheInfo writecache.Info
// Weight parameters of the shard.
WeightValues WeightValues

View file

@ -84,13 +84,17 @@ func New(opts ...Option) *Shard {
writecache.WithMetabase(mb))...)
}
return &Shard{
s := &Shard{
cfg: c,
mode: atomic.NewUint32(0), // TODO: init with particular mode
blobStor: bs,
metaBase: mb,
writeCache: writeCache,
}
s.fillInfo()
return s
}
// WithID returns option to set shard identifier.
@ -192,3 +196,12 @@ func WithRefillMetabase(v bool) Option {
c.refillMetabase = v
}
}
func (s *Shard) fillInfo() {
s.cfg.info.MetaBaseInfo = s.metaBase.DumpInfo()
s.cfg.info.BlobStorInfo = s.blobStor.DumpInfo()
if s.cfg.useWriteCache {
s.cfg.info.WriteCacheInfo = s.writeCache.DumpInfo()
}
}

View file

@ -9,12 +9,19 @@ import (
"go.uber.org/zap"
)
// Info groups the information about write-cache.
type Info struct {
// Full path to the write-cache.
Path string
}
// Cache represents write-cache for objects.
type Cache interface {
Get(*objectSDK.Address) (*object.Object, error)
Head(*objectSDK.Address) (*object.Object, error)
Delete(*objectSDK.Address) error
Put(*object.Object) error
DumpInfo() Info
Init() error
Open() error
@ -90,6 +97,12 @@ func New(opts ...Option) Cache {
return c
}
func (c *cache) DumpInfo() Info {
return Info{
Path: c.path,
}
}
// Open opens and initializes database. Reads object counters from the ObjectCounters instance.
func (c *cache) Open() error {
err := c.openStore()