[#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 ( import (
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor" "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor"
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase" 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. // Info groups the information about Shard.
@ -17,7 +18,7 @@ type Info struct {
BlobStorInfo blobstor.Info BlobStorInfo blobstor.Info
// Information about the Write Cache. // Information about the Write Cache.
WriteCacheInfo blobstor.Info WriteCacheInfo writecache.Info
// Weight parameters of the shard. // Weight parameters of the shard.
WeightValues WeightValues WeightValues WeightValues

View file

@ -84,13 +84,17 @@ func New(opts ...Option) *Shard {
writecache.WithMetabase(mb))...) writecache.WithMetabase(mb))...)
} }
return &Shard{ s := &Shard{
cfg: c, cfg: c,
mode: atomic.NewUint32(0), // TODO: init with particular mode mode: atomic.NewUint32(0), // TODO: init with particular mode
blobStor: bs, blobStor: bs,
metaBase: mb, metaBase: mb,
writeCache: writeCache, writeCache: writeCache,
} }
s.fillInfo()
return s
} }
// WithID returns option to set shard identifier. // WithID returns option to set shard identifier.
@ -192,3 +196,12 @@ func WithRefillMetabase(v bool) Option {
c.refillMetabase = v 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" "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. // Cache represents write-cache for objects.
type Cache interface { type Cache interface {
Get(*objectSDK.Address) (*object.Object, error) Get(*objectSDK.Address) (*object.Object, error)
Head(*objectSDK.Address) (*object.Object, error) Head(*objectSDK.Address) (*object.Object, error)
Delete(*objectSDK.Address) error Delete(*objectSDK.Address) error
Put(*object.Object) error Put(*object.Object) error
DumpInfo() Info
Init() error Init() error
Open() error Open() error
@ -90,6 +97,12 @@ func New(opts ...Option) Cache {
return c return c
} }
func (c *cache) DumpInfo() Info {
return Info{
Path: c.path,
}
}
// Open opens and initializes database. Reads object counters from the ObjectCounters instance. // Open opens and initializes database. Reads object counters from the ObjectCounters instance.
func (c *cache) Open() error { func (c *cache) Open() error {
err := c.openStore() err := c.openStore()