From 091d7d30f614e7538aaa3b5a59bd90ba1fb5d3a4 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 13 Sep 2022 13:28:08 +0300 Subject: [PATCH] [#1731] services/control: Allow to evacuate data from shard Signed-off-by: Evgenii Stratonikov --- pkg/services/control/convert.go | 18 +++++++++ pkg/services/control/ir/service.pb.go | Bin 14529 -> 14528 bytes pkg/services/control/ir/service_grpc.pb.go | Bin 3854 -> 3853 bytes pkg/services/control/ir/types.pb.go | Bin 7734 -> 7733 bytes pkg/services/control/rpc.go | 14 +++++++ pkg/services/control/server/evacuate.go | 41 +++++++++++++++++++++ pkg/services/control/service.pb.go | Bin 100537 -> 111461 bytes pkg/services/control/service.proto | 30 +++++++++++++++ pkg/services/control/service_grpc.pb.go | Bin 16664 -> 18306 bytes pkg/services/control/service_neofs.pb.go | Bin 47260 -> 52696 bytes pkg/services/control/types.pb.go | Bin 27109 -> 27108 bytes 11 files changed, 103 insertions(+) create mode 100644 pkg/services/control/server/evacuate.go diff --git a/pkg/services/control/convert.go b/pkg/services/control/convert.go index a4d0bced6..373bbabee 100644 --- a/pkg/services/control/convert.go +++ b/pkg/services/control/convert.go @@ -184,3 +184,21 @@ func (w *synchronizeTreeResponseWrapper) FromGRPCMessage(m grpc.Message) error { w.SynchronizeTreeResponse = r return nil } + +type evacuateShardResponseWrapper struct { + *EvacuateShardResponse +} + +func (w *evacuateShardResponseWrapper) ToGRPCMessage() grpc.Message { + return w.EvacuateShardResponse +} + +func (w *evacuateShardResponseWrapper) FromGRPCMessage(m grpc.Message) error { + r, ok := m.(*EvacuateShardResponse) + if !ok { + return message.NewUnexpectedMessageType(m, (*EvacuateShardResponse)(nil)) + } + + w.EvacuateShardResponse = r + return nil +} diff --git a/pkg/services/control/ir/service.pb.go b/pkg/services/control/ir/service.pb.go index 73bf274e2639a6953fb4dab1d429d078cd52d8b4..8d3c40a4109087cfc1800843111ae4d06509c734 100644 GIT binary patch delta 22 ecmX?Dc%X1X0i)@}LcfU*Dktt!*c{22VGaO$1qtr} delta 23 fcmX?5c(8Cn0i)5xLchtDjPeurR&S1A%rFN4c@POl diff --git a/pkg/services/control/ir/service_grpc.pb.go b/pkg/services/control/ir/service_grpc.pb.go index def51dacdfde504bc9c4426d8f6f0e8c073a2d6d..3753fae5c6801f87edec381afbcc77add6b93604 100644 GIT binary patch delta 15 WcmeB^>y?|(z-T(LF=68)9Xyw+%z-TnFF=68aT|NLV1_jvw diff --git a/pkg/services/control/ir/types.pb.go b/pkg/services/control/ir/types.pb.go index 4d18a2266830736ed33138268bb6373b1990101c..a71db096917d163fac09c8e5c0b86d34ee3fd2da 100644 GIT binary patch delta 22 ecmdmHv(;uo0i)@}LZ6BEDktty*c{GyUj_hifC<9@ delta 23 fcmdmLv(08g0i)5xLZ8XzjPetAS8onuye|U)ZwCn* diff --git a/pkg/services/control/rpc.go b/pkg/services/control/rpc.go index 13751e692..20b4df980 100644 --- a/pkg/services/control/rpc.go +++ b/pkg/services/control/rpc.go @@ -17,6 +17,7 @@ const ( rpcDumpShard = "DumpShard" rpcRestoreShard = "RestoreShard" rpcSynchronizeTree = "SynchronizeTree" + rpcEvacuateShard = "EvacuateShard" ) // HealthCheck executes ControlService.HealthCheck RPC. @@ -186,3 +187,16 @@ func SynchronizeTree(cli *client.Client, req *SynchronizeTreeRequest, opts ...cl return wResp.SynchronizeTreeResponse, nil } + +// EvacuateShard executes ControlService.EvacuateShard RPC. +func EvacuateShard(cli *client.Client, req *EvacuateShardRequest, opts ...client.CallOption) (*EvacuateShardResponse, error) { + wResp := &evacuateShardResponseWrapper{new(EvacuateShardResponse)} + wReq := &requestWrapper{m: req} + + err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcEvacuateShard), wReq, wResp, opts...) + if err != nil { + return nil, err + } + + return wResp.EvacuateShardResponse, nil +} diff --git a/pkg/services/control/server/evacuate.go b/pkg/services/control/server/evacuate.go new file mode 100644 index 000000000..8208a00ab --- /dev/null +++ b/pkg/services/control/server/evacuate.go @@ -0,0 +1,41 @@ +package control + +import ( + "context" + + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/engine" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard" + "github.com/nspcc-dev/neofs-node/pkg/services/control" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (s *Server) EvacuateShard(_ context.Context, req *control.EvacuateShardRequest) (*control.EvacuateShardResponse, error) { + err := s.isValidRequest(req) + if err != nil { + return nil, status.Error(codes.PermissionDenied, err.Error()) + } + + shardID := shard.NewIDFromBytes(req.GetBody().GetShard_ID()) + + var prm engine.EvacuateShardPrm + prm.WithShardID(shardID) + prm.WithIgnoreErrors(req.GetBody().GetIgnoreErrors()) + + res, err := s.s.Evacuate(prm) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &control.EvacuateShardResponse{ + Body: &control.EvacuateShardResponse_Body{ + Count: uint32(res.Count()), + }, + } + + err = SignMessage(s.key, resp) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + return resp, nil +} diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index 96a55b3791342d4fa0b5a5681a1e61519af71f24..919642a90cd927ccb752f8fe76ac2272f1548013 100644 GIT binary patch delta 5514 zcmbVQd32Q36+d^vOlBsN$z&lrVPpx}Gs`!VO_C52*~|`sBnXMguvE>)!~!vFqIE3^ zS8}@u#*YA3DQqiJn>iY;yL`@WgUqW0L%AK!WJzI*Tc z-FtuUes8{4`ZeBhOP(RH@jU}RUQ@Wo8W=^dm~EP zTX&e{Uz%TB*{~Y7rOpmh#DOOc2dxeD`>Ea1+|`Oho8tn`${V+0NB1mLyPE^D>(uP1dx(C zGer}fD+BI!yIk0#jq;3il>+`^_a=NKI0DZHtFhPpXI!~=96!*=bI+}}KNW=z25 zc)2$e+wNM5yF(%m8r67YBngN7!(cQGH{#~Iy=)qa&+Z7pvrndap1C6>2oK-q!rQ`U zWBHzcVeA85k7eJ83g0^5!ru7kgLen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>8CK|LiB0EVH@5e=P=UfGsK3!eQ;t6Fj95oRaJ!Zy~q^$AvIkY~zX`n;G^N z!CbNJDuQWrtq^p4CixG5$PJ?AN9=uD4@LmVu*R_gO3LRL6bpYvtQZcuK6rFi7N` zRt%Z`392W~yqFIlH`tF_i$U)9#JLMWUAiE zD*?Bdi2EflOYGB2nI|jNl|qibw?ey9nTWwuumWP}pCue_(sFS3ixZw77^WfCpHG~K znJ8vuC>d6OL%2>^0a-M5IrAu6`=`i{(h9l0j&d+7LnRa+tl%6Rlu`!s`hv)E?_^ym zWB)3ZvO^5m&nRjoBnq>cDMPe5Q@2yGf{|#Q${75URclK-IXxTB)-*L^(?0?*=3~) zFGLP5URhSMvTR=2ni7vbK-|1S?yx62Z9+cM_zZE_1rko5^Uwc>^<>-t137h}*OIsa z;=}3wdmtX>2I@ElpV9aokS-wp*zAH1D%=Tal=wdMKfLJ=$KVoe+r?T8htrfg)@uEj zwet4BxAc$Q>PozVjV4<_&XpOn$$vlijr}F}XCcWb*EbQj-&C}pxi zC1quKF diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index 28975091c7ed6d77b5958375512a03a331b7662e..b1962abce644bcca924c4c4abe6b1a204158c74a 100644 GIT binary patch delta 24 gcmaEQneoYG#t8+CrV|T2C*H1{xKm+s2;;;I0F`YELjV8( delta 53 zcmaEInepjm#t8+CMiUD?<%?3&a#E8^6qKM0B`(h5%DiL+B@n5^HE~Dv=3vH&82~g` B6Z`-G