From 51b8f26a312d559f47fb05f267fe6036b68347f5 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 21 Sep 2022 13:51:51 +0300 Subject: [PATCH] [#1806] services/control: Allow to flush write-cache 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/flush_cache.go | 36 +++++++++++++++++++++ pkg/services/control/service.pb.go | Bin 100929 -> 110686 bytes pkg/services/control/service.proto | 25 ++++++++++++++ pkg/services/control/service_grpc.pb.go | Bin 16645 -> 18212 bytes pkg/services/control/service_neofs.pb.go | Bin 47539 -> 52624 bytes pkg/services/control/types.pb.go | Bin 27109 -> 27108 bytes 11 files changed, 93 insertions(+) create mode 100644 pkg/services/control/server/flush_cache.go diff --git a/pkg/services/control/convert.go b/pkg/services/control/convert.go index 39cad6aff..041af61e4 100644 --- a/pkg/services/control/convert.go +++ b/pkg/services/control/convert.go @@ -182,3 +182,21 @@ func (w *evacuateShardResponseWrapper) FromGRPCMessage(m grpc.Message) error { w.EvacuateShardResponse = r return nil } + +type flushCacheResponseWrapper struct { + *FlushCacheResponse +} + +func (w *flushCacheResponseWrapper) ToGRPCMessage() grpc.Message { + return w.FlushCacheResponse +} + +func (w *flushCacheResponseWrapper) FromGRPCMessage(m grpc.Message) error { + r, ok := m.(*FlushCacheResponse) + if !ok { + return message.NewUnexpectedMessageType(m, (*FlushCacheResponse)(nil)) + } + + w.FlushCacheResponse = r + return nil +} diff --git a/pkg/services/control/ir/service.pb.go b/pkg/services/control/ir/service.pb.go index 7e1f7d9e37221498ada89759a5455e582d5ccae9..dd8fa73641778a22b3b3e58d6eb0b004648836fb 100644 GIT binary patch delta 17 ZcmX?Dc%X2?{)rDNC+<_&9Lbnr4ggt42)Fhe%@)P$~Z;oKhFb4ouO9&GH diff --git a/pkg/services/control/ir/service_grpc.pb.go b/pkg/services/control/ir/service_grpc.pb.go index 7a053876e9e10087e4954bb9124b57ab3fefe97a..bd98e881cc4ff1a8787d6706b834fadb1d5021ac 100644 GIT binary patch delta 10 RcmeB^>y?}EaN{E#J^&eW1eO2* delta 10 RcmeB`>yw-CaN`4AJ^&eQ1eE{) diff --git a/pkg/services/control/ir/types.pb.go b/pkg/services/control/ir/types.pb.go index d76fcc770028f56e76e44a0b32e6a12e10327c80..9f00354caef30819f85d86c54bcc0cd25c057609 100644 GIT binary patch delta 17 ZcmdmHv(;w8-ih}rC+<<$9L{)O1^`k*2#f## delta 18 acmdmLv(0A0-pS^S@)LJgZw_O;F9QHh!UyL7 diff --git a/pkg/services/control/rpc.go b/pkg/services/control/rpc.go index 6c70d9e6b..b0be2a7f2 100644 --- a/pkg/services/control/rpc.go +++ b/pkg/services/control/rpc.go @@ -17,6 +17,7 @@ const ( rpcRestoreShard = "RestoreShard" rpcSynchronizeTree = "SynchronizeTree" rpcEvacuateShard = "EvacuateShard" + rpcFlushCache = "FlushCache" ) // HealthCheck executes ControlService.HealthCheck RPC. @@ -177,3 +178,16 @@ func EvacuateShard(cli *client.Client, req *EvacuateShardRequest, opts ...client return wResp.EvacuateShardResponse, nil } + +// FlushCache executes ControlService.FlushCache RPC. +func FlushCache(cli *client.Client, req *FlushCacheRequest, opts ...client.CallOption) (*FlushCacheResponse, error) { + wResp := &flushCacheResponseWrapper{new(FlushCacheResponse)} + wReq := &requestWrapper{m: req} + + err := client.SendUnary(cli, common.CallMethodInfoUnary(serviceName, rpcFlushCache), wReq, wResp, opts...) + if err != nil { + return nil, err + } + + return wResp.FlushCacheResponse, nil +} diff --git a/pkg/services/control/server/flush_cache.go b/pkg/services/control/server/flush_cache.go new file mode 100644 index 000000000..baf1eb620 --- /dev/null +++ b/pkg/services/control/server/flush_cache.go @@ -0,0 +1,36 @@ +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) FlushCache(_ context.Context, req *control.FlushCacheRequest) (*control.FlushCacheResponse, 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.FlushWriteCachePrm + prm.SetShardID(shardID) + + _, err = s.s.FlushWriteCache(prm) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + resp := &control.FlushCacheResponse{Body: &control.FlushCacheResponse_Body{}} + + 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 0bef278bd472473409e1c5c040646d93f2a1fbb1..104d511b6b648bad536518a599193e64d08486db 100644 GIT binary patch delta 5378 zcmbVQc~q3w6+d@i24+K$)eS~82sjM0&j5y1jmVBc4U#Cz&{!2nAc<%Q7^BV7MC2yi zTGIgO$!-(v^pu`fjcw8)t;07GxP5Hes_8I zd*AoR$5o&BRNeb`o@n3s2ZMJh47DULTz^;V?M3x#Zuc1O^xScmr?t(bX=`us7$yW* zV1EE#Ua!?ma6EW0wHz-rCS%TqrRoVbj@3>LQa#Q!*wNZ3x3UzK%E?vA8|38qinaJf z+i1`O9>3Khqt3gVrdr$`nhuSo@vf#dhSZIQ^ohMaXo-oDdox!T%WP+^Tsb?a%aOLW zG&i++{yS6;4uoG7YrVRHW1WSDAIW2lnm0|p-AYXZcDH-vtb*b)Ik|6kiVV=m>UFFi zimJ^cGVWNeRc=zLZ=RBM-GIkaVr8agPl?=guWco64v+C>-8mod-<^%v7d9D(!<6`4 z>z8=vmeY7b<)?4#O~ZtM?B3qSU+%a&1ZQm%`g$DSs7K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f+0DHEj^5o+|MR{vv-^Rw;Kd zoqiFf`&i{}?N&pQ)kaxcAVw=Q-)=D`Sq(xnA$VPxb7N(GWwq1c?PVD?Ta3aSNSZqC z@#YrLKIQt9Eu1?LxXzh%FeQ*~5lF9Zy4(Vv(A>R{E>r_l+yZG7`YVn%aX)-Udq@^_ z*b}0myGI$@y^pawxAKIYt?);>y`K>*@*}ZTMfZ-v$27iGL^}jpoZ7CT&qRV*2N=bw zekwW0r;r`|av6T=Qg}ODpgo6VwRq$Xhk37!!=$_d{#f6olEZx6&L~!CsOb&(6OBF0 z;)x?%w(Sl1H2TUErF=qH8#%_*-*OCoGVXRuVLqlEM_KEB4a9p<+sQy3ko|Y?1$}j# b!|+LZ&r$pDVJ~ev33vEY>a08k|APMmS5js5 diff --git a/pkg/services/control/service.proto b/pkg/services/control/service.proto index 3f55d3ccb..fba8ee99a 100644 --- a/pkg/services/control/service.proto +++ b/pkg/services/control/service.proto @@ -34,6 +34,9 @@ service ControlService { // EvacuateShard moves all data from one shard to the others. rpc EvacuateShard (EvacuateShardRequest) returns (EvacuateShardResponse); + + // FlushCache moves all data from one shard to the others. + rpc FlushCache (FlushCacheRequest) returns (FlushCacheResponse); } // Health check request. @@ -311,3 +314,25 @@ message EvacuateShardResponse { Body body = 1; Signature signature = 2; } + +// FlushCache request. +message FlushCacheRequest { + // Request body structure. + message Body { + // ID of the shard. + bytes shard_ID = 1; + } + + Body body = 1; + Signature signature = 2; +} + +// FlushCache response. +message FlushCacheResponse { + // Response body structure. + message Body { + } + + Body body = 1; + Signature signature = 2; +} diff --git a/pkg/services/control/service_grpc.pb.go b/pkg/services/control/service_grpc.pb.go index f7523b98c4080960f993c9e1070b73687a3dd775..1978deb67d45d4f355bbc2cd3815277d7ce84e01 100644 GIT binary patch delta 454 zcmZo|VqDV4IN{#L`$im-7l^ZPx#g4=XE-M&XQWQnlhQ}#I_in>X67kq!BtFlWK%^_ zu!&QHXYvDKc_g99SoLrsOqi%BI{AShH(4+|rD#=y%q`oZ8ra~-p(?4g1s=Z<^^_2 J$lUo3X#kTFpf&&i delta 41 zcmV+^0M`Gcjsb;&0g&FY-7^TYx(OEyvkDiB1+yO=DG0L{CL9^FzCpJHlg>s~N)Hbo diff --git a/pkg/services/control/service_neofs.pb.go b/pkg/services/control/service_neofs.pb.go index 70616a79801049d18ce3b127dc869ea3212ce2dc..00979f012d55631afae8a0366fd9adfc4fd478f1 100644 GIT binary patch delta 242 zcmdn|nQ6jo<_(*7PM#3c$?29;TAbmWn4B@$Fhq3nzd+l~#w-&VQG{<#{=z$r3$8GA z^EzfRCWMO34b!GFAxTfZAbS@fJDGo0KCHwl+W`QM>t3n= delta 9 RcmbO*n|bqRrVX2S0st2-1oHp@ diff --git a/pkg/services/control/types.pb.go b/pkg/services/control/types.pb.go index 4f95fa12ae37384f0212aa292d14c02e35e3ca28..7056a225f38a593628095f94fcfd090224db0cf5 100644 GIT binary patch delta 19 bcmaEQneoYG#tFM7-maXuQ(5UIp9aYyy$V8)3V0P2ns$N&HU