diff options
Diffstat (limited to 'go/topology/topology_event_handling.go')
| -rw-r--r-- | go/topology/topology_event_handling.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/go/topology/topology_event_handling.go b/go/topology/topology_event_handling.go index 7f81d8184..5097e9874 100644 --- a/go/topology/topology_event_handling.go +++ b/go/topology/topology_event_handling.go @@ -10,15 +10,19 @@ import ( func (t *Topology) StartRefreshWritableVolumes(garbageThreshold string) { go func() { for { - freshThreshHold := time.Now().Unix() - 3*t.pulse //3 times of sleep interval - t.CollectDeadNodeAndFullVolumes(freshThreshHold, t.volumeSizeLimit) + if t.IsLeader { + freshThreshHold := time.Now().Unix() - 3*t.pulse //3 times of sleep interval + t.CollectDeadNodeAndFullVolumes(freshThreshHold, t.volumeSizeLimit) + } time.Sleep(time.Duration(float32(t.pulse*1e3)*(1+rand.Float32())) * time.Millisecond) } }() go func(garbageThreshold string) { c := time.Tick(15 * time.Minute) - for _ = range c { - t.Vacuum(garbageThreshold) + if t.IsLeader { + for _ = range c { + t.Vacuum(garbageThreshold) + } } }(garbageThreshold) go func() { |
