forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
0b9622c418
Doctor RPC performs complex operations on the storage engine. Currently only duplicate removal is supported. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
37 lines
985 B
Go
37 lines
985 B
Go
package control
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
func (s *Server) Doctor(ctx context.Context, req *control.DoctorRequest) (*control.DoctorResponse, error) {
|
|
err := s.isValidRequest(req)
|
|
if err != nil {
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
}
|
|
|
|
if !req.Body.RemoveDuplicates {
|
|
return nil, status.Error(codes.InvalidArgument, "operation not specified")
|
|
}
|
|
|
|
var prm engine.RemoveDuplicatesPrm
|
|
prm.Concurrency = int(req.Body.Concurrency)
|
|
|
|
err = s.s.RemoveDuplicates(ctx, prm)
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
|
|
resp := &control.DoctorResponse{Body: &control.DoctorResponse_Body{}}
|
|
|
|
err = SignMessage(s.key, resp)
|
|
if err != nil {
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
}
|
|
return resp, nil
|
|
}
|