Browse Source

remove ticker

update the topology before each file
pull/3298/head
Konstantin Lebedev 2 years ago
parent
commit
d3f7c09c03
  1. 26
      weed/shell/command_volume_server_evacuate.go

26
weed/shell/command_volume_server_evacuate.go

@ -11,11 +11,8 @@ import (
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
"io" "io"
"os" "os"
"time"
) )
const topologyInfoUpdateInterval = 5 * time.Minute
func init() { func init() {
Commands = append(Commands, &commandVolumeServerEvacuate{}) Commands = append(Commands, &commandVolumeServerEvacuate{})
} }
@ -117,23 +114,18 @@ func (c *commandVolumeServerEvacuate) evacuateNormalVolumes(commandEnv *CommandE
} }
// move away normal volumes // move away normal volumes
ticker := time.NewTicker(topologyInfoUpdateInterval)
defer ticker.Stop()
for _, thisNode := range thisNodes { for _, thisNode := range thisNodes {
for _, diskInfo := range thisNode.info.DiskInfos { for _, diskInfo := range thisNode.info.DiskInfos {
if applyChange { if applyChange {
select {
case <-ticker.C:
if topologyInfo, _, err := collectTopologyInfo(commandEnv, 0); err != nil {
fmt.Fprintf(writer, "update topologyInfo %v", err)
} else {
_, otherNodesNew := c.nodesOtherThan(
collectVolumeServersByDc(topologyInfo, ""), volumeServer)
if len(otherNodesNew) > 0 {
otherNodes = otherNodesNew
c.topologyInfo = topologyInfo
fmt.Fprintf(writer, "topologyInfo updated %v\n", len(otherNodes))
}
if topologyInfo, _, err := collectTopologyInfo(commandEnv, 0); err != nil {
fmt.Fprintf(writer, "update topologyInfo %v", err)
} else {
_, otherNodesNew := c.nodesOtherThan(
collectVolumeServersByDc(topologyInfo, ""), volumeServer)
if len(otherNodesNew) > 0 {
otherNodes = otherNodesNew
c.topologyInfo = topologyInfo
fmt.Fprintf(writer, "topologyInfo updated %v\n", len(otherNodes))
} }
} }
} }

Loading…
Cancel
Save