command_ec_encode_test.go 807 B

12345678910111213141516171819202122232425262728293031
  1. package shell
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/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. sortEcNodesByFreeslotsDescending(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. }