mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
wait for goroutines
This commit is contained in:
parent
1098ed0d78
commit
85832d02c0
|
@ -109,6 +109,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
|
||||||
hasFoundTarget := false
|
hasFoundTarget := false
|
||||||
keepDataNodesSorted(allLocations, toDiskType)
|
keepDataNodesSorted(allLocations, toDiskType)
|
||||||
fn := capacityByFreeVolumeCount(toDiskType)
|
fn := capacityByFreeVolumeCount(toDiskType)
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
for _, dst := range allLocations {
|
for _, dst := range allLocations {
|
||||||
if fn(dst.dataNode) > 0 && !hasFoundTarget {
|
if fn(dst.dataNode) > 0 && !hasFoundTarget {
|
||||||
// ask the volume server to replicate the volume
|
// ask the volume server to replicate the volume
|
||||||
|
@ -145,6 +146,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
|
||||||
c.activeServers[dst.dataNode.Id] = struct{}{}
|
c.activeServers[dst.dataNode.Id] = struct{}{}
|
||||||
c.activeServersCond.L.Unlock()
|
c.activeServersCond.L.Unlock()
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
go func(dst location) {
|
go func(dst location) {
|
||||||
if err := c.doMoveOneVolume(commandEnv, writer, vid, toDiskType, locations, sourceVolumeServer, dst); err != nil {
|
if err := c.doMoveOneVolume(commandEnv, writer, vid, toDiskType, locations, sourceVolumeServer, dst); err != nil {
|
||||||
fmt.Fprintf(writer, "move volume %d %s => %s: %v\n", vid, sourceVolumeServer, dst.dataNode.Id, err)
|
fmt.Fprintf(writer, "move volume %d %s => %s: %v\n", vid, sourceVolumeServer, dst.dataNode.Id, err)
|
||||||
|
@ -152,11 +154,14 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
|
||||||
delete(c.activeServers, sourceVolumeServer)
|
delete(c.activeServers, sourceVolumeServer)
|
||||||
delete(c.activeServers, dst.dataNode.Id)
|
delete(c.activeServers, dst.dataNode.Id)
|
||||||
c.activeServersCond.Signal()
|
c.activeServersCond.Signal()
|
||||||
|
wg.Done()
|
||||||
}(dst)
|
}(dst)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
if !hasFoundTarget {
|
if !hasFoundTarget {
|
||||||
fmt.Fprintf(writer, "can not find disk type %s for volume %d\n", toDiskType.ReadableString(), vid)
|
fmt.Fprintf(writer, "can not find disk type %s for volume %d\n", toDiskType.ReadableString(), vid)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue