aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2014-05-19 19:18:39 -0700
committerChris Lu <chris.lu@gmail.com>2014-05-19 19:18:39 -0700
commite8e8d11bd3470e19aa20a965c23d74d2952deec9 (patch)
tree68891566bd4fc20a920af897d3f39305588c9abf
parentc1307103b2b0c874a017353cd85812f862f5dcfc (diff)
downloadseaweedfs-e8e8d11bd3470e19aa20a965c23d74d2952deec9.tar.xz
seaweedfs-e8e8d11bd3470e19aa20a965c23d74d2952deec9.zip
Refactor out weedfs vacuum.
-rw-r--r--go/storage/store.go35
-rw-r--r--go/storage/store_vacuum.go43
2 files changed, 43 insertions, 35 deletions
diff --git a/go/storage/store.go b/go/storage/store.go
index a9ad88661..a6a4f399e 100644
--- a/go/storage/store.go
+++ b/go/storage/store.go
@@ -164,41 +164,6 @@ func (s *Store) addVolume(vid VolumeId, collection string, replicaPlacement *Rep
return fmt.Errorf("No more free space left")
}
-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()
- }
- return fmt.Errorf("volume id %d is not found during check compact!", vid), false
-}
-func (s *Store) CompactVolume(volumeIdString string) error {
- vid, err := NewVolumeId(volumeIdString)
- if err != nil {
- return fmt.Errorf("Volume Id %s is not a valid unsigned integer!", volumeIdString)
- }
- if v := s.findVolume(vid); v != nil {
- return v.Compact()
- }
- 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)
- }
- 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) FreezeVolume(volumeIdString string) error {
vid, err := NewVolumeId(volumeIdString)
if err != nil {
diff --git a/go/storage/store_vacuum.go b/go/storage/store_vacuum.go
new file mode 100644
index 000000000..5adaa7561
--- /dev/null
+++ b/go/storage/store_vacuum.go
@@ -0,0 +1,43 @@
+package storage
+
+import (
+ "code.google.com/p/weed-fs/go/glog"
+ "fmt"
+ "strconv"
+)
+
+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()
+ }
+ return fmt.Errorf("volume id %d is not found during check compact!", vid), false
+}
+func (s *Store) CompactVolume(volumeIdString string) error {
+ vid, err := NewVolumeId(volumeIdString)
+ if err != nil {
+ return fmt.Errorf("Volume Id %s is not a valid unsigned integer!", volumeIdString)
+ }
+ if v := s.findVolume(vid); v != nil {
+ return v.Compact()
+ }
+ 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)
+ }
+ if v := s.findVolume(vid); v != nil {
+ return v.commitCompact()
+ }
+ return fmt.Errorf("volume id %d is not found during commit compact!", vid)
+}