2022-02-08 09:50:05 +00:00
|
|
|
package shell
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-07-29 07:17:28 +00:00
|
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/erasure_coding"
|
2022-02-08 09:50:05 +00:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestEcDistribution(t *testing.T) {
|
|
|
|
|
|
|
|
topologyInfo := parseOutput(topoData)
|
|
|
|
|
|
|
|
// find out all volume servers with one slot left.
|
|
|
|
ecNodes, totalFreeEcSlots := collectEcVolumeServersByDc(topologyInfo, "")
|
|
|
|
|
2022-09-14 19:06:48 +00:00
|
|
|
sortEcNodesByFreeslotsDescending(ecNodes)
|
2022-02-08 09:50:05 +00:00
|
|
|
|
|
|
|
if totalFreeEcSlots < erasure_coding.TotalShardsCount {
|
|
|
|
println("not enough free ec shard slots", totalFreeEcSlots)
|
|
|
|
}
|
|
|
|
allocatedDataNodes := ecNodes
|
|
|
|
if len(allocatedDataNodes) > erasure_coding.TotalShardsCount {
|
|
|
|
allocatedDataNodes = allocatedDataNodes[:erasure_coding.TotalShardsCount]
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, dn := range allocatedDataNodes {
|
2022-02-24 21:50:08 +00:00
|
|
|
// fmt.Printf("info %+v %+v\n", dn.info, dn)
|
|
|
|
fmt.Printf("=> %+v %+v\n", dn.info.Id, dn.freeEcSlot)
|
2022-02-08 09:50:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|