store_vacuum.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package storage
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/storage/needle"
  6. )
  7. func (s *Store) CheckCompactVolume(volumeId needle.VolumeId) (float64, error) {
  8. if v := s.findVolume(volumeId); v != nil {
  9. glog.V(3).Infof("volumd %d garbage level: %f", volumeId, v.garbageLevel())
  10. return v.garbageLevel(), nil
  11. }
  12. return 0, fmt.Errorf("volume id %d is not found during check compact", volumeId)
  13. }
  14. func (s *Store) CompactVolume(vid needle.VolumeId, preallocate int64, compactionBytePerSecond int64) error {
  15. if v := s.findVolume(vid); v != nil {
  16. return v.Compact2(preallocate, compactionBytePerSecond)
  17. }
  18. return fmt.Errorf("volume id %d is not found during compact", vid)
  19. }
  20. func (s *Store) CommitCompactVolume(vid needle.VolumeId) error {
  21. if v := s.findVolume(vid); v != nil {
  22. return v.CommitCompact()
  23. }
  24. return fmt.Errorf("volume id %d is not found during commit compact", vid)
  25. }
  26. func (s *Store) CommitCleanupVolume(vid needle.VolumeId) error {
  27. if v := s.findVolume(vid); v != nil {
  28. return v.cleanupCompact()
  29. }
  30. return fmt.Errorf("volume id %d is not found during cleaning up", vid)
  31. }