diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-10-14 23:12:43 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-10-14 23:12:43 -0700 |
| commit | b1daede91bca63bf2ca3019f622e763d35969e4f (patch) | |
| tree | 2078fd7bc116e12f0eeb2c3015c3568b90163b57 /weed/storage | |
| parent | 91ac2e0dd920c0f629f4076202267afbac74a62c (diff) | |
| download | seaweedfs-b1daede91bca63bf2ca3019f622e763d35969e4f.tar.xz seaweedfs-b1daede91bca63bf2ca3019f622e763d35969e4f.zip | |
move volume vacuum to gRpc
Diffstat (limited to 'weed/storage')
| -rw-r--r-- | weed/storage/store_vacuum.go | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/weed/storage/store_vacuum.go b/weed/storage/store_vacuum.go index 3ada1f49c..cc0521491 100644 --- a/weed/storage/store_vacuum.go +++ b/weed/storage/store_vacuum.go @@ -2,51 +2,29 @@ package storage import ( "fmt" - "strconv" - "github.com/chrislusf/seaweedfs/weed/glog" ) -func (s *Store) CheckCompactVolume(volumeIdString string, garbageThresholdString string) (error, bool) { - vid, err := NewVolumeId(volumeIdString) - if err != nil { - return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString), false - } - garbageThreshold, e := strconv.ParseFloat(garbageThresholdString, 32) - if e != nil { - return fmt.Errorf("garbageThreshold %s is not a valid float number", garbageThresholdString), false - } - if v := s.findVolume(vid); v != nil { - glog.V(3).Infoln(vid, "garbage level is", v.garbageLevel()) - return nil, garbageThreshold < v.garbageLevel() +func (s *Store) CheckCompactVolume(volumeId VolumeId) (float64, error) { + if v := s.findVolume(volumeId); v != nil { + glog.V(3).Infof("volumd %d garbage level: %f", volumeId, v.garbageLevel()) + return v.garbageLevel(), nil } - return fmt.Errorf("volume id %d is not found during check compact", vid), false + return 0, fmt.Errorf("volume id %d is not found during check compact", volumeId) } -func (s *Store) CompactVolume(volumeIdString string, preallocate int64) error { - vid, err := NewVolumeId(volumeIdString) - if err != nil { - return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString) - } +func (s *Store) CompactVolume(vid VolumeId, preallocate int64) error { if v := s.findVolume(vid); v != nil { return v.Compact(preallocate) } return fmt.Errorf("volume id %d is not found during compact", vid) } -func (s *Store) CommitCompactVolume(volumeIdString string) error { - vid, err := NewVolumeId(volumeIdString) - if err != nil { - return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString) - } +func (s *Store) CommitCompactVolume(vid VolumeId) error { if v := s.findVolume(vid); v != nil { return v.commitCompact() } return fmt.Errorf("volume id %d is not found during commit compact", vid) } -func (s *Store) CommitCleanupVolume(volumeIdString string) error { - vid, err := NewVolumeId(volumeIdString) - if err != nil { - return fmt.Errorf("Volume Id %s is not a valid unsigned integer", volumeIdString) - } +func (s *Store) CommitCleanupVolume(vid VolumeId) error { if v := s.findVolume(vid); v != nil { return v.cleanupCompact() } |
