From 5e843a73f9939c08171042dd5d1409dfaf13b58f Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Mon, 16 May 2022 16:23:09 +0300 Subject: [PATCH] [#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 --- cmd/neofs-cli/modules/control/shards_list.go | 1 + pkg/local_object_storage/pilorama/info.go | 24 ++++++++++++++++++ .../pilorama/interface.go | 2 ++ pkg/local_object_storage/shard/info.go | 4 +++ pkg/local_object_storage/shard/shard.go | 1 + pkg/services/control/server/list_shards.go | 1 + pkg/services/control/service_test.go | 1 + pkg/services/control/types.go | 5 ++++ pkg/services/control/types.pb.go | Bin 26304 -> 26791 bytes pkg/services/control/types.proto | 3 +++ pkg/services/control/types_neofs.pb.go | Bin 5782 -> 5891 bytes pkg/services/control/types_test.go | 1 + pkg/services/tree/service.pb.go | Bin 97443 -> 97443 bytes pkg/services/tree/service_grpc.pb.go | Bin 15010 -> 15010 bytes pkg/services/tree/types.pb.go | Bin 9666 -> 9666 bytes 15 files changed, 43 insertions(+) create mode 100644 pkg/local_object_storage/pilorama/info.go diff --git a/cmd/neofs-cli/modules/control/shards_list.go b/cmd/neofs-cli/modules/control/shards_list.go index 7244ebd0d..9ee986805 100644 --- a/cmd/neofs-cli/modules/control/shards_list.go +++ b/cmd/neofs-cli/modules/control/shards_list.go @@ -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()), diff --git a/pkg/local_object_storage/pilorama/info.go b/pkg/local_object_storage/pilorama/info.go new file mode 100644 index 000000000..0040b9dca --- /dev/null +++ b/pkg/local_object_storage/pilorama/info.go @@ -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", + } +} diff --git a/pkg/local_object_storage/pilorama/interface.go b/pkg/local_object_storage/pilorama/interface.go index 92c47b6af..6d685e951 100644 --- a/pkg/local_object_storage/pilorama/interface.go +++ b/pkg/local_object_storage/pilorama/interface.go @@ -36,6 +36,8 @@ type Forest interface { } type ForestStorage interface { + // DumpInfo returns information about the pilorama. + DumpInfo() Info Init() error Open() error Close() error diff --git a/pkg/local_object_storage/shard/info.go b/pkg/local_object_storage/shard/info.go index fbc26e519..deb46cd44 100644 --- a/pkg/local_object_storage/shard/info.go +++ b/pkg/local_object_storage/shard/info.go @@ -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. diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index f9f3a01f8..7e5a039ba 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -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() } diff --git a/pkg/services/control/server/list_shards.go b/pkg/services/control/server/list_shards.go index 3cc89284b..d896ec6d0 100644 --- a/pkg/services/control/server/list_shards.go +++ b/pkg/services/control/server/list_shards.go @@ -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 diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index c80d8ee8f..8a3167543 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -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 } diff --git a/pkg/services/control/types.go b/pkg/services/control/types.go index 4d4c11196..406a1896a 100644 --- a/pkg/services/control/types.go +++ b/pkg/services/control/types.go @@ -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 diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index 2b1ee90089f7c4f868015d624773e9f901a4139f..c22eb0a7e362803deb41ad3485625c9277c53cd9 100644 GIT binary patch delta 702 zcmZuu!E4iC6ep7v69lJBx6TA&2Ca^4W?4b1j-tWU)hG?$@29>EV{&F}-=H};@M9r2@h_psT}AFh$*oRHH;mqW>u`4OykqLtZOiVx zC|@2Hvo;}nj=7LylVZ`L=$zu%;JC^>>z!Fo|v z+!H3*-!QQyN(8c14IdT{qFiP1ofK-Gf+y8^s(y6ycpV(TsFx>r#-mnskDU)0yz7JC zo`$z&1804mgeyJ?@A@p<^fhd`Dz^O`)s6-lbfKai9W%04kqWkfv%_GRWO|) zL7{*z?%1C6S1?p7=|nmFMGiY1UcBAUqg2$WmALUvnHN)JgWW{8tm1o(H~Q$@aa=l| P$MVwtbgtgo(v^`vd9ltj delta 403 zcmZ2}k@3J;#trARCf`%ynQUXoy}3nuJ?rLKhC-4YsfIcV1{DT|lfQ=OPfqa?-~7u< zh;{Ot0Nu&!+~kmOHU37RGZut4Cc-XbYxVRd^b=QB=;N4u?qroVuC<2^C6tQ zAkL&t`|9I+PP+4a5XP6Lb?y3_&KOggQ>1 z9|(5VzCh{84?@*|PUZ*$yI(B~w91bDS*hB{114oDUQnp5Y*cJ>jyG mi~PhU?+e$Ryu?9{jf>Nu!YFOBpsU_w+X#L}h0T5ukpckTvT{TK diff --git a/pkg/services/control/types.proto b/pkg/services/control/types.proto index a786c7b12..f9c8cef2c 100644 --- a/pkg/services/control/types.proto +++ b/pkg/services/control/types.proto @@ -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. diff --git a/pkg/services/control/types_neofs.pb.go b/pkg/services/control/types_neofs.pb.go index 5fe19be943814df060243c61d213e9692976c14d..8dd46362eb57239996e0fef9b9decddd331c1d46 100644 GIT binary patch delta 86 zcmbQH+pM?YiO^(YAxS}V9fb1K^BGNQ07&EqH~;_u delta 17 YcmZ4dlXdY=)(Lrx295b!^BGNQ07%>iHvj+t diff --git a/pkg/services/tree/service_grpc.pb.go b/pkg/services/tree/service_grpc.pb.go index 956a003295ee095c6f18205182607df4007fd39a..7de60958c8118e3aa2403261ab52fa45d05b5eee 100644 GIT binary patch delta 12 TcmZ2fx~OzQ9i!pKdSxpBB+3N* delta 12 TcmZ2fx~OzQ9izd