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.

35 lines
1.2 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. // return v.Compact(preallocate, compactionBytePerSecond)
  18. }
  19. return fmt.Errorf("volume id %d is not found during compact", vid)
  20. }
  21. func (s *Store) CommitCompactVolume(vid needle.VolumeId) error {
  22. if v := s.findVolume(vid); v != nil {
  23. return v.CommitCompact()
  24. }
  25. return fmt.Errorf("volume id %d is not found during commit compact", vid)
  26. }
  27. func (s *Store) CommitCleanupVolume(vid needle.VolumeId) error {
  28. if v := s.findVolume(vid); v != nil {
  29. return v.cleanupCompact()
  30. }
  31. return fmt.Errorf("volume id %d is not found during cleaning up", vid)
  32. }