diff options
| author | bingoohuang <bingoo.huang@gmail.com> | 2021-03-01 09:22:46 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-01 09:22:46 +0800 |
| commit | eb65cbf0025e4bfbfe6359a5ba5bfbd094c3e81d (patch) | |
| tree | 7aa6c966d0d36a6cd4d2c16735b6b265527af142 /weed/shell/command_volume_balance.go | |
| parent | 0cfbe8f059c9f97f606e7c76f77aa8a8a8c97765 (diff) | |
| parent | e52c94640e9898be5308a77867ecea5ef1567c5b (diff) | |
| download | seaweedfs-eb65cbf0025e4bfbfe6359a5ba5bfbd094c3e81d.tar.xz seaweedfs-eb65cbf0025e4bfbfe6359a5ba5bfbd094c3e81d.zip | |
Merge pull request #5 from chrislusf/master
sync
Diffstat (limited to 'weed/shell/command_volume_balance.go')
| -rw-r--r-- | weed/shell/command_volume_balance.go | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/weed/shell/command_volume_balance.go b/weed/shell/command_volume_balance.go index a1e3c1ab6..e0c41f310 100644 --- a/weed/shell/command_volume_balance.go +++ b/weed/shell/command_volume_balance.go @@ -1,7 +1,6 @@ package shell import ( - "context" "flag" "fmt" "github.com/chrislusf/seaweedfs/weed/storage/super_block" @@ -75,18 +74,15 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer return nil } - var resp *master_pb.VolumeListResponse - err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error { - resp, err = client.VolumeList(context.Background(), &master_pb.VolumeListRequest{}) - return err - }) + // collect topology information + topologyInfo, volumeSizeLimitMb, err := collectTopologyInfo(commandEnv) if err != nil { return err } - volumeServers := collectVolumeServersByDc(resp.TopologyInfo, *dc) - volumeReplicas, _ := collectVolumeReplicaLocations(resp) - diskTypes := collectVolumeDiskTypes(resp.TopologyInfo) + volumeServers := collectVolumeServersByDc(topologyInfo, *dc) + volumeReplicas, _ := collectVolumeReplicaLocations(topologyInfo) + diskTypes := collectVolumeDiskTypes(topologyInfo) if *collection == "EACH_COLLECTION" { collections, err := ListCollectionNames(commandEnv, true, false) @@ -94,16 +90,16 @@ func (c *commandVolumeBalance) Do(args []string, commandEnv *CommandEnv, writer return err } for _, c := range collections { - if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, resp.VolumeSizeLimitMb*1024*1024, c, *applyBalancing); err != nil { + if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, volumeSizeLimitMb*1024*1024, c, *applyBalancing); err != nil { return err } } } else if *collection == "ALL_COLLECTIONS" { - if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, resp.VolumeSizeLimitMb*1024*1024, "ALL_COLLECTIONS", *applyBalancing); err != nil { + if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, volumeSizeLimitMb*1024*1024, "ALL_COLLECTIONS", *applyBalancing); err != nil { return err } } else { - if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, resp.VolumeSizeLimitMb*1024*1024, *collection, *applyBalancing); err != nil { + if err = balanceVolumeServers(commandEnv, diskTypes, volumeReplicas, volumeServers, volumeSizeLimitMb*1024*1024, *collection, *applyBalancing); err != nil { return err } } |
