Browse Source

randomize a bit for ec shards distribution

pull/2427/head
Chris Lu 3 years ago
parent
commit
00ae965d8d
  1. 3
      weed/shell/command_ec_encode.go

3
weed/shell/command_ec_encode.go

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/pb"
"io" "io"
"math/rand"
"sync" "sync"
"time" "time"
@ -248,7 +249,7 @@ func parallelCopyEcShardsFromSource(grpcDialOption grpc.DialOption, targetServer
func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) { func balancedEcDistribution(servers []*EcNode) (allocated [][]uint32) {
allocated = make([][]uint32, len(servers)) allocated = make([][]uint32, len(servers))
allocatedShardIdIndex := uint32(0) allocatedShardIdIndex := uint32(0)
serverIndex := 0
serverIndex := rand.Intn(len(servers))
for allocatedShardIdIndex < erasure_coding.TotalShardsCount { for allocatedShardIdIndex < erasure_coding.TotalShardsCount {
if servers[serverIndex].freeEcSlot > 0 { if servers[serverIndex].freeEcSlot > 0 {
allocated[serverIndex] = append(allocated[serverIndex], allocatedShardIdIndex) allocated[serverIndex] = append(allocated[serverIndex], allocatedShardIdIndex)

Loading…
Cancel
Save