diff --git a/Makefile b/Makefile index 5f447f9e4..866123a0b 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ cloc: cloc --exclude-dir=vendor,3rdmocks,mocks,tools,gen --not-match-f=test . unit-test: - go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'` + go vet `go list ./... | grep -v '/vendor/' | grep -v '/tools'` && \ go test -race -timeout 240s -count=1 -cover ./utils/... \ ./types/... \ ./store/etcdv3/. \ @@ -66,7 +66,7 @@ unit-test: ./wal/. \ ./wal/kv/. \ ./store/redis/... \ - ./lock/redis/... + ./lock/redis/... && \ go test -timeout 240s -count=1 -cover ./cluster/calcium/... lint: diff --git a/scheduler/complex/resource.go b/scheduler/complex/resource.go index f7c790247..0eb3257da 100644 --- a/scheduler/complex/resource.go +++ b/scheduler/complex/resource.go @@ -184,13 +184,23 @@ func (h *host) getFragmentsResult(resources []resourceInfo, fragments ...int64) func (h *host) getFullResult(full int, resources []resourceInfo) []types.ResourceMap { result := []types.ResourceMap{} - count := len(resources) / full - for i := 0; i < count; i++ { - plan := types.ResourceMap{} - for j := i * full; j < i*full+full; j++ { - plan[resources[j].id] = int64(h.share) + for len(resources)/full > 0 { + count, rem := len(resources)/full, len(resources)%full + newResources := []resourceInfo{} + for i := 0; i < count; i++ { + plan := types.ResourceMap{} + for j := i * full; j < i*full+full; j++ { + // 洗掉没配额的 + last := resources[j].pieces - int64(h.share) + if last > 0 { + newResources = append(newResources, resourceInfo{resources[j].id, last}) + } + plan[resources[j].id] = int64(h.share) + } + result = append(result, plan) } - result = append(result, plan) + + resources = append(newResources, resources[len(resources)-rem:]...) } return result