Browse Source

refactoring

pull/991/head
Chris Lu 6 years ago
parent
commit
6bc3dee5b3
  1. 8
      weed/shell/command_ec_encode.go
  2. 8
      weed/shell/command_volume_fix_replication.go

8
weed/shell/command_ec_encode.go

@ -245,9 +245,7 @@ func collectVolumeIdsForEcEncode(ctx context.Context, commandEnv *CommandEnv, se
fmt.Printf("ec encode volumes quiet for: %d seconds\n", quietSeconds)
vidMap := make(map[uint32]bool)
for _, dc := range resp.TopologyInfo.DataCenterInfos {
for _, r := range dc.RackInfos {
for _, dn := range r.DataNodeInfos {
eachDataNode(resp.TopologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
for _, v := range dn.VolumeInfos {
if v.Collection == selectedCollection && v.ModifiedAtSecond+quietSeconds < nowUnixSeconds {
if float64(v.Size) > fullPercentage/100*float64(resp.VolumeSizeLimitMb)*1024*1024 {
@ -255,9 +253,7 @@ func collectVolumeIdsForEcEncode(ctx context.Context, commandEnv *CommandEnv, se
}
}
}
}
}
}
})
for vid, _ := range vidMap {
vids = append(vids, needle.VolumeId(vid))

8
weed/shell/command_volume_fix_replication.go

@ -63,9 +63,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
replicatedVolumeLocations := make(map[uint32][]location)
replicatedVolumeInfo := make(map[uint32]*master_pb.VolumeInformationMessage)
var allLocations []location
for _, dc := range resp.TopologyInfo.DataCenterInfos {
for _, rack := range dc.RackInfos {
for _, dn := range rack.DataNodeInfos {
eachDataNode(resp.TopologyInfo, func(dc string, rack RackId, dn *master_pb.DataNodeInfo) {
loc := newLocation(dc.Id, rack.Id, dn)
for _, v := range dn.VolumeInfos {
if v.ReplicaPlacement > 0 {
@ -74,9 +72,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv,
}
}
allLocations = append(allLocations, loc)
}
}
}
})
// find all under replicated volumes
underReplicatedVolumeLocations := make(map[uint32][]location)

Loading…
Cancel
Save