2022-09-21 10:51:51 +00:00
|
|
|
package control
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/engine"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/control"
|
2022-09-21 10:51:51 +00:00
|
|
|
"google.golang.org/grpc/codes"
|
|
|
|
"google.golang.org/grpc/status"
|
|
|
|
)
|
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
func (s *Server) FlushCache(ctx context.Context, req *control.FlushCacheRequest) (*control.FlushCacheResponse, error) {
|
2022-09-21 10:51:51 +00:00
|
|
|
err := s.isValidRequest(req)
|
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.PermissionDenied, err.Error())
|
|
|
|
}
|
|
|
|
|
2022-10-10 18:14:12 +00:00
|
|
|
for _, shardID := range s.getShardIDList(req.GetBody().GetShard_ID()) {
|
2022-10-10 17:54:14 +00:00
|
|
|
var prm engine.FlushWriteCachePrm
|
|
|
|
prm.SetShardID(shardID)
|
2022-09-21 10:51:51 +00:00
|
|
|
|
2023-04-12 14:01:29 +00:00
|
|
|
_, err = s.s.FlushWriteCache(ctx, prm)
|
2022-10-10 17:54:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, status.Error(codes.Internal, err.Error())
|
|
|
|
}
|
2022-09-21 10:51:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|