mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
test checking ec distribution
This commit is contained in:
parent
f34c2ff7c5
commit
13f6ec1c4e
30
weed/shell/command_ec_encode_test.go
Normal file
30
weed/shell/command_ec_encode_test.go
Normal file
|
@ -0,0 +1,30 @@
|
|||
package shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/erasure_coding"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEcDistribution(t *testing.T) {
|
||||
|
||||
topologyInfo := parseOutput(topoData)
|
||||
|
||||
// find out all volume servers with one slot left.
|
||||
ecNodes, totalFreeEcSlots := collectEcVolumeServersByDc(topologyInfo, "")
|
||||
|
||||
sortEcNodesByFreeslotsDecending(ecNodes)
|
||||
|
||||
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 {
|
||||
fmt.Printf("info %+v %+v\n", dn.info, dn)
|
||||
}
|
||||
|
||||
}
|
|
@ -65,11 +65,14 @@ func parseOutput(output string) *master_pb.TopologyInfo {
|
|||
case "Disk":
|
||||
if disk == nil {
|
||||
diskType := parts[1][:strings.Index(parts[1], "(")]
|
||||
volumeCountStr := parts[1][strings.Index(parts[1], ":")+1 : strings.Index(parts[1], "/")]
|
||||
maxVolumeCountStr := parts[1][strings.Index(parts[1], "/")+1:]
|
||||
maxVolumeCount, _ := strconv.Atoi(maxVolumeCountStr)
|
||||
volumeCount, _ := strconv.Atoi(volumeCountStr)
|
||||
disk = &master_pb.DiskInfo{
|
||||
Type: diskType,
|
||||
MaxVolumeCount: int64(maxVolumeCount),
|
||||
VolumeCount: int64(volumeCount),
|
||||
}
|
||||
dn.DiskInfos[types.ToDiskType(diskType).String()] = disk
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue