aboutsummaryrefslogtreecommitdiff
path: root/go/topology
diff options
context:
space:
mode:
Diffstat (limited to 'go/topology')
-rw-r--r--go/topology/topology.go2
-rw-r--r--go/topology/topology_event_handling.go12
2 files changed, 10 insertions, 4 deletions
diff --git a/go/topology/topology.go b/go/topology/topology.go
index 5b3d29e0b..24b3ab337 100644
--- a/go/topology/topology.go
+++ b/go/topology/topology.go
@@ -12,6 +12,8 @@ import (
type Topology struct {
NodeImpl
+ IsLeader bool
+
collectionMap map[string]*Collection
pulse int64
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() {