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.

34 lines
1.1 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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. }