2023-04-07 11:21:05 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
2024-05-16 09:11:57 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control/server/ctrlmessage"
|
2023-04-07 11:21:05 +00:00
|
|
|
"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())
|
|
|
|
}
|
|
|
|
|
2023-12-11 10:18:34 +00:00
|
|
|
if !req.GetBody().GetRemoveDuplicates() {
|
2023-04-07 11:21:05 +00:00
|
|
|
return nil, status.Error(codes.InvalidArgument, "operation not specified")
|
|
|
|
}
|
|
|
|
|
|
|
|
var prm engine.RemoveDuplicatesPrm
|
2023-12-11 10:18:34 +00:00
|
|
|
prm.Concurrency = int(req.GetBody().GetConcurrency())
|
2023-04-07 11:21:05 +00:00
|
|
|
|
|
|
|
err = s.s.RemoveDuplicates(ctx, prm)
|
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
resp := &control.DoctorResponse{Body: &control.DoctorResponse_Body{}}
|
|
|
|
|
2024-05-16 09:11:57 +00:00
|
|
|
err = ctrlmessage.Sign(s.key, resp)
|
2023-04-07 11:21:05 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
|
|
|
return resp, nil
|
|
|
|
}
|