You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0 KiB

  1. package weed_server
  2. import (
  3. "context"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/chrislusf/seaweedfs/weed/storage"
  7. )
  8. func (vs *VolumeServer) VacuumVolumeCheck(ctx context.Context, req *volume_server_pb.VacuumVolumeCheckRequest) (*volume_server_pb.VacuumVolumeCheckResponse, error) {
  9. resp := &volume_server_pb.VacuumVolumeCheckResponse{}
  10. garbageRatio, err := vs.store.CheckCompactVolume(storage.VolumeId(req.VolumdId))
  11. resp.GarbageRatio = garbageRatio
  12. if err != nil {
  13. glog.V(3).Infof("check volume %d: %v", req.VolumdId, err)
  14. }
  15. return resp, err
  16. }
  17. func (vs *VolumeServer) VacuumVolumeCompact(ctx context.Context, req *volume_server_pb.VacuumVolumeCompactRequest) (*volume_server_pb.VacuumVolumeCompactResponse, error) {
  18. resp := &volume_server_pb.VacuumVolumeCompactResponse{}
  19. err := vs.store.CompactVolume(storage.VolumeId(req.VolumdId), req.Preallocate)
  20. if err != nil {
  21. glog.Errorf("compact volume %d: %v", req.VolumdId, err)
  22. } else {
  23. glog.V(1).Infof("compact volume %d", req.VolumdId)
  24. }
  25. return resp, err
  26. }
  27. func (vs *VolumeServer) VacuumVolumeCommit(ctx context.Context, req *volume_server_pb.VacuumVolumeCommitRequest) (*volume_server_pb.VacuumVolumeCommitResponse, error) {
  28. resp := &volume_server_pb.VacuumVolumeCommitResponse{}
  29. err := vs.store.CommitCompactVolume(storage.VolumeId(req.VolumdId))
  30. if err != nil {
  31. glog.Errorf("commit volume %d: %v", req.VolumdId, err)
  32. } else {
  33. glog.V(1).Infof("commit volume %d", req.VolumdId)
  34. }
  35. return resp, err
  36. }
  37. func (vs *VolumeServer) VacuumVolumeCleanup(ctx context.Context, req *volume_server_pb.VacuumVolumeCleanupRequest) (*volume_server_pb.VacuumVolumeCleanupResponse, error) {
  38. resp := &volume_server_pb.VacuumVolumeCleanupResponse{}
  39. err := vs.store.CommitCleanupVolume(storage.VolumeId(req.VolumdId))
  40. if err != nil {
  41. glog.Errorf("cleanup volume %d: %v", req.VolumdId, err)
  42. } else {
  43. glog.V(1).Infof("cleanup volume %d", req.VolumdId)
  44. }
  45. return resp, err
  46. }