[#1333] services/control: Return pilorama info in ListShards RPC

Do not return backend type from the service for now, because memory
backend is expected to vanish.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
Evgenii Stratonikov 2022-05-16 16:23:09 +03:00 committed by fyrchik
parent 8f4ee1aded
commit 5e843a73f9
15 changed files with 43 additions and 0 deletions

View file

@ -93,6 +93,7 @@ func prettyPrintShards(cmd *cobra.Command, ii []*control.ShardInfo) {
pathPrinter("Metabase", i.GetMetabasePath())+
pathPrinter("Blobstor", i.GetBlobstorPath())+
pathPrinter("Write-cache", i.GetWritecachePath())+
pathPrinter("Pilorama", i.GetPiloramaPath())+
fmt.Sprintf("Error count: %d\n", i.GetErrorCount()),
base58.Encode(i.Shard_ID),
shardModeToString(i.GetMode()),

View file

@ -0,0 +1,24 @@
package pilorama
// Info groups the information about the pilorama.
type Info struct {
// Path contains path to the root-directory of the pilorama.
Path string
// Backend is the pilorama storage type. Either "boltdb" or "memory".
Backend string
}
// DumpInfo implements the ForestStorage interface.
func (t *boltForest) DumpInfo() Info {
return Info{
Path: t.path,
Backend: "boltdb",
}
}
// DumpInfo implements the ForestStorage interface.
func (f *memoryForest) DumpInfo() Info {
return Info{
Backend: "memory",
}
}

View file

@ -36,6 +36,8 @@ type Forest interface {
}
type ForestStorage interface {
// DumpInfo returns information about the pilorama.
DumpInfo() Info
Init() error
Open() error
Close() error

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/pilorama"
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/writecache"
)
@ -28,6 +29,9 @@ type Info struct {
// ErrorCount contains amount of errors occurred in shard operations.
ErrorCount uint32
// PiloramaInfo contains information about trees stored on this shard.
PiloramaInfo pilorama.Info
}
// DumpInfo returns information about the Shard.

View file

@ -255,4 +255,5 @@ func (s *Shard) fillInfo() {
if s.cfg.useWriteCache {
s.cfg.info.WriteCacheInfo = s.writeCache.DumpInfo()
}
s.cfg.info.PiloramaInfo = s.pilorama.DumpInfo()
}

View file

@ -32,6 +32,7 @@ func (s *Server) ListShards(_ context.Context, req *control.ListShardsRequest) (
si.SetMetabasePath(sh.MetaBaseInfo.Path)
si.SetBlobstorPath(sh.BlobStorInfo.RootPath)
si.SetWriteCachePath(sh.WriteCacheInfo.Path)
si.SetPiloramaPath(sh.PiloramaInfo.Path)
var mode control.ShardMode

View file

@ -103,6 +103,7 @@ func equalListShardResponseBodies(b1, b2 *control.ListShardsResponse_Body) bool
if b1.Shards[i].GetMetabasePath() != b2.Shards[i].GetMetabasePath() ||
b1.Shards[i].GetBlobstorPath() != b2.Shards[i].GetBlobstorPath() ||
b1.Shards[i].GetWritecachePath() != b2.Shards[i].GetWritecachePath() ||
b1.Shards[i].GetPiloramaPath() != b2.Shards[i].GetPiloramaPath() ||
!bytes.Equal(b1.Shards[i].GetShard_ID(), b2.Shards[i].GetShard_ID()) {
return false
}

View file

@ -107,6 +107,11 @@ func (x *ShardInfo) SetWriteCachePath(v string) {
x.WritecachePath = v
}
// SetPiloramaPath sets path to shard's pilorama.
func (x *ShardInfo) SetPiloramaPath(v string) {
x.PiloramaPath = v
}
// SetMode sets path to shard's work mode.
func (x *ShardInfo) SetMode(v ShardMode) {
x.Mode = v

Binary file not shown.

View file

@ -139,6 +139,9 @@ message ShardInfo {
// Amount of errors occured.
uint32 errorCount = 6;
// Path to shard's pilorama storage.
string pilorama_path = 7 [json_name = "piloramaPath"];
}
// Work mode of the shard.

Binary file not shown.

View file

@ -140,6 +140,7 @@ func generateShardInfo(id int) *control.ShardInfo {
si.SetMetabasePath(filepath.Join(path, "meta"))
si.SetBlobstorPath(filepath.Join(path, "blobstor"))
si.SetWriteCachePath(filepath.Join(path, "writecache"))
si.SetPiloramaPath(filepath.Join(path, "pilorama"))
return si
}

Binary file not shown.

Binary file not shown.

Binary file not shown.