forked from nspcc-dev/neofs-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nspcc-dev#1731] services/control: Allow to evacuate data from shard
Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
- Loading branch information
1 parent
5e28909
commit 4a1ac2f
Showing
11 changed files
with
812 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
Oops, something went wrong.