aboutsummaryrefslogtreecommitdiff
path: root/weed-fs/src/pkg
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2012-11-23 17:31:54 -0800
committerChris Lu <chris.lu@gmail.com>2012-11-23 17:31:54 -0800
commit3ef7a34f49aa479e47e152c12875a77e3bdaf5b8 (patch)
treea1860a9823b1fa0b302fe15e35f61961654834dc /weed-fs/src/pkg
parent94dbe6023384ddc99b58948e7ff01ab8abec2e47 (diff)
downloadseaweedfs-3ef7a34f49aa479e47e152c12875a77e3bdaf5b8.tar.xz
seaweedfs-3ef7a34f49aa479e47e152c12875a77e3bdaf5b8.zip
add command line option to control garbage threshold
Diffstat (limited to 'weed-fs/src/pkg')
-rw-r--r--weed-fs/src/pkg/topology/topology_compact.go12
-rw-r--r--weed-fs/src/pkg/topology/topology_event_handling.go8
2 files changed, 10 insertions, 10 deletions
diff --git a/weed-fs/src/pkg/topology/topology_compact.go b/weed-fs/src/pkg/topology/topology_compact.go
index c8ad9b2e7..e87bf982f 100644
--- a/weed-fs/src/pkg/topology/topology_compact.go
+++ b/weed-fs/src/pkg/topology/topology_compact.go
@@ -10,12 +10,12 @@ import (
"time"
)
-func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList) bool {
+func batchVacuumVolumeCheck(vl *VolumeLayout, vid storage.VolumeId, locationlist *VolumeLocationList, garbageThreshold string) bool {
ch := make(chan bool, locationlist.Length())
for index, dn := range locationlist.list {
go func(index int, url string, vid storage.VolumeId) {
//fmt.Println(index, "Check vacuuming", vid, "on", dn.Url())
- if e, ret := vacuumVolume_Check(url, vid); e != nil {
+ if e, ret := vacuumVolume_Check(url, vid, garbageThreshold); e != nil {
//fmt.Println(index, "Error when checking vacuuming", vid, "on", url, e)
ch <- false
} else {
@@ -78,11 +78,11 @@ func batchVacuumVolumeCommit(vl *VolumeLayout, vid storage.VolumeId, locationlis
}
return isCommitSuccess
}
-func (t *Topology) Vacuum() int {
+func (t *Topology) Vacuum(garbageThreshold string) int {
for _, vl := range t.replicaType2VolumeLayout {
if vl != nil {
for vid, locationlist := range vl.vid2location {
- if batchVacuumVolumeCheck(vl, vid, locationlist) {
+ if batchVacuumVolumeCheck(vl, vid, locationlist, garbageThreshold) {
if batchVacuumVolumeCompact(vl, vid, locationlist) {
batchVacuumVolumeCommit(vl, vid, locationlist)
}
@@ -98,10 +98,10 @@ type VacuumVolumeResult struct {
Error string
}
-func vacuumVolume_Check(urlLocation string, vid storage.VolumeId) (error, bool) {
+func vacuumVolume_Check(urlLocation string, vid storage.VolumeId, garbageThreshold string) (error, bool) {
values := make(url.Values)
values.Add("volume", vid.String())
- values.Add("garbageThreshold", "0.3")
+ values.Add("garbageThreshold", garbageThreshold)
jsonBlob, err := util.Post("http://"+urlLocation+"/admin/vacuum_volume_check", values)
if err != nil {
return err, false
diff --git a/weed-fs/src/pkg/topology/topology_event_handling.go b/weed-fs/src/pkg/topology/topology_event_handling.go
index 322d6c27a..9d7999f93 100644
--- a/weed-fs/src/pkg/topology/topology_event_handling.go
+++ b/weed-fs/src/pkg/topology/topology_event_handling.go
@@ -7,7 +7,7 @@ import (
"time"
)
-func (t *Topology) StartRefreshWritableVolumes() {
+func (t *Topology) StartRefreshWritableVolumes(garbageThreshold string) {
go func() {
for {
freshThreshHold := time.Now().Unix() - 3*t.pulse //3 times of sleep interval
@@ -15,12 +15,12 @@ func (t *Topology) StartRefreshWritableVolumes() {
time.Sleep(time.Duration(float32(t.pulse*1e3)*(1+rand.Float32())) * time.Millisecond)
}
}()
- go func() {
+ go func(garbageThreshold string) {
c := time.Tick(15 * time.Minute)
for _ = range c {
- t.Vacuum()
+ t.Vacuum(garbageThreshold)
}
- }()
+ }(garbageThreshold)
go func() {
for {
select {