From 562cd4a2829218de406bd4a048795c32eb756062 Mon Sep 17 00:00:00 2001 From: Connor1996 Date: Thu, 19 Apr 2018 14:00:10 +0800 Subject: [PATCH] address comment --- server/coordinator_test.go | 2 +- server/core/store.go | 1 + server/schedule/mockcluster.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/coordinator_test.go b/server/coordinator_test.go index 02d217a86a8..52e0c8b9e8f 100644 --- a/server/coordinator_test.go +++ b/server/coordinator_test.go @@ -66,7 +66,7 @@ func (c *testClusterInfo) addRegionStore(storeID uint64, regionCount int) { store.RegionCount = regionCount store.RegionSize = int64(regionCount) * 10 store.Stats.Capacity = 1000 * (1 << 20) - store.Stats.Available = store.Stats.Capacity - uint64(store.LeaderSize) + store.Stats.Available = store.Stats.Capacity - uint64(store.RegionSize) c.putStore(store) } diff --git a/server/core/store.go b/server/core/store.go index 0a55a75579a..47ace78b43d 100644 --- a/server/core/store.go +++ b/server/core/store.go @@ -127,6 +127,7 @@ func (s *StoreInfo) RegionScore(highSpaceRatio, lowSpaceRatio float64, delta int lowSpaceRatio = highSpaceRatio } + // because of rocksdb compression, region size is larger than actual used size amplification := float64(s.RegionSize) / (float64(s.Stats.GetUsedSize()) / (1 << 20)) if available-float64(delta)/amplification >= highSpaceRatio*capacity || lowSpaceRatio < 0 || lowSpaceRatio > 1 { diff --git a/server/schedule/mockcluster.go b/server/schedule/mockcluster.go index a405e62baef..796fb7e5df0 100644 --- a/server/schedule/mockcluster.go +++ b/server/schedule/mockcluster.go @@ -25,7 +25,7 @@ import ( log "github.com/sirupsen/logrus" ) -// MockCluster is to mock clusterInfo for test use +// MockCluster is used to mock clusterInfo for test use type MockCluster struct { *BasicCluster id *core.MockIDAllocator