You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
806 B

3 years ago
  1. package shell
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
  5. "testing"
  6. )
  7. func TestEcDistribution(t *testing.T) {
  8. topologyInfo := parseOutput(topoData)
  9. // find out all volume servers with one slot left.
  10. ecNodes, totalFreeEcSlots := collectEcVolumeServersByDc(topologyInfo, "")
  11. sortEcNodesByFreeslotsDecending(ecNodes)
  12. if totalFreeEcSlots < erasure_coding.TotalShardsCount {
  13. println("not enough free ec shard slots", totalFreeEcSlots)
  14. }
  15. allocatedDataNodes := ecNodes
  16. if len(allocatedDataNodes) > erasure_coding.TotalShardsCount {
  17. allocatedDataNodes = allocatedDataNodes[:erasure_coding.TotalShardsCount]
  18. }
  19. for _, dn := range allocatedDataNodes {
  20. // fmt.Printf("info %+v %+v\n", dn.info, dn)
  21. fmt.Printf("=> %+v %+v\n", dn.info.Id, dn.freeEcSlot)
  22. }
  23. }