diff --git a/pkg/autoscaling/calculation.go b/pkg/autoscaling/calculation.go index 8742aeea3d31..eff1594cdf1c 100644 --- a/pkg/autoscaling/calculation.go +++ b/pkg/autoscaling/calculation.go @@ -23,11 +23,11 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/log" promClient "github.com/prometheus/client_golang/api" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/filter" "go.etcd.io/etcd/clientv3" "go.uber.org/zap" diff --git a/pkg/autoscaling/calculation_test.go b/pkg/autoscaling/calculation_test.go index a411cce632e7..a40d81a2042b 100644 --- a/pkg/autoscaling/calculation_test.go +++ b/pkg/autoscaling/calculation_test.go @@ -23,9 +23,9 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) func TestGetScaledTiKVGroups(t *testing.T) { diff --git a/server/core/basic_cluster.go b/pkg/core/basic_cluster.go similarity index 99% rename from server/core/basic_cluster.go rename to pkg/core/basic_cluster.go index ae8ff3bdf752..5775887f4c01 100644 --- a/server/core/basic_cluster.go +++ b/pkg/core/basic_cluster.go @@ -16,8 +16,8 @@ package core import ( "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core/storelimit" ) // BasicCluster provides basic data member and interface for a tikv cluster. diff --git a/server/core/factory.go b/pkg/core/factory.go similarity index 100% rename from server/core/factory.go rename to pkg/core/factory.go diff --git a/server/core/factory_test.go b/pkg/core/factory_test.go similarity index 100% rename from server/core/factory_test.go rename to pkg/core/factory_test.go diff --git a/server/core/kind.go b/pkg/core/kind.go similarity index 100% rename from server/core/kind.go rename to pkg/core/kind.go diff --git a/server/core/peer.go b/pkg/core/peer.go similarity index 100% rename from server/core/peer.go rename to pkg/core/peer.go diff --git a/server/core/rangetree/range_tree.go b/pkg/core/rangetree/range_tree.go similarity index 100% rename from server/core/rangetree/range_tree.go rename to pkg/core/rangetree/range_tree.go diff --git a/server/core/rangetree/range_tree_test.go b/pkg/core/rangetree/range_tree_test.go similarity index 100% rename from server/core/rangetree/range_tree_test.go rename to pkg/core/rangetree/range_tree_test.go diff --git a/server/core/region.go b/pkg/core/region.go similarity index 96% rename from server/core/region.go rename to pkg/core/region.go index 972d08c5d3f6..2bae0d87a238 100644 --- a/server/core/region.go +++ b/pkg/core/region.go @@ -18,6 +18,7 @@ import ( "bytes" "encoding/hex" "fmt" + "math" "reflect" "sort" "strings" @@ -1674,3 +1675,71 @@ func NeedTransferWitnessLeader(region *RegionInfo) bool { } return region.GetLeader().IsWitness } + +// SplitRegions split a set of RegionInfo by the middle of regionKey. Only for test purpose. +func SplitRegions(regions []*RegionInfo) []*RegionInfo { + results := make([]*RegionInfo, 0, len(regions)*2) + for _, region := range regions { + start, end := byte(0), byte(math.MaxUint8) + if len(region.GetStartKey()) > 0 { + start = region.GetStartKey()[0] + } + if len(region.GetEndKey()) > 0 { + end = region.GetEndKey()[0] + } + middle := []byte{start/2 + end/2} + left := region.Clone() + left.meta.Id = region.GetID() + uint64(len(regions)) + left.meta.EndKey = middle + left.meta.RegionEpoch.Version++ + right := region.Clone() + right.meta.Id = region.GetID() + uint64(len(regions)*2) + right.meta.StartKey = middle + right.meta.RegionEpoch.Version++ + results = append(results, left, right) + } + return results +} + +// MergeRegions merge a set of RegionInfo by regionKey. Only for test purpose. +func MergeRegions(regions []*RegionInfo) []*RegionInfo { + results := make([]*RegionInfo, 0, len(regions)/2) + for i := 0; i < len(regions); i += 2 { + left := regions[i] + right := regions[i] + if i+1 < len(regions) { + right = regions[i+1] + } + region := &RegionInfo{meta: &metapb.Region{ + Id: left.GetID(), + StartKey: left.GetStartKey(), + EndKey: right.GetEndKey(), + Peers: left.meta.Peers, + }} + if left.GetRegionEpoch().GetVersion() > right.GetRegionEpoch().GetVersion() { + region.meta.RegionEpoch = left.GetRegionEpoch() + } else { + region.meta.RegionEpoch = right.GetRegionEpoch() + } + region.meta.RegionEpoch.Version++ + region.leader = left.leader + results = append(results, region) + } + return results +} + +// NewTestRegionInfo creates a new RegionInfo for test purpose. +func NewTestRegionInfo(regionID, storeID uint64, start, end []byte, opts ...RegionCreateOption) *RegionInfo { + leader := &metapb.Peer{ + Id: regionID, + StoreId: storeID, + } + metaRegion := &metapb.Region{ + Id: regionID, + StartKey: start, + EndKey: end, + Peers: []*metapb.Peer{leader}, + RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1}, + } + return NewRegionInfo(metaRegion, leader, opts...) +} diff --git a/server/core/region_option.go b/pkg/core/region_option.go similarity index 89% rename from server/core/region_option.go rename to pkg/core/region_option.go index 4fa3de028625..ca133deb55fc 100644 --- a/server/core/region_option.go +++ b/pkg/core/region_option.go @@ -16,7 +16,9 @@ package core import ( "math" + "math/rand" "sort" + "time" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" @@ -237,15 +239,6 @@ func SetWrittenQuery(v uint64) RegionCreateOption { return SetQueryStats(q) } -// SetQueryNum sets the read and write query with specific num. -// This func is only used for test and simulator. -func SetQueryNum(read, write uint64) RegionCreateOption { - r := RandomKindReadQuery(read) - w := RandomKindWriteQuery(write) - q := mergeQueryStat(r, w) - return SetQueryStats(q) -} - // SetQueryStats sets the query stats for the region, it will cover previous statistic. // This func is only used for unit test. func SetQueryStats(v *pdpb.QueryStats) RegionCreateOption { @@ -369,6 +362,64 @@ func SetFromHeartbeat(fromHeartbeat bool) RegionCreateOption { } } +// RandomKindReadQuery returns query stat with random query kind, only used for unit test. +func RandomKindReadQuery(queryRead uint64) *pdpb.QueryStats { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + switch r.Intn(3) { + case 0: + return &pdpb.QueryStats{ + Coprocessor: queryRead, + } + case 1: + return &pdpb.QueryStats{ + Scan: queryRead, + } + case 2: + return &pdpb.QueryStats{ + Get: queryRead, + } + default: + return &pdpb.QueryStats{} + } +} + +// RandomKindWriteQuery returns query stat with random query kind, only used for unit test. +func RandomKindWriteQuery(queryWrite uint64) *pdpb.QueryStats { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + switch r.Intn(7) { + case 0: + return &pdpb.QueryStats{ + Put: queryWrite, + } + case 1: + return &pdpb.QueryStats{ + Delete: queryWrite, + } + case 2: + return &pdpb.QueryStats{ + DeleteRange: queryWrite, + } + case 3: + return &pdpb.QueryStats{ + AcquirePessimisticLock: queryWrite, + } + case 4: + return &pdpb.QueryStats{ + Rollback: queryWrite, + } + case 5: + return &pdpb.QueryStats{ + Prewrite: queryWrite, + } + case 6: + return &pdpb.QueryStats{ + Commit: queryWrite, + } + default: + return &pdpb.QueryStats{} + } +} + func mergeQueryStat(q1, q2 *pdpb.QueryStats) *pdpb.QueryStats { if q1 == nil && q2 == nil { return &pdpb.QueryStats{} diff --git a/server/core/region_test.go b/pkg/core/region_test.go similarity index 99% rename from server/core/region_test.go rename to pkg/core/region_test.go index b4bacac6bcf6..c54befb85d8d 100644 --- a/server/core/region_test.go +++ b/pkg/core/region_test.go @@ -615,7 +615,7 @@ func checkRegions(re *require.Assertions, regions *RegionsInfo) { } func BenchmarkUpdateBuckets(b *testing.B) { - region := NewTestRegionInfo([]byte{}, []byte{}) + region := NewTestRegionInfo(1, 1, []byte{}, []byte{}) b.ResetTimer() for i := 0; i < b.N; i++ { buckets := &metapb.Buckets{RegionId: 0, Version: uint64(i)} diff --git a/server/core/region_tree.go b/pkg/core/region_tree.go similarity index 100% rename from server/core/region_tree.go rename to pkg/core/region_tree.go diff --git a/server/core/region_tree_test.go b/pkg/core/region_tree_test.go similarity index 94% rename from server/core/region_tree_test.go rename to pkg/core/region_tree_test.go index 796b83f176d1..4e002fb8157b 100644 --- a/server/core/region_tree_test.go +++ b/pkg/core/region_tree_test.go @@ -114,7 +114,7 @@ func TestRegionItem(t *testing.T) { } func newRegionWithStat(start, end string, size, keys int64) *RegionInfo { - region := NewTestRegionInfo([]byte(start), []byte(end)) + region := NewTestRegionInfo(1, 1, []byte(start), []byte(end)) region.approximateSize, region.approximateKeys = size, keys return region } @@ -151,10 +151,10 @@ func TestRegionTree(t *testing.T) { re.Nil(tree.search([]byte("a"))) - regionA := NewTestRegionInfo([]byte("a"), []byte("b")) - regionB := NewTestRegionInfo([]byte("b"), []byte("c")) - regionC := NewTestRegionInfo([]byte("c"), []byte("d")) - regionD := NewTestRegionInfo([]byte("d"), []byte{}) + regionA := NewTestRegionInfo(1, 1, []byte("a"), []byte("b")) + regionB := NewTestRegionInfo(2, 2, []byte("b"), []byte("c")) + regionC := NewTestRegionInfo(3, 3, []byte("c"), []byte("d")) + regionD := NewTestRegionInfo(4, 4, []byte("d"), []byte{}) updateNewItem(tree, regionA) updateNewItem(tree, regionC) @@ -274,14 +274,14 @@ func TestRandomRegion(t *testing.T) { r := tree.RandomRegion(nil) re.Nil(r) - regionA := NewTestRegionInfo([]byte(""), []byte("g")) + regionA := NewTestRegionInfo(1, 1, []byte(""), []byte("g")) updateNewItem(tree, regionA) ra := tree.RandomRegion([]KeyRange{NewKeyRange("", "")}) re.Equal(regionA, ra) - regionB := NewTestRegionInfo([]byte("g"), []byte("n")) - regionC := NewTestRegionInfo([]byte("n"), []byte("t")) - regionD := NewTestRegionInfo([]byte("t"), []byte("")) + regionB := NewTestRegionInfo(2, 2, []byte("g"), []byte("n")) + regionC := NewTestRegionInfo(3, 3, []byte("n"), []byte("t")) + regionD := NewTestRegionInfo(4, 4, []byte("t"), []byte("")) updateNewItem(tree, regionB) updateNewItem(tree, regionC) updateNewItem(tree, regionD) @@ -316,7 +316,7 @@ func TestRandomRegionDiscontinuous(t *testing.T) { re.Nil(r) // test for single region - regionA := NewTestRegionInfo([]byte("c"), []byte("f")) + regionA := NewTestRegionInfo(1, 1, []byte("c"), []byte("f")) updateNewItem(tree, regionA) ra := tree.RandomRegion([]KeyRange{NewKeyRange("c", "e")}) re.Nil(ra) @@ -331,7 +331,7 @@ func TestRandomRegionDiscontinuous(t *testing.T) { ra = tree.RandomRegion([]KeyRange{NewKeyRange("a", "g")}) re.Equal(regionA, ra) - regionB := NewTestRegionInfo([]byte("n"), []byte("x")) + regionB := NewTestRegionInfo(2, 2, []byte("n"), []byte("x")) updateNewItem(tree, regionB) rb := tree.RandomRegion([]KeyRange{NewKeyRange("g", "x")}) re.Equal(regionB, rb) @@ -342,11 +342,11 @@ func TestRandomRegionDiscontinuous(t *testing.T) { rb = tree.RandomRegion([]KeyRange{NewKeyRange("o", "y")}) re.Nil(rb) - regionC := NewTestRegionInfo([]byte("z"), []byte("")) + regionC := NewTestRegionInfo(3, 3, []byte("z"), []byte("")) updateNewItem(tree, regionC) rc := tree.RandomRegion([]KeyRange{NewKeyRange("y", "")}) re.Equal(regionC, rc) - regionD := NewTestRegionInfo([]byte(""), []byte("a")) + regionD := NewTestRegionInfo(4, 4, []byte(""), []byte("a")) updateNewItem(tree, regionD) rd := tree.RandomRegion([]KeyRange{NewKeyRange("", "b")}) re.Equal(regionD, rd) @@ -379,7 +379,7 @@ func checkRandomRegion(re *require.Assertions, tree *regionTree, regions []*Regi } func newRegionItem(start, end []byte) *regionItem { - return ®ionItem{RegionInfo: NewTestRegionInfo(start, end)} + return ®ionItem{RegionInfo: NewTestRegionInfo(1, 1, start, end)} } type mockRegionTreeData struct { diff --git a/server/core/store.go b/pkg/core/store.go similarity index 97% rename from server/core/store.go rename to pkg/core/store.go index 3226f0621b88..6dcae317b4a9 100644 --- a/server/core/store.go +++ b/pkg/core/store.go @@ -22,9 +22,9 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core/storelimit" "go.uber.org/zap" ) @@ -80,6 +80,24 @@ func NewStoreInfo(store *metapb.Store, opts ...StoreCreateOption) *StoreInfo { return storeInfo } +// NewStoreInfoWithLabel is create a store with specified labels. only for test purpose. +func NewStoreInfoWithLabel(id uint64, labels map[string]string) *StoreInfo { + storeLabels := make([]*metapb.StoreLabel, 0, len(labels)) + for k, v := range labels { + storeLabels = append(storeLabels, &metapb.StoreLabel{ + Key: k, + Value: v, + }) + } + store := NewStoreInfo( + &metapb.Store{ + Id: id, + Labels: storeLabels, + }, + ) + return store +} + // Clone creates a copy of current StoreInfo. func (s *StoreInfo) Clone(opts ...StoreCreateOption) *StoreInfo { store := *s diff --git a/server/core/store_option.go b/pkg/core/store_option.go similarity index 99% rename from server/core/store_option.go rename to pkg/core/store_option.go index ebac0d257343..8e1c70091fbb 100644 --- a/server/core/store_option.go +++ b/pkg/core/store_option.go @@ -19,8 +19,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core/storelimit" ) // StoreCreateOption is used to create store. diff --git a/server/core/store_stats.go b/pkg/core/store_stats.go similarity index 100% rename from server/core/store_stats.go rename to pkg/core/store_stats.go diff --git a/server/core/store_stats_test.go b/pkg/core/store_stats_test.go similarity index 100% rename from server/core/store_stats_test.go rename to pkg/core/store_stats_test.go diff --git a/server/core/store_test.go b/pkg/core/store_test.go similarity index 75% rename from server/core/store_test.go rename to pkg/core/store_test.go index eaee6b70d6bf..f4ad32197adb 100644 --- a/server/core/store_test.go +++ b/pkg/core/store_test.go @@ -44,7 +44,7 @@ func TestDistinctScore(t *testing.T) { "rack": rack, "host": host, } - store := NewStoreInfoWithLabel(storeID, 1, storeLabels) + store := NewStoreInfoWithLabel(storeID, storeLabels) stores = append(stores, store) // Number of stores in different zones. @@ -58,7 +58,7 @@ func TestDistinctScore(t *testing.T) { } } } - store := NewStoreInfoWithLabel(100, 1, nil) + store := NewStoreInfoWithLabel(100, nil) re.Equal(float64(0), DistinctScore(labels, stores, store)) } @@ -131,7 +131,8 @@ func TestRegionScore(t *testing.T) { func TestLowSpaceRatio(t *testing.T) { re := require.New(t) - store := NewStoreInfoWithLabel(1, 20, nil) + store := NewStoreInfo(&metapb.Store{Id: 1}) + store.rawStats.Capacity = initialMinSpace << 4 store.rawStats.Available = store.rawStats.Capacity >> 3 @@ -149,40 +150,40 @@ func TestLowSpaceScoreV2(t *testing.T) { small *StoreInfo }{{ // store1 and store2 has same store available ratio and store1 less 50 GB - bigger: NewStoreInfoWithAvailable(1, 20*units.GiB, 100*units.GiB, 1.4), - small: NewStoreInfoWithAvailable(2, 200*units.GiB, 1000*units.GiB, 1.4), + bigger: newStoreInfoWithAvailable(1, 20*units.GiB, 100*units.GiB, 1.4), + small: newStoreInfoWithAvailable(2, 200*units.GiB, 1000*units.GiB, 1.4), }, { // store1 and store2 has same available space and less than 50 GB - bigger: NewStoreInfoWithAvailable(1, 10*units.GiB, 1000*units.GiB, 1.4), - small: NewStoreInfoWithAvailable(2, 10*units.GiB, 100*units.GiB, 1.4), + bigger: newStoreInfoWithAvailable(1, 10*units.GiB, 1000*units.GiB, 1.4), + small: newStoreInfoWithAvailable(2, 10*units.GiB, 100*units.GiB, 1.4), }, { // store1 and store2 has same available ratio less than 0.2 - bigger: NewStoreInfoWithAvailable(1, 20*units.GiB, 1000*units.GiB, 1.4), - small: NewStoreInfoWithAvailable(2, 10*units.GiB, 500*units.GiB, 1.4), + bigger: newStoreInfoWithAvailable(1, 20*units.GiB, 1000*units.GiB, 1.4), + small: newStoreInfoWithAvailable(2, 10*units.GiB, 500*units.GiB, 1.4), }, { // store1 and store2 has same available ratio // but the store1 ratio less than store2 ((50-10)/50=0.8<(200-100)/200=0.5) - bigger: NewStoreInfoWithAvailable(1, 10*units.GiB, 100*units.GiB, 1.4), - small: NewStoreInfoWithAvailable(2, 100*units.GiB, 1000*units.GiB, 1.4), + bigger: newStoreInfoWithAvailable(1, 10*units.GiB, 100*units.GiB, 1.4), + small: newStoreInfoWithAvailable(2, 100*units.GiB, 1000*units.GiB, 1.4), }, { // store1 and store2 has same usedSize and capacity // but the bigger's amp is bigger - bigger: NewStoreInfoWithAvailable(1, 10*units.GiB, 100*units.GiB, 1.5), - small: NewStoreInfoWithAvailable(2, 10*units.GiB, 100*units.GiB, 1.4), + bigger: newStoreInfoWithAvailable(1, 10*units.GiB, 100*units.GiB, 1.5), + small: newStoreInfoWithAvailable(2, 10*units.GiB, 100*units.GiB, 1.4), }, { // store1 and store2 has same capacity and regionSizeļ¼ˆ40g) // but store1 has less available space size - bigger: NewStoreInfoWithAvailable(1, 60*units.GiB, 100*units.GiB, 1), - small: NewStoreInfoWithAvailable(2, 80*units.GiB, 100*units.GiB, 2), + bigger: newStoreInfoWithAvailable(1, 60*units.GiB, 100*units.GiB, 1), + small: newStoreInfoWithAvailable(2, 80*units.GiB, 100*units.GiB, 2), }, { // store1 and store2 has same capacity and store2 (40g) has twice usedSize than store1 (20g) // but store1 has higher amp, so store1(60g) has more regionSize (40g) - bigger: NewStoreInfoWithAvailable(1, 80*units.GiB, 100*units.GiB, 3), - small: NewStoreInfoWithAvailable(2, 60*units.GiB, 100*units.GiB, 1), + bigger: newStoreInfoWithAvailable(1, 80*units.GiB, 100*units.GiB, 3), + small: newStoreInfoWithAvailable(2, 60*units.GiB, 100*units.GiB, 1), }, { // store1's capacity is less than store2's capacity, but store2 has more available space, - bigger: NewStoreInfoWithAvailable(1, 2*units.GiB, 100*units.GiB, 3), - small: NewStoreInfoWithAvailable(2, 100*units.GiB, 10*1000*units.GiB, 3), + bigger: newStoreInfoWithAvailable(1, 2*units.GiB, 100*units.GiB, 3), + small: newStoreInfoWithAvailable(2, 100*units.GiB, 10*1000*units.GiB, 3), }} for _, v := range testdata { score1 := v.bigger.regionScoreV2(0, 0.8) @@ -190,3 +191,21 @@ func TestLowSpaceScoreV2(t *testing.T) { re.Greater(score1, score2) } } + +// newStoreInfoWithAvailable is created with available and capacity +func newStoreInfoWithAvailable(id, available, capacity uint64, amp float64) *StoreInfo { + stats := &pdpb.StoreStats{} + stats.Capacity = capacity + stats.Available = available + usedSize := capacity - available + regionSize := (float64(usedSize) * amp) / units.MiB + store := NewStoreInfo( + &metapb.Store{ + Id: id, + }, + SetStoreStats(stats), + SetRegionCount(int(regionSize/96)), + SetRegionSize(int64(regionSize)), + ) + return store +} diff --git a/server/core/storelimit/limit.go b/pkg/core/storelimit/limit.go similarity index 100% rename from server/core/storelimit/limit.go rename to pkg/core/storelimit/limit.go diff --git a/server/core/storelimit/limit_test.go b/pkg/core/storelimit/limit_test.go similarity index 100% rename from server/core/storelimit/limit_test.go rename to pkg/core/storelimit/limit_test.go diff --git a/server/core/storelimit/store_limit.go b/pkg/core/storelimit/store_limit.go similarity index 100% rename from server/core/storelimit/store_limit.go rename to pkg/core/storelimit/store_limit.go diff --git a/server/core/storelimit/store_limit_scenes.go b/pkg/core/storelimit/store_limit_scenes.go similarity index 100% rename from server/core/storelimit/store_limit_scenes.go rename to pkg/core/storelimit/store_limit_scenes.go diff --git a/pkg/dashboard/keyvisual/input/core.go b/pkg/dashboard/keyvisual/input/core.go index 951221cf21e0..d4e50281b883 100644 --- a/pkg/dashboard/keyvisual/input/core.go +++ b/pkg/dashboard/keyvisual/input/core.go @@ -17,8 +17,8 @@ package input import ( "github.com/pingcap/log" regionpkg "github.com/pingcap/tidb-dashboard/pkg/keyvisual/region" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/pkg/encryption/key_manager_test.go b/pkg/encryption/key_manager_test.go index f6847403cae6..a8c2493adc78 100644 --- a/pkg/encryption/key_manager_test.go +++ b/pkg/encryption/key_manager_test.go @@ -28,11 +28,11 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pingcap/kvproto/pkg/encryptionpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/election" "github.com/tikv/pd/pkg/utils/etcdutil" "github.com/tikv/pd/pkg/utils/tempurl" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "go.etcd.io/etcd/clientv3" "go.etcd.io/etcd/embed" ) diff --git a/pkg/encryption/region_crypter.go b/pkg/encryption/region_crypter.go index e9b0b2405f94..346e8a08da0e 100644 --- a/pkg/encryption/region_crypter.go +++ b/pkg/encryption/region_crypter.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/encryptionpb" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" ) // processRegionKeys encrypt or decrypt the start key and end key of the region in-place, diff --git a/pkg/mock/mockcluster/mockcluster.go b/pkg/mock/mockcluster/mockcluster.go index bd0c63f639d1..70fd1f56c629 100644 --- a/pkg/mock/mockcluster/mockcluster.go +++ b/pkg/mock/mockcluster/mockcluster.go @@ -24,14 +24,14 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/id" "github.com/tikv/pd/pkg/mock/mockid" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule/labeler" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/server/statistics" diff --git a/pkg/mock/mockhbstream/mockhbstream.go b/pkg/mock/mockhbstream/mockhbstream.go index 54e563b95617..00e9fc65cf03 100644 --- a/pkg/mock/mockhbstream/mockhbstream.go +++ b/pkg/mock/mockhbstream/mockhbstream.go @@ -19,7 +19,7 @@ import ( "time" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule/hbstream" ) diff --git a/pkg/mock/mockhbstream/mockhbstream_test.go b/pkg/mock/mockhbstream/mockhbstream_test.go index 47fdc63b7a9f..49c631fdeb22 100644 --- a/pkg/mock/mockhbstream/mockhbstream_test.go +++ b/pkg/mock/mockhbstream/mockhbstream_test.go @@ -22,11 +22,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/hbstream" ) diff --git a/pkg/storage/endpoint/meta.go b/pkg/storage/endpoint/meta.go index bb848485c399..ed6a9d9ebd62 100644 --- a/pkg/storage/endpoint/meta.go +++ b/pkg/storage/endpoint/meta.go @@ -23,9 +23,9 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" ) // MetaStorage defines the storage operations on the PD cluster meta info. diff --git a/plugin/scheduler_example/evict_leader.go b/plugin/scheduler_example/evict_leader.go index 2c0f4a8474c1..5960ff99901a 100644 --- a/plugin/scheduler_example/evict_leader.go +++ b/plugin/scheduler_example/evict_leader.go @@ -22,11 +22,11 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/errors" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/api/admin_test.go b/server/api/admin_test.go index 3d7aef34a906..9e89de968dca 100644 --- a/server/api/admin_test.go +++ b/server/api/admin_test.go @@ -25,10 +25,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" ) type adminTestSuite struct { diff --git a/server/api/diagnostic_test.go b/server/api/diagnostic_test.go index 025dcf1aaf98..fe1dfce04a4e 100644 --- a/server/api/diagnostic_test.go +++ b/server/api/diagnostic_test.go @@ -22,12 +22,12 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedulers" ) diff --git a/server/api/min_resolved_ts_test.go b/server/api/min_resolved_ts_test.go index ea28da598fea..96c2a778f46d 100644 --- a/server/api/min_resolved_ts_test.go +++ b/server/api/min_resolved_ts_test.go @@ -22,6 +22,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" @@ -52,9 +53,9 @@ func (suite *minResolvedTSTestSuite) SetupSuite() { mustBootstrapCluster(re, suite.svr) mustPutStore(re, suite.svr, 1, metapb.StoreState_Up, metapb.NodeState_Serving, nil) - r1 := newTestRegionInfo(7, 1, []byte("a"), []byte("b")) + r1 := core.NewTestRegionInfo(7, 1, []byte("a"), []byte("b")) mustRegionHeartbeat(re, suite.svr, r1) - r2 := newTestRegionInfo(8, 1, []byte("b"), []byte("c")) + r2 := core.NewTestRegionInfo(8, 1, []byte("b"), []byte("c")) mustRegionHeartbeat(re, suite.svr, r2) } diff --git a/server/api/operator_test.go b/server/api/operator_test.go index d5995921f9e9..2788688ef7fa 100644 --- a/server/api/operator_test.go +++ b/server/api/operator_test.go @@ -29,13 +29,13 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockhbstream" "github.com/tikv/pd/pkg/utils/apiutil" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" pdoperator "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" ) @@ -139,11 +139,11 @@ func (suite *operatorTestSuite) TestAddRemovePeer() { func (suite *operatorTestSuite) TestMergeRegionOperator() { re := suite.Require() - r1 := newTestRegionInfo(10, 1, []byte(""), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1)) + r1 := core.NewTestRegionInfo(10, 1, []byte(""), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1)) mustRegionHeartbeat(re, suite.svr, r1) - r2 := newTestRegionInfo(20, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3)) + r2 := core.NewTestRegionInfo(20, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3)) mustRegionHeartbeat(re, suite.svr, r2) - r3 := newTestRegionInfo(30, 1, []byte("c"), []byte(""), core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) + r3 := core.NewTestRegionInfo(30, 1, []byte("c"), []byte(""), core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) mustRegionHeartbeat(re, suite.svr, r3) err := tu.CheckPostJSON(testDialClient, fmt.Sprintf("%s/operators", suite.urlPrefix), []byte(`{"name":"merge-region", "source_region_id": 10, "target_region_id": 20}`), tu.StatusOK(re)) diff --git a/server/api/region.go b/server/api/region.go index 244b02677c20..3f08fd99c09b 100644 --- a/server/api/region.go +++ b/server/api/region.go @@ -29,10 +29,10 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/kvproto/pkg/replication_modepb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/statistics" "github.com/unrolled/render" diff --git a/server/api/region_test.go b/server/api/region_test.go index 84ce1ad09838..f5beefd6b00b 100644 --- a/server/api/region_test.go +++ b/server/api/region_test.go @@ -31,9 +31,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" ) @@ -109,33 +109,12 @@ func (suite *regionTestSuite) TearDownSuite() { suite.cleanup() } -func newTestRegionInfo(regionID, storeID uint64, start, end []byte, opts ...core.RegionCreateOption) *core.RegionInfo { - leader := &metapb.Peer{ - Id: regionID, - StoreId: storeID, - } - metaRegion := &metapb.Region{ - Id: regionID, - StartKey: start, - EndKey: end, - Peers: []*metapb.Peer{leader}, - RegionEpoch: &metapb.RegionEpoch{ConfVer: 1, Version: 1}, - } - newOpts := []core.RegionCreateOption{ - core.SetApproximateKeys(10), - core.SetApproximateSize(10), - core.SetWrittenBytes(100 * units.MiB), - core.SetWrittenKeys(1 * units.MiB), - core.SetReadBytes(200 * units.MiB), - core.SetReadKeys(2 * units.MiB), - } - newOpts = append(newOpts, opts...) - region := core.NewRegionInfo(metaRegion, leader, newOpts...) - return region -} - func (suite *regionTestSuite) TestRegion() { - r := newTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r := core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b"), + core.SetWrittenBytes(100*units.MiB), + core.SetWrittenKeys(1*units.MiB), + core.SetReadBytes(200*units.MiB), + core.SetReadKeys(2*units.MiB)) buckets := &metapb.Buckets{ RegionId: 2, Keys: [][]byte{[]byte("a"), []byte("b")}, @@ -168,7 +147,9 @@ func (suite *regionTestSuite) TestRegion() { } func (suite *regionTestSuite) TestRegionCheck() { - r := newTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r := core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b"), + core.SetApproximateKeys(10), + core.SetApproximateSize(10)) downPeer := &metapb.Peer{Id: 13, StoreId: 2} r = r.Clone(core.WithAddPeer(downPeer), core.WithDownPeers([]*pdpb.PeerStats{{Peer: downPeer, DownSeconds: 3600}}), core.WithPendingPeers([]*metapb.Peer{downPeer})) re := suite.Require() @@ -228,9 +209,9 @@ func (suite *regionTestSuite) TestRegions() { suite.Len(r.Leader.RoleName, 0) rs := []*core.RegionInfo{ - newTestRegionInfo(2, 1, []byte("a"), []byte("b")), - newTestRegionInfo(3, 1, []byte("b"), []byte("c")), - newTestRegionInfo(4, 2, []byte("c"), []byte("d")), + core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b"), core.SetApproximateKeys(10), core.SetApproximateSize(10)), + core.NewTestRegionInfo(3, 1, []byte("b"), []byte("c"), core.SetApproximateKeys(10), core.SetApproximateSize(10)), + core.NewTestRegionInfo(4, 2, []byte("c"), []byte("d"), core.SetApproximateKeys(10), core.SetApproximateSize(10)), } regions := make([]RegionInfo, 0, len(rs)) re := suite.Require() @@ -255,9 +236,9 @@ func (suite *regionTestSuite) TestRegions() { func (suite *regionTestSuite) TestStoreRegions() { re := suite.Require() - r1 := newTestRegionInfo(2, 1, []byte("a"), []byte("b")) - r2 := newTestRegionInfo(3, 1, []byte("b"), []byte("c")) - r3 := newTestRegionInfo(4, 2, []byte("c"), []byte("d")) + r1 := core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r2 := core.NewTestRegionInfo(3, 1, []byte("b"), []byte("c")) + r3 := core.NewTestRegionInfo(4, 2, []byte("c"), []byte("d")) mustRegionHeartbeat(re, suite.svr, r1) mustRegionHeartbeat(re, suite.svr, r2) mustRegionHeartbeat(re, suite.svr, r3) @@ -294,11 +275,11 @@ func (suite *regionTestSuite) TestStoreRegions() { func (suite *regionTestSuite) TestTop() { // Top flow. re := suite.Require() - r1 := newTestRegionInfo(1, 1, []byte("a"), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1)) + r1 := core.NewTestRegionInfo(1, 1, []byte("a"), []byte("b"), core.SetWrittenBytes(1000), core.SetReadBytes(1000), core.SetRegionConfVer(1), core.SetRegionVersion(1)) mustRegionHeartbeat(re, suite.svr, r1) - r2 := newTestRegionInfo(2, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3)) + r2 := core.NewTestRegionInfo(2, 1, []byte("b"), []byte("c"), core.SetWrittenBytes(2000), core.SetReadBytes(0), core.SetRegionConfVer(2), core.SetRegionVersion(3)) mustRegionHeartbeat(re, suite.svr, r2) - r3 := newTestRegionInfo(3, 1, []byte("c"), []byte("d"), core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) + r3 := core.NewTestRegionInfo(3, 1, []byte("c"), []byte("d"), core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) mustRegionHeartbeat(re, suite.svr, r3) suite.checkTopRegions(fmt.Sprintf("%s/regions/writeflow", suite.urlPrefix), []uint64{2, 1, 3}) suite.checkTopRegions(fmt.Sprintf("%s/regions/readflow", suite.urlPrefix), []uint64{1, 3, 2}) @@ -310,26 +291,26 @@ func (suite *regionTestSuite) TestTop() { // Top size. baseOpt := []core.RegionCreateOption{core.SetRegionConfVer(3), core.SetRegionVersion(3)} opt := core.SetApproximateSize(1000) - r1 = newTestRegionInfo(1, 1, []byte("a"), []byte("b"), append(baseOpt, opt)...) + r1 = core.NewTestRegionInfo(1, 1, []byte("a"), []byte("b"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r1) opt = core.SetApproximateSize(900) - r2 = newTestRegionInfo(2, 1, []byte("b"), []byte("c"), append(baseOpt, opt)...) + r2 = core.NewTestRegionInfo(2, 1, []byte("b"), []byte("c"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r2) opt = core.SetApproximateSize(800) - r3 = newTestRegionInfo(3, 1, []byte("c"), []byte("d"), append(baseOpt, opt)...) + r3 = core.NewTestRegionInfo(3, 1, []byte("c"), []byte("d"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r3) suite.checkTopRegions(fmt.Sprintf("%s/regions/size?limit=2", suite.urlPrefix), []uint64{1, 2}) suite.checkTopRegions(fmt.Sprintf("%s/regions/size", suite.urlPrefix), []uint64{1, 2, 3}) // Top CPU usage. baseOpt = []core.RegionCreateOption{core.SetRegionConfVer(4), core.SetRegionVersion(4)} opt = core.SetCPUUsage(100) - r1 = newTestRegionInfo(1, 1, []byte("a"), []byte("b"), append(baseOpt, opt)...) + r1 = core.NewTestRegionInfo(1, 1, []byte("a"), []byte("b"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r1) opt = core.SetCPUUsage(300) - r2 = newTestRegionInfo(2, 1, []byte("b"), []byte("c"), append(baseOpt, opt)...) + r2 = core.NewTestRegionInfo(2, 1, []byte("b"), []byte("c"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r2) opt = core.SetCPUUsage(500) - r3 = newTestRegionInfo(3, 1, []byte("c"), []byte("d"), append(baseOpt, opt)...) + r3 = core.NewTestRegionInfo(3, 1, []byte("c"), []byte("d"), append(baseOpt, opt)...) mustRegionHeartbeat(re, suite.svr, r3) suite.checkTopRegions(fmt.Sprintf("%s/regions/cpu?limit=2", suite.urlPrefix), []uint64{3, 2}) suite.checkTopRegions(fmt.Sprintf("%s/regions/cpu", suite.urlPrefix), []uint64{3, 2, 1}) @@ -337,9 +318,9 @@ func (suite *regionTestSuite) TestTop() { func (suite *regionTestSuite) TestAccelerateRegionsScheduleInRange() { re := suite.Require() - r1 := newTestRegionInfo(557, 13, []byte("a1"), []byte("a2")) - r2 := newTestRegionInfo(558, 14, []byte("a2"), []byte("a3")) - r3 := newTestRegionInfo(559, 15, []byte("a3"), []byte("a4")) + r1 := core.NewTestRegionInfo(557, 13, []byte("a1"), []byte("a2")) + r2 := core.NewTestRegionInfo(558, 14, []byte("a2"), []byte("a3")) + r3 := core.NewTestRegionInfo(559, 15, []byte("a3"), []byte("a4")) mustRegionHeartbeat(re, suite.svr, r1) mustRegionHeartbeat(re, suite.svr, r2) mustRegionHeartbeat(re, suite.svr, r3) @@ -353,11 +334,11 @@ func (suite *regionTestSuite) TestAccelerateRegionsScheduleInRange() { func (suite *regionTestSuite) TestScatterRegions() { re := suite.Require() - r1 := newTestRegionInfo(601, 13, []byte("b1"), []byte("b2")) + r1 := core.NewTestRegionInfo(601, 13, []byte("b1"), []byte("b2")) r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 14}, &metapb.Peer{Id: 6, StoreId: 15}) - r2 := newTestRegionInfo(602, 13, []byte("b2"), []byte("b3")) + r2 := core.NewTestRegionInfo(602, 13, []byte("b2"), []byte("b3")) r2.GetMeta().Peers = append(r2.GetMeta().Peers, &metapb.Peer{Id: 7, StoreId: 14}, &metapb.Peer{Id: 8, StoreId: 15}) - r3 := newTestRegionInfo(603, 13, []byte("b4"), []byte("b4")) + r3 := core.NewTestRegionInfo(603, 13, []byte("b4"), []byte("b4")) r3.GetMeta().Peers = append(r3.GetMeta().Peers, &metapb.Peer{Id: 9, StoreId: 14}, &metapb.Peer{Id: 10, StoreId: 15}) mustRegionHeartbeat(re, suite.svr, r1) mustRegionHeartbeat(re, suite.svr, r2) @@ -383,7 +364,7 @@ func (suite *regionTestSuite) TestScatterRegions() { func (suite *regionTestSuite) TestSplitRegions() { re := suite.Require() - r1 := newTestRegionInfo(601, 13, []byte("aaa"), []byte("ggg")) + r1 := core.NewTestRegionInfo(601, 13, []byte("aaa"), []byte("ggg")) r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 13}, &metapb.Peer{Id: 6, StoreId: 13}) mustRegionHeartbeat(re, suite.svr, r1) mustPutStore(re, suite.svr, 13, metapb.StoreState_Up, metapb.NodeState_Serving, []*metapb.StoreLabel{}) @@ -424,7 +405,7 @@ func (suite *regionTestSuite) TestTopN() { regions := make([]*core.RegionInfo, 0, len(writtenBytes)) for _, i := range rand.Perm(len(writtenBytes)) { id := uint64(i + 1) - region := newTestRegionInfo(id, id, nil, nil, core.SetWrittenBytes(writtenBytes[i])) + region := core.NewTestRegionInfo(id, id, nil, nil, core.SetWrittenBytes(writtenBytes[i])) regions = append(regions, region) } topN := TopNRegions(regions, func(a, b *core.RegionInfo) bool { return a.GetBytesWritten() < b.GetBytesWritten() }, n) @@ -467,7 +448,7 @@ func (suite *getRegionTestSuite) TearDownSuite() { func (suite *getRegionTestSuite) TestRegionKey() { re := suite.Require() - r := newTestRegionInfo(99, 1, []byte{0xFF, 0xFF, 0xAA}, []byte{0xFF, 0xFF, 0xCC}, core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) + r := core.NewTestRegionInfo(99, 1, []byte{0xFF, 0xFF, 0xAA}, []byte{0xFF, 0xFF, 0xCC}, core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) mustRegionHeartbeat(re, suite.svr, r) url := fmt.Sprintf("%s/region/key/%s", suite.urlPrefix, url.QueryEscape(string([]byte{0xFF, 0xFF, 0xBB}))) RegionInfo := &RegionInfo{} @@ -478,11 +459,11 @@ func (suite *getRegionTestSuite) TestRegionKey() { func (suite *getRegionTestSuite) TestScanRegionByKeys() { re := suite.Require() - r1 := newTestRegionInfo(2, 1, []byte("a"), []byte("b")) - r2 := newTestRegionInfo(3, 1, []byte("b"), []byte("c")) - r3 := newTestRegionInfo(4, 2, []byte("c"), []byte("e")) - r4 := newTestRegionInfo(5, 2, []byte("x"), []byte("z")) - r := newTestRegionInfo(99, 1, []byte{0xFF, 0xFF, 0xAA}, []byte{0xFF, 0xFF, 0xCC}, core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) + r1 := core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r2 := core.NewTestRegionInfo(3, 1, []byte("b"), []byte("c")) + r3 := core.NewTestRegionInfo(4, 2, []byte("c"), []byte("e")) + r4 := core.NewTestRegionInfo(5, 2, []byte("x"), []byte("z")) + r := core.NewTestRegionInfo(99, 1, []byte{0xFF, 0xFF, 0xAA}, []byte{0xFF, 0xFF, 0xCC}, core.SetWrittenBytes(500), core.SetReadBytes(800), core.SetRegionConfVer(3), core.SetRegionVersion(2)) mustRegionHeartbeat(re, suite.svr, r1) mustRegionHeartbeat(re, suite.svr, r2) mustRegionHeartbeat(re, suite.svr, r3) @@ -574,12 +555,12 @@ func (suite *getRegionRangeHolesTestSuite) TearDownSuite() { func (suite *getRegionRangeHolesTestSuite) TestRegionRangeHoles() { re := suite.Require() // Missing r0 with range [0, 0xEA] - r1 := newTestRegionInfo(2, 1, []byte{0xEA}, []byte{0xEB}) + r1 := core.NewTestRegionInfo(2, 1, []byte{0xEA}, []byte{0xEB}) // Missing r2 with range [0xEB, 0xEC] - r3 := newTestRegionInfo(3, 1, []byte{0xEC}, []byte{0xED}) - r4 := newTestRegionInfo(4, 2, []byte{0xED}, []byte{0xEE}) + r3 := core.NewTestRegionInfo(3, 1, []byte{0xEC}, []byte{0xED}) + r4 := core.NewTestRegionInfo(4, 2, []byte{0xED}, []byte{0xEE}) // Missing r5 with range [0xEE, 0xFE] - r6 := newTestRegionInfo(5, 2, []byte{0xFE}, []byte{0xFF}) + r6 := core.NewTestRegionInfo(5, 2, []byte{0xFE}, []byte{0xFF}) mustRegionHeartbeat(re, suite.svr, r1) mustRegionHeartbeat(re, suite.svr, r3) mustRegionHeartbeat(re, suite.svr, r4) @@ -631,7 +612,7 @@ func (suite *regionsReplicatedTestSuite) TestCheckRegionsReplicated() { }() // add test region - r1 := newTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r1 := core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b")) mustRegionHeartbeat(re, suite.svr, r1) // set the bundle @@ -677,7 +658,7 @@ func (suite *regionsReplicatedTestSuite) TestCheckRegionsReplicated() { suite.Equal("PENDING", status) suite.NoError(failpoint.Disable("github.com/tikv/pd/server/api/mockPending")) // test multiple rules - r1 = newTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r1 = core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b")) r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 1}) mustRegionHeartbeat(re, suite.svr, r1) @@ -712,7 +693,7 @@ func (suite *regionsReplicatedTestSuite) TestCheckRegionsReplicated() { suite.NoError(err) suite.Equal("INPROGRESS", status) - r1 = newTestRegionInfo(2, 1, []byte("a"), []byte("b")) + r1 = core.NewTestRegionInfo(2, 1, []byte("a"), []byte("b")) r1.GetMeta().Peers = append(r1.GetMeta().Peers, &metapb.Peer{Id: 5, StoreId: 1}, &metapb.Peer{Id: 6, StoreId: 1}, &metapb.Peer{Id: 7, StoreId: 1}) mustRegionHeartbeat(re, suite.svr, r1) diff --git a/server/api/rule.go b/server/api/rule.go index 1a5db4ac1712..e67b6a90bddd 100644 --- a/server/api/rule.go +++ b/server/api/rule.go @@ -23,11 +23,11 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/errors" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/cluster" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/unrolled/render" ) diff --git a/server/api/rule_test.go b/server/api/rule_test.go index 2656903ed48d..72ae480b5fc7 100644 --- a/server/api/rule_test.go +++ b/server/api/rule_test.go @@ -24,11 +24,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" ) @@ -400,7 +400,7 @@ func (suite *ruleTestSuite) TestGetAllByRegion() { err = tu.CheckPostJSON(testDialClient, suite.urlPrefix+"/rule", data, tu.StatusOK(re)) suite.NoError(err) - r := newTestRegionInfo(4, 1, []byte{0x22, 0x22}, []byte{0x33, 0x33}) + r := core.NewTestRegionInfo(4, 1, []byte{0x22, 0x22}, []byte{0x33, 0x33}) mustRegionHeartbeat(re, suite.svr, r) testCases := []struct { diff --git a/server/api/stats_test.go b/server/api/stats_test.go index d501d54fc530..c7b6e7d2bcaf 100644 --- a/server/api/stats_test.go +++ b/server/api/stats_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/statistics" ) diff --git a/server/api/store.go b/server/api/store.go index 84adda24c1e0..6985a3738289 100644 --- a/server/api/store.go +++ b/server/api/store.go @@ -26,13 +26,13 @@ import ( "github.com/pingcap/errcode" "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/unrolled/render" ) diff --git a/server/api/store_test.go b/server/api/store_test.go index e47076424ad7..fb48bac80f1a 100644 --- a/server/api/store_test.go +++ b/server/api/store_test.go @@ -29,11 +29,11 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) type storeTestSuite struct { diff --git a/server/api/trend_test.go b/server/api/trend_test.go index 2b79d7b35f66..23d66caf947d 100644 --- a/server/api/trend_test.go +++ b/server/api/trend_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" tu "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index ae615dc35e88..71d01f8ee69a 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -31,6 +31,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/id" "github.com/tikv/pd/pkg/progress" @@ -43,8 +45,6 @@ import ( "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" syncer "github.com/tikv/pd/server/region_syncer" "github.com/tikv/pd/server/replication" "github.com/tikv/pd/server/schedule" diff --git a/server/cluster/cluster_test.go b/server/cluster/cluster_test.go index c8dbca4bb387..7847c4be5011 100644 --- a/server/cluster/cluster_test.go +++ b/server/cluster/cluster_test.go @@ -28,13 +28,13 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/id" "github.com/tikv/pd/pkg/mock/mockid" "github.com/tikv/pd/pkg/progress" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/labeler" @@ -930,7 +930,7 @@ func TestRegionFlowChanged(t *testing.T) { re.NoError(err) cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster()) cluster.coordinator = newCoordinator(ctx, cluster, nil) - regions := []*core.RegionInfo{core.NewTestRegionInfo([]byte{}, []byte{})} + regions := []*core.RegionInfo{core.NewTestRegionInfo(1, 1, []byte{}, []byte{})} processRegions := func(regions []*core.RegionInfo) { for _, r := range regions { cluster.processRegionHeartbeat(r) @@ -999,12 +999,12 @@ func TestConcurrentReportBucket(t *testing.T) { cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster()) cluster.coordinator = newCoordinator(ctx, cluster, nil) - regions := []*core.RegionInfo{core.NewTestRegionInfo([]byte{}, []byte{})} + regions := []*core.RegionInfo{core.NewTestRegionInfo(1, 1, []byte{}, []byte{})} heartbeatRegions(re, cluster, regions) - re.NotNil(cluster.GetRegion(0)) + re.NotNil(cluster.GetRegion(1)) - bucket1 := &metapb.Buckets{RegionId: 0, Version: 3} - bucket2 := &metapb.Buckets{RegionId: 0, Version: 2} + bucket1 := &metapb.Buckets{RegionId: 1, Version: 3} + bucket2 := &metapb.Buckets{RegionId: 1, Version: 2} var wg sync.WaitGroup wg.Add(1) re.NoError(failpoint.Enable("github.com/tikv/pd/server/cluster/concurrentBucketHeartbeat", "return(true)")) @@ -1016,7 +1016,7 @@ func TestConcurrentReportBucket(t *testing.T) { re.NoError(failpoint.Disable("github.com/tikv/pd/server/cluster/concurrentBucketHeartbeat")) re.NoError(cluster.processReportBuckets(bucket2)) wg.Wait() - re.Equal(bucket1, cluster.GetRegion(0).GetBuckets()) + re.Equal(bucket1, cluster.GetRegion(1).GetBuckets()) } func TestConcurrentRegionHeartbeat(t *testing.T) { @@ -1029,7 +1029,7 @@ func TestConcurrentRegionHeartbeat(t *testing.T) { cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster()) cluster.coordinator = newCoordinator(ctx, cluster, nil) - regions := []*core.RegionInfo{core.NewTestRegionInfo([]byte{}, []byte{})} + regions := []*core.RegionInfo{core.NewTestRegionInfo(1, 1, []byte{}, []byte{})} regions = core.SplitRegions(regions) heartbeatRegions(re, cluster, regions) @@ -1193,7 +1193,7 @@ func TestRegionSplitAndMerge(t *testing.T) { cluster := newTestRaftCluster(ctx, mockid.NewIDAllocator(), opt, storage.NewStorageWithMemoryBackend(), core.NewBasicCluster()) cluster.coordinator = newCoordinator(ctx, cluster, nil) - regions := []*core.RegionInfo{core.NewTestRegionInfo([]byte{}, []byte{})} + regions := []*core.RegionInfo{core.NewTestRegionInfo(1, 1, []byte{}, []byte{})} // Byte will underflow/overflow if n > 7. n := 7 @@ -1385,7 +1385,7 @@ func TestTopologyWeight(t *testing.T) { "rack": rack, "host": host, } - store := core.NewStoreInfoWithLabel(storeID, 1, storeLabels) + store := core.NewStoreInfoWithLabel(storeID, storeLabels) if i == 0 && j == 0 && k == 0 { testStore = store } @@ -1401,12 +1401,12 @@ func TestTopologyWeight1(t *testing.T) { re := require.New(t) labels := []string{"dc", "zone", "host"} - store1 := core.NewStoreInfoWithLabel(1, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) - store2 := core.NewStoreInfoWithLabel(2, 1, map[string]string{"dc": "dc2", "zone": "zone2", "host": "host2"}) - store3 := core.NewStoreInfoWithLabel(3, 1, map[string]string{"dc": "dc3", "zone": "zone3", "host": "host3"}) - store4 := core.NewStoreInfoWithLabel(4, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) - store5 := core.NewStoreInfoWithLabel(5, 1, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host2"}) - store6 := core.NewStoreInfoWithLabel(6, 1, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host3"}) + store1 := core.NewStoreInfoWithLabel(1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) + store2 := core.NewStoreInfoWithLabel(2, map[string]string{"dc": "dc2", "zone": "zone2", "host": "host2"}) + store3 := core.NewStoreInfoWithLabel(3, map[string]string{"dc": "dc3", "zone": "zone3", "host": "host3"}) + store4 := core.NewStoreInfoWithLabel(4, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) + store5 := core.NewStoreInfoWithLabel(5, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host2"}) + store6 := core.NewStoreInfoWithLabel(6, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host3"}) stores := []*core.StoreInfo{store1, store2, store3, store4, store5, store6} re.Equal(1.0/3, getStoreTopoWeight(store2, stores, labels, 3)) @@ -1418,11 +1418,11 @@ func TestTopologyWeight2(t *testing.T) { re := require.New(t) labels := []string{"dc", "zone", "host"} - store1 := core.NewStoreInfoWithLabel(1, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) - store2 := core.NewStoreInfoWithLabel(2, 1, map[string]string{"dc": "dc2"}) - store3 := core.NewStoreInfoWithLabel(3, 1, map[string]string{"dc": "dc3"}) - store4 := core.NewStoreInfoWithLabel(4, 1, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host1"}) - store5 := core.NewStoreInfoWithLabel(5, 1, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host1"}) + store1 := core.NewStoreInfoWithLabel(1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) + store2 := core.NewStoreInfoWithLabel(2, map[string]string{"dc": "dc2"}) + store3 := core.NewStoreInfoWithLabel(3, map[string]string{"dc": "dc3"}) + store4 := core.NewStoreInfoWithLabel(4, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host1"}) + store5 := core.NewStoreInfoWithLabel(5, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host1"}) stores := []*core.StoreInfo{store1, store2, store3, store4, store5} re.Equal(1.0/3, getStoreTopoWeight(store2, stores, labels, 3)) @@ -1433,17 +1433,17 @@ func TestTopologyWeight3(t *testing.T) { re := require.New(t) labels := []string{"dc", "zone", "host"} - store1 := core.NewStoreInfoWithLabel(1, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) - store2 := core.NewStoreInfoWithLabel(2, 1, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host2"}) - store3 := core.NewStoreInfoWithLabel(3, 1, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host3"}) - store4 := core.NewStoreInfoWithLabel(4, 1, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host4"}) - store5 := core.NewStoreInfoWithLabel(5, 1, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host5"}) - store6 := core.NewStoreInfoWithLabel(6, 1, map[string]string{"dc": "dc2", "zone": "zone5", "host": "host6"}) - - store7 := core.NewStoreInfoWithLabel(7, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host7"}) - store8 := core.NewStoreInfoWithLabel(8, 1, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host8"}) - store9 := core.NewStoreInfoWithLabel(9, 1, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host9"}) - store10 := core.NewStoreInfoWithLabel(10, 1, map[string]string{"dc": "dc2", "zone": "zone5", "host": "host10"}) + store1 := core.NewStoreInfoWithLabel(1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) + store2 := core.NewStoreInfoWithLabel(2, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host2"}) + store3 := core.NewStoreInfoWithLabel(3, map[string]string{"dc": "dc1", "zone": "zone3", "host": "host3"}) + store4 := core.NewStoreInfoWithLabel(4, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host4"}) + store5 := core.NewStoreInfoWithLabel(5, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host5"}) + store6 := core.NewStoreInfoWithLabel(6, map[string]string{"dc": "dc2", "zone": "zone5", "host": "host6"}) + + store7 := core.NewStoreInfoWithLabel(7, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host7"}) + store8 := core.NewStoreInfoWithLabel(8, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host8"}) + store9 := core.NewStoreInfoWithLabel(9, map[string]string{"dc": "dc2", "zone": "zone4", "host": "host9"}) + store10 := core.NewStoreInfoWithLabel(10, map[string]string{"dc": "dc2", "zone": "zone5", "host": "host10"}) stores := []*core.StoreInfo{store1, store2, store3, store4, store5, store6, store7, store8, store9, store10} re.Equal(1.0/5/2, getStoreTopoWeight(store7, stores, labels, 5)) @@ -1456,10 +1456,10 @@ func TestTopologyWeight4(t *testing.T) { re := require.New(t) labels := []string{"dc", "zone", "host"} - store1 := core.NewStoreInfoWithLabel(1, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) - store2 := core.NewStoreInfoWithLabel(2, 1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host2"}) - store3 := core.NewStoreInfoWithLabel(3, 1, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host3"}) - store4 := core.NewStoreInfoWithLabel(4, 1, map[string]string{"dc": "dc2", "zone": "zone1", "host": "host4"}) + store1 := core.NewStoreInfoWithLabel(1, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host1"}) + store2 := core.NewStoreInfoWithLabel(2, map[string]string{"dc": "dc1", "zone": "zone1", "host": "host2"}) + store3 := core.NewStoreInfoWithLabel(3, map[string]string{"dc": "dc1", "zone": "zone2", "host": "host3"}) + store4 := core.NewStoreInfoWithLabel(4, map[string]string{"dc": "dc2", "zone": "zone1", "host": "host4"}) stores := []*core.StoreInfo{store1, store2, store3, store4} @@ -1753,8 +1753,8 @@ func TestCheckStaleRegion(t *testing.T) { re := require.New(t) // (0, 0) v.s. (0, 0) - region := core.NewTestRegionInfo([]byte{}, []byte{}) - origin := core.NewTestRegionInfo([]byte{}, []byte{}) + region := core.NewTestRegionInfo(1, 1, []byte{}, []byte{}) + origin := core.NewTestRegionInfo(1, 1, []byte{}, []byte{}) re.NoError(checkStaleRegion(region.GetMeta(), origin.GetMeta())) re.NoError(checkStaleRegion(origin.GetMeta(), region.GetMeta())) diff --git a/server/cluster/cluster_worker.go b/server/cluster/cluster_worker.go index d1d2a3ced948..86645db7c6af 100644 --- a/server/cluster/cluster_worker.go +++ b/server/cluster/cluster_worker.go @@ -21,11 +21,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/statistics/buckets" "go.uber.org/zap" diff --git a/server/cluster/cluster_worker_test.go b/server/cluster/cluster_worker_test.go index 8c747c6c847b..95b734d25d95 100644 --- a/server/cluster/cluster_worker_test.go +++ b/server/cluster/cluster_worker_test.go @@ -21,8 +21,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockid" - "github.com/tikv/pd/server/core" _ "github.com/tikv/pd/server/schedulers" "github.com/tikv/pd/server/storage" ) diff --git a/server/cluster/coordinator.go b/server/cluster/coordinator.go index 03f0182f2bae..0d3aeea904c8 100644 --- a/server/cluster/coordinator.go +++ b/server/cluster/coordinator.go @@ -27,11 +27,11 @@ import ( "github.com/pingcap/failpoint" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/checker" "github.com/tikv/pd/server/schedule/hbstream" diff --git a/server/cluster/coordinator_test.go b/server/cluster/coordinator_test.go index 2fa61faa14e4..b9332919cd92 100644 --- a/server/cluster/coordinator_test.go +++ b/server/cluster/coordinator_test.go @@ -28,12 +28,12 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/mock/mockhbstream" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/labeler" diff --git a/server/cluster/prepare_checker.go b/server/cluster/prepare_checker.go index 9358a0a30ad5..39d4cab1f912 100644 --- a/server/cluster/prepare_checker.go +++ b/server/cluster/prepare_checker.go @@ -17,8 +17,8 @@ package cluster import ( "time" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" ) type prepareChecker struct { diff --git a/server/cluster/store_limiter.go b/server/cluster/store_limiter.go index 619c1b127ecc..f4b317ffe22f 100644 --- a/server/cluster/store_limiter.go +++ b/server/cluster/store_limiter.go @@ -17,9 +17,9 @@ package cluster import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core/storelimit" "go.uber.org/zap" ) diff --git a/server/cluster/store_limiter_test.go b/server/cluster/store_limiter_test.go index 7a1dcab9fad8..d7561a2c64fd 100644 --- a/server/cluster/store_limiter_test.go +++ b/server/cluster/store_limiter_test.go @@ -19,8 +19,8 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core/storelimit" ) func TestCollect(t *testing.T) { diff --git a/server/cluster/unsafe_recovery_controller.go b/server/cluster/unsafe_recovery_controller.go index 26f85db06ccc..f1d6b880425e 100644 --- a/server/cluster/unsafe_recovery_controller.go +++ b/server/cluster/unsafe_recovery_controller.go @@ -29,10 +29,10 @@ import ( "github.com/pingcap/log" "github.com/tikv/pd/pkg/btree" "github.com/tikv/pd/pkg/codec" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/server/cluster/unsafe_recovery_controller_test.go b/server/cluster/unsafe_recovery_controller_test.go index 1baf14668538..da5f6883f9c9 100644 --- a/server/cluster/unsafe_recovery_controller_test.go +++ b/server/cluster/unsafe_recovery_controller_test.go @@ -25,8 +25,8 @@ import ( "github.com/pingcap/kvproto/pkg/raft_serverpb" "github.com/stretchr/testify/require" "github.com/tikv/pd/pkg/codec" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockid" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/storage" ) diff --git a/server/config/config.go b/server/config/config.go index 872ddda1f375..0b36e66407dd 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -27,6 +27,7 @@ import ( "time" "github.com/docker/go-units" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/grpcutil" @@ -35,7 +36,6 @@ import ( "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" - "github.com/tikv/pd/server/core/storelimit" "github.com/BurntSushi/toml" "github.com/coreos/go-semver/semver" diff --git a/server/config/persist_options.go b/server/config/persist_options.go index c4f98969fffa..bdb3abd70c2f 100644 --- a/server/config/persist_options.go +++ b/server/config/persist_options.go @@ -30,12 +30,12 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/etcdutil" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "go.etcd.io/etcd/clientv3" ) diff --git a/server/core/test_util.go b/server/core/test_util.go deleted file mode 100644 index f0dfc45acfcb..000000000000 --- a/server/core/test_util.go +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright 2016 TiKV Project Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package core - -import ( - "math" - "math/rand" - "time" - - "github.com/docker/go-units" - "github.com/pingcap/kvproto/pkg/metapb" - "github.com/pingcap/kvproto/pkg/pdpb" -) - -// SplitRegions split a set of RegionInfo by the middle of regionKey -func SplitRegions(regions []*RegionInfo) []*RegionInfo { - results := make([]*RegionInfo, 0, len(regions)*2) - for _, region := range regions { - start, end := byte(0), byte(math.MaxUint8) - if len(region.GetStartKey()) > 0 { - start = region.GetStartKey()[0] - } - if len(region.GetEndKey()) > 0 { - end = region.GetEndKey()[0] - } - middle := []byte{start/2 + end/2} - left := region.Clone() - left.meta.Id = region.GetID() + uint64(len(regions)) - left.meta.EndKey = middle - left.meta.RegionEpoch.Version++ - right := region.Clone() - right.meta.Id = region.GetID() + uint64(len(regions)*2) - right.meta.StartKey = middle - right.meta.RegionEpoch.Version++ - results = append(results, left, right) - } - return results -} - -// MergeRegions merge a set of RegionInfo by regionKey -func MergeRegions(regions []*RegionInfo) []*RegionInfo { - results := make([]*RegionInfo, 0, len(regions)/2) - for i := 0; i < len(regions); i += 2 { - left := regions[i] - right := regions[i] - if i+1 < len(regions) { - right = regions[i+1] - } - region := &RegionInfo{meta: &metapb.Region{ - Id: left.GetID(), - StartKey: left.GetStartKey(), - EndKey: right.GetEndKey(), - Peers: left.meta.Peers, - }} - if left.GetRegionEpoch().GetVersion() > right.GetRegionEpoch().GetVersion() { - region.meta.RegionEpoch = left.GetRegionEpoch() - } else { - region.meta.RegionEpoch = right.GetRegionEpoch() - } - region.meta.RegionEpoch.Version++ - region.leader = left.leader - results = append(results, region) - } - return results -} - -// NewTestRegionInfo creates a RegionInfo for test. -func NewTestRegionInfo(start, end []byte) *RegionInfo { - return &RegionInfo{meta: &metapb.Region{ - StartKey: start, - EndKey: end, - RegionEpoch: &metapb.RegionEpoch{}, - }} -} - -// NewStoreInfoWithAvailable is created with available and capacity -func NewStoreInfoWithAvailable(id, available, capacity uint64, amp float64) *StoreInfo { - stats := &pdpb.StoreStats{} - stats.Capacity = capacity - stats.Available = available - usedSize := capacity - available - regionSize := (float64(usedSize) * amp) / units.MiB - store := NewStoreInfo( - &metapb.Store{ - Id: id, - }, - SetStoreStats(stats), - SetRegionCount(int(regionSize/96)), - SetRegionSize(int64(regionSize)), - ) - return store -} - -// NewStoreInfoWithLabel is create a store with specified labels. -func NewStoreInfoWithLabel(id uint64, regionCount int, labels map[string]string) *StoreInfo { - storeLabels := make([]*metapb.StoreLabel, 0, len(labels)) - for k, v := range labels { - storeLabels = append(storeLabels, &metapb.StoreLabel{ - Key: k, - Value: v, - }) - } - stats := &pdpb.StoreStats{} - stats.Capacity = units.GiB / units.MiB - stats.Available = units.GiB / units.MiB - store := NewStoreInfo( - &metapb.Store{ - Id: id, - Labels: storeLabels, - }, - SetStoreStats(stats), - SetRegionCount(regionCount), - SetRegionSize(int64(regionCount)*10), - ) - return store -} - -// NewStoreInfoWithSizeCount is create a store with size and count. -func NewStoreInfoWithSizeCount(id uint64, regionCount, leaderCount int, regionSize, leaderSize int64) *StoreInfo { - stats := &pdpb.StoreStats{} - stats.Capacity = units.GiB / units.MiB - stats.Available = units.GiB / units.MiB - store := NewStoreInfo( - &metapb.Store{ - Id: id, - }, - SetStoreStats(stats), - SetRegionCount(regionCount), - SetRegionSize(regionSize), - SetLeaderCount(leaderCount), - SetLeaderSize(leaderSize), - ) - return store -} - -// RandomKindReadQuery returns query stat with random query kind, only used for unit test. -func RandomKindReadQuery(queryRead uint64) *pdpb.QueryStats { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - switch r.Intn(3) { - case 0: - return &pdpb.QueryStats{ - Coprocessor: queryRead, - } - case 1: - return &pdpb.QueryStats{ - Scan: queryRead, - } - case 2: - return &pdpb.QueryStats{ - Get: queryRead, - } - default: - return &pdpb.QueryStats{} - } -} - -// RandomKindWriteQuery returns query stat with random query kind, only used for unit test. -func RandomKindWriteQuery(queryWrite uint64) *pdpb.QueryStats { - r := rand.New(rand.NewSource(time.Now().UnixNano())) - switch r.Intn(7) { - case 0: - return &pdpb.QueryStats{ - Put: queryWrite, - } - case 1: - return &pdpb.QueryStats{ - Delete: queryWrite, - } - case 2: - return &pdpb.QueryStats{ - DeleteRange: queryWrite, - } - case 3: - return &pdpb.QueryStats{ - AcquirePessimisticLock: queryWrite, - } - case 4: - return &pdpb.QueryStats{ - Rollback: queryWrite, - } - case 5: - return &pdpb.QueryStats{ - Prewrite: queryWrite, - } - case 6: - return &pdpb.QueryStats{ - Commit: queryWrite, - } - default: - return &pdpb.QueryStats{} - } -} diff --git a/server/grpc_service.go b/server/grpc_service.go index 8a5685c7b92d..a0791b4a3e48 100644 --- a/server/grpc_service.go +++ b/server/grpc_service.go @@ -27,6 +27,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/storage/kv" @@ -35,7 +36,6 @@ import ( "github.com/tikv/pd/pkg/utils/tsoutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/cluster" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/tso" "go.etcd.io/etcd/clientv3" "go.uber.org/zap" diff --git a/server/handler.go b/server/handler.go index 96654069550f..a28f2d3d47ad 100644 --- a/server/handler.go +++ b/server/handler.go @@ -29,14 +29,14 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/region_syncer/client.go b/server/region_syncer/client.go index 3b4850368602..a7ccb8967aa8 100644 --- a/server/region_syncer/client.go +++ b/server/region_syncer/client.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/grpcutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/storage" "go.uber.org/zap" "google.golang.org/grpc" diff --git a/server/region_syncer/client_test.go b/server/region_syncer/client_test.go index 315c1e70b55b..419da6f54d28 100644 --- a/server/region_syncer/client_test.go +++ b/server/region_syncer/client_test.go @@ -23,8 +23,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/grpcutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/storage" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/server/region_syncer/history_buffer.go b/server/region_syncer/history_buffer.go index a8b07498458a..eed2a2ab7102 100644 --- a/server/region_syncer/history_buffer.go +++ b/server/region_syncer/history_buffer.go @@ -18,10 +18,10 @@ import ( "strconv" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/kv" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/server/region_syncer/history_buffer_test.go b/server/region_syncer/history_buffer_test.go index e74e55220fcb..4bca5b7f6031 100644 --- a/server/region_syncer/history_buffer_test.go +++ b/server/region_syncer/history_buffer_test.go @@ -19,8 +19,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/kv" - "github.com/tikv/pd/server/core" ) func TestBufferSize(t *testing.T) { diff --git a/server/region_syncer/server.go b/server/region_syncer/server.go index f8dbb8f1ab4f..b7626cc3ecf2 100644 --- a/server/region_syncer/server.go +++ b/server/region_syncer/server.go @@ -26,12 +26,12 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/ratelimit" "github.com/tikv/pd/pkg/storage/kv" "github.com/tikv/pd/pkg/utils/grpcutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/storage" "go.uber.org/zap" "google.golang.org/grpc/codes" diff --git a/server/replication/replication_mode.go b/server/replication/replication_mode.go index b9c465dc5c22..60877f31d542 100644 --- a/server/replication/replication_mode.go +++ b/server/replication/replication_mode.go @@ -27,13 +27,13 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" pb "github.com/pingcap/kvproto/pkg/replication_modepb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "go.uber.org/zap" ) diff --git a/server/replication/replication_mode_test.go b/server/replication/replication_mode_test.go index e51e9ff51d25..371618e7a17c 100644 --- a/server/replication/replication_mode_test.go +++ b/server/replication/replication_mode_test.go @@ -24,10 +24,10 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" pb "github.com/pingcap/kvproto/pkg/replication_modepb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/storage" ) diff --git a/server/schedule/checker/checker_controller.go b/server/schedule/checker/checker_controller.go index 63f8a15061cc..58776bbebd45 100644 --- a/server/schedule/checker/checker_controller.go +++ b/server/schedule/checker/checker_controller.go @@ -19,10 +19,10 @@ import ( "time" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/keyutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/labeler" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedule/checker/joint_state_checker.go b/server/schedule/checker/joint_state_checker.go index cc1edbea5ba3..27ec911672a2 100644 --- a/server/schedule/checker/joint_state_checker.go +++ b/server/schedule/checker/joint_state_checker.go @@ -16,8 +16,8 @@ package checker import ( "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/checker/joint_state_checker_test.go b/server/schedule/checker/joint_state_checker_test.go index 9b10ada8c769..1ea0ddd21f7f 100644 --- a/server/schedule/checker/joint_state_checker_test.go +++ b/server/schedule/checker/joint_state_checker_test.go @@ -20,9 +20,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/checker/learner_checker.go b/server/schedule/checker/learner_checker.go index f120982dd395..4769e7ea021e 100644 --- a/server/schedule/checker/learner_checker.go +++ b/server/schedule/checker/learner_checker.go @@ -16,8 +16,8 @@ package checker import ( "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/checker/learner_checker_test.go b/server/schedule/checker/learner_checker_test.go index b55550d974cb..d5fdf25f40c5 100644 --- a/server/schedule/checker/learner_checker_test.go +++ b/server/schedule/checker/learner_checker_test.go @@ -20,10 +20,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/checker/merge_checker.go b/server/schedule/checker/merge_checker.go index f30d7ebb077c..eb3d6746c790 100644 --- a/server/schedule/checker/merge_checker.go +++ b/server/schedule/checker/merge_checker.go @@ -22,10 +22,10 @@ import ( "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" "github.com/tikv/pd/pkg/codec" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/labeler" diff --git a/server/schedule/checker/merge_checker_test.go b/server/schedule/checker/merge_checker_test.go index 2c2d4aac344d..df3a61477d92 100644 --- a/server/schedule/checker/merge_checker_test.go +++ b/server/schedule/checker/merge_checker_test.go @@ -22,12 +22,12 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/labeler" diff --git a/server/schedule/checker/priority_inspector.go b/server/schedule/checker/priority_inspector.go index 63d5df11c21a..5c5d2c0b3770 100644 --- a/server/schedule/checker/priority_inspector.go +++ b/server/schedule/checker/priority_inspector.go @@ -18,8 +18,8 @@ import ( "time" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/schedule/checker/replica_checker.go b/server/schedule/checker/replica_checker.go index fe092a36c465..796e180fde31 100644 --- a/server/schedule/checker/replica_checker.go +++ b/server/schedule/checker/replica_checker.go @@ -20,9 +20,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "go.uber.org/zap" diff --git a/server/schedule/checker/replica_checker_test.go b/server/schedule/checker/replica_checker_test.go index 857107489495..798f21ba2850 100644 --- a/server/schedule/checker/replica_checker_test.go +++ b/server/schedule/checker/replica_checker_test.go @@ -24,11 +24,11 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/suite" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/checker/replica_strategy.go b/server/schedule/checker/replica_strategy.go index 92f35595f73f..aa70fc0accb8 100644 --- a/server/schedule/checker/replica_strategy.go +++ b/server/schedule/checker/replica_strategy.go @@ -16,7 +16,7 @@ package checker import ( "github.com/pingcap/log" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "go.uber.org/zap" diff --git a/server/schedule/checker/rule_checker.go b/server/schedule/checker/rule_checker.go index e3b02b96905a..3f10576b13c4 100644 --- a/server/schedule/checker/rule_checker.go +++ b/server/schedule/checker/rule_checker.go @@ -25,9 +25,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/versioninfo" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedule/checker/rule_checker_test.go b/server/schedule/checker/rule_checker_test.go index ae3419895e97..7346d3afc85f 100644 --- a/server/schedule/checker/rule_checker_test.go +++ b/server/schedule/checker/rule_checker_test.go @@ -25,12 +25,12 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/suite" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/schedule/checker/split_checker.go b/server/schedule/checker/split_checker.go index 1b0db44df473..494ce5675d3e 100644 --- a/server/schedule/checker/split_checker.go +++ b/server/schedule/checker/split_checker.go @@ -17,8 +17,8 @@ package checker import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/labeler" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedule/cluster.go b/server/schedule/cluster.go index b18ba040b225..71edd8d8e043 100644 --- a/server/schedule/cluster.go +++ b/server/schedule/cluster.go @@ -15,7 +15,7 @@ package schedule import ( - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/statistics" "github.com/tikv/pd/server/statistics/buckets" diff --git a/server/schedule/filter/candidates.go b/server/schedule/filter/candidates.go index 3eb38d8cad2c..2e6f5fade436 100644 --- a/server/schedule/filter/candidates.go +++ b/server/schedule/filter/candidates.go @@ -18,8 +18,8 @@ import ( "math/rand" "sort" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/plan" ) diff --git a/server/schedule/filter/candidates_test.go b/server/schedule/filter/candidates_test.go index 78ed69c0f798..d2d94862d007 100644 --- a/server/schedule/filter/candidates_test.go +++ b/server/schedule/filter/candidates_test.go @@ -19,8 +19,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/plan" ) diff --git a/server/schedule/filter/comparer.go b/server/schedule/filter/comparer.go index 0cd245840ad2..a4068bb8d63e 100644 --- a/server/schedule/filter/comparer.go +++ b/server/schedule/filter/comparer.go @@ -15,8 +15,8 @@ package filter import ( + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) // StoreComparer compares 2 stores. Often used for StoreCandidates to diff --git a/server/schedule/filter/filters.go b/server/schedule/filter/filters.go index 1100defd549d..03426cbc1612 100644 --- a/server/schedule/filter/filters.go +++ b/server/schedule/filter/filters.go @@ -19,11 +19,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/server/schedule/plan" "go.uber.org/zap" diff --git a/server/schedule/filter/filters_test.go b/server/schedule/filter/filters_test.go index 61084599d415..076e17184f8c 100644 --- a/server/schedule/filter/filters_test.go +++ b/server/schedule/filter/filters_test.go @@ -18,12 +18,13 @@ import ( "testing" "time" + "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/server/schedule/plan" ) @@ -32,12 +33,12 @@ func TestDistinctScoreFilter(t *testing.T) { re := require.New(t) labels := []string{"zone", "rack", "host"} allStores := []*core.StoreInfo{ - core.NewStoreInfoWithLabel(1, 1, map[string]string{"zone": "z1", "rack": "r1", "host": "h1"}), - core.NewStoreInfoWithLabel(2, 1, map[string]string{"zone": "z1", "rack": "r1", "host": "h2"}), - core.NewStoreInfoWithLabel(3, 1, map[string]string{"zone": "z1", "rack": "r2", "host": "h1"}), - core.NewStoreInfoWithLabel(4, 1, map[string]string{"zone": "z2", "rack": "r1", "host": "h1"}), - core.NewStoreInfoWithLabel(5, 1, map[string]string{"zone": "z2", "rack": "r2", "host": "h1"}), - core.NewStoreInfoWithLabel(6, 1, map[string]string{"zone": "z3", "rack": "r1", "host": "h1"}), + core.NewStoreInfoWithLabel(1, map[string]string{"zone": "z1", "rack": "r1", "host": "h1"}), + core.NewStoreInfoWithLabel(2, map[string]string{"zone": "z1", "rack": "r1", "host": "h2"}), + core.NewStoreInfoWithLabel(3, map[string]string{"zone": "z1", "rack": "r2", "host": "h1"}), + core.NewStoreInfoWithLabel(4, map[string]string{"zone": "z2", "rack": "r1", "host": "h1"}), + core.NewStoreInfoWithLabel(5, map[string]string{"zone": "z2", "rack": "r2", "host": "h1"}), + core.NewStoreInfoWithLabel(6, map[string]string{"zone": "z3", "rack": "r1", "host": "h1"}), } testCases := []struct { @@ -70,7 +71,7 @@ func TestLabelConstraintsFilter(t *testing.T) { opt := config.NewTestOptions() testCluster := mockcluster.NewCluster(ctx, opt) - store := core.NewStoreInfoWithLabel(1, 1, map[string]string{"id": "1"}) + store := core.NewStoreInfoWithLabel(1, map[string]string{"id": "1"}) testCases := []struct { key string @@ -156,7 +157,7 @@ func TestStoreStateFilter(t *testing.T) { &StoreStateFilter{MoveRegion: true, AllowTemporaryStates: true}, } opt := config.NewTestOptions() - store := core.NewStoreInfoWithLabel(1, 0, map[string]string{}) + store := core.NewStoreInfoWithLabel(1, map[string]string{}) type testCase struct { filterIdx int @@ -208,7 +209,7 @@ func TestStoreStateFilterReason(t *testing.T) { &StoreStateFilter{MoveRegion: true, AllowTemporaryStates: true}, } opt := config.NewTestOptions() - store := core.NewStoreInfoWithLabel(1, 0, map[string]string{}) + store := core.NewStoreInfoWithLabel(1, map[string]string{}) type testCase struct { filterIdx int @@ -375,7 +376,8 @@ func TestSpecialUseFilter(t *testing.T) { {map[string]string{core.EngineKey: core.EngineTiKV}, []string{""}, plan.StatusOK, plan.StatusOK}, } for _, testCase := range testCases { - store := core.NewStoreInfoWithLabel(1, 1, testCase.label) + store := core.NewStoreInfoWithLabel(1, testCase.label) + store = store.Clone(core.SetStoreStats(&pdpb.StoreStats{StoreId: 1, Capacity: 100 * units.GiB, Available: 100 * units.GiB})) filter := NewSpecialUseFilter("", testCase.allowUse...) re.Equal(testCase.sourceRes, filter.Source(testCluster.GetOpts(), store).StatusCode) re.Equal(testCase.targetRes, filter.Target(testCluster.GetOpts(), store).StatusCode) diff --git a/server/schedule/filter/healthy.go b/server/schedule/filter/healthy.go index 6ff65d4df965..ce9dcee793b9 100644 --- a/server/schedule/filter/healthy.go +++ b/server/schedule/filter/healthy.go @@ -15,8 +15,8 @@ package filter import ( + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/schedule/filter/healthy_test.go b/server/schedule/filter/healthy_test.go index 92afa753543c..82598e7832f6 100644 --- a/server/schedule/filter/healthy_test.go +++ b/server/schedule/filter/healthy_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) func TestIsRegionHealthy(t *testing.T) { diff --git a/server/schedule/filter/region_filters.go b/server/schedule/filter/region_filters.go index 7b2613583452..673a4b2efe56 100644 --- a/server/schedule/filter/region_filters.go +++ b/server/schedule/filter/region_filters.go @@ -15,8 +15,8 @@ package filter import ( + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/slice" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/server/schedule/plan" ) diff --git a/server/schedule/filter/region_filters_test.go b/server/schedule/filter/region_filters_test.go index 65f77f25c2a8..d351f1a2c25a 100644 --- a/server/schedule/filter/region_filters_test.go +++ b/server/schedule/filter/region_filters_test.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) func TestRegionPendingFilter(t *testing.T) { diff --git a/server/schedule/hbstream/heartbeat_streams.go b/server/schedule/hbstream/heartbeat_streams.go index be28d288013e..d80b6ff3a46c 100644 --- a/server/schedule/hbstream/heartbeat_streams.go +++ b/server/schedule/hbstream/heartbeat_streams.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/server/schedule/labeler/labeler.go b/server/schedule/labeler/labeler.go index d617f9c6944b..5c9a50e00b21 100644 --- a/server/schedule/labeler/labeler.go +++ b/server/schedule/labeler/labeler.go @@ -21,10 +21,10 @@ import ( "time" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/rangelist" "go.uber.org/zap" ) diff --git a/server/schedule/labeler/labeler_test.go b/server/schedule/labeler/labeler_test.go index 8a435bf01acf..6f547a836338 100644 --- a/server/schedule/labeler/labeler_test.go +++ b/server/schedule/labeler/labeler_test.go @@ -25,9 +25,9 @@ import ( "github.com/pingcap/failpoint" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/storage/kv" - "github.com/tikv/pd/server/core" ) func TestAdjustRule(t *testing.T) { @@ -164,7 +164,7 @@ func TestIndex(t *testing.T) { for _, testCase := range testCases { start, _ := hex.DecodeString(testCase.start) end, _ := hex.DecodeString(testCase.end) - region := core.NewTestRegionInfo(start, end) + region := core.NewTestRegionInfo(1, 1, start, end) labels := labeler.GetRegionLabels(region) re.Len(labels, len(testCase.labels)) for _, l := range labels { @@ -250,7 +250,7 @@ func TestKeyRange(t *testing.T) { for _, testCase := range testCases { start, _ := hex.DecodeString(testCase.start) end, _ := hex.DecodeString(testCase.end) - region := core.NewTestRegionInfo(start, end) + region := core.NewTestRegionInfo(1, 1, start, end) labels := labeler.GetRegionLabels(region) re.Len(labels, len(testCase.labels)) for _, l := range labels { @@ -293,7 +293,7 @@ func TestLabelerRuleTTL(t *testing.T) { start, _ := hex.DecodeString("1234") end, _ := hex.DecodeString("5678") - region := core.NewTestRegionInfo(start, end) + region := core.NewTestRegionInfo(1, 1, start, end) // the region has no lable rule at the beginning. re.Empty(labeler.GetRegionLabels(region)) @@ -343,7 +343,7 @@ func TestGC(t *testing.T) { ttls := []string{"1ms", "1ms", "1ms", "5ms", "5ms", "10ms", "1h", "24h"} start, _ := hex.DecodeString("1234") end, _ := hex.DecodeString("5678") - region := core.NewTestRegionInfo(start, end) + region := core.NewTestRegionInfo(1, 1, start, end) // the region has no lable rule at the beginning. re.Empty(labeler.GetRegionLabels(region)) diff --git a/server/schedule/operator/builder.go b/server/schedule/operator/builder.go index 0123ae85a7e3..23178d1af33f 100644 --- a/server/schedule/operator/builder.go +++ b/server/schedule/operator/builder.go @@ -20,11 +20,11 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/id" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/schedule/operator/builder_test.go b/server/schedule/operator/builder_test.go index d4dfe4610053..87993e6eac0e 100644 --- a/server/schedule/operator/builder_test.go +++ b/server/schedule/operator/builder_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) type operatorBuilderTestSuite struct { diff --git a/server/schedule/operator/create_operator.go b/server/schedule/operator/create_operator.go index a3723c3e66f2..c44b8184cfc7 100644 --- a/server/schedule/operator/create_operator.go +++ b/server/schedule/operator/create_operator.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/logutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "go.uber.org/zap" ) diff --git a/server/schedule/operator/create_operator_test.go b/server/schedule/operator/create_operator_test.go index ae4b117d44bd..856bd451306d 100644 --- a/server/schedule/operator/create_operator_test.go +++ b/server/schedule/operator/create_operator_test.go @@ -24,10 +24,10 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/schedule/operator/influence.go b/server/schedule/operator/influence.go index c4e7c58c3218..c7ba53ba293e 100644 --- a/server/schedule/operator/influence.go +++ b/server/schedule/operator/influence.go @@ -15,8 +15,8 @@ package operator import ( - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" ) // OpInfluence records the influence of the cluster. diff --git a/server/schedule/operator/operator.go b/server/schedule/operator/operator.go index 3fae9d86eea2..1df18aacfb1c 100644 --- a/server/schedule/operator/operator.go +++ b/server/schedule/operator/operator.go @@ -24,7 +24,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/prometheus/client_golang/prometheus" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) const ( @@ -151,6 +151,11 @@ func (o *Operator) Status() OpStatus { return o.status.Status() } +// SetStatusReachTime sets the reach time of the operator, only for test purpose. +func (o *Operator) SetStatusReachTime(st OpStatus, t time.Time) { + o.status.setTime(st, t) +} + // CheckAndGetStatus returns operator status after `CheckExpired` and `CheckTimeout`. func (o *Operator) CheckAndGetStatus() OpStatus { switch { diff --git a/server/schedule/operator/operator_test.go b/server/schedule/operator/operator_test.go index 87e44e7a6c6d..acc48dbfe0ef 100644 --- a/server/schedule/operator/operator_test.go +++ b/server/schedule/operator/operator_test.go @@ -24,10 +24,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" ) type operatorTestSuite struct { @@ -121,7 +121,7 @@ func (suite *operatorTestSuite) TestOperator() { suite.Nil(op.Check(region)) suite.Equal(SUCCESS, op.Status()) - SetOperatorStatusReachTime(op, STARTED, time.Now().Add(-SlowStepWaitTime-time.Second)) + op.SetStatusReachTime(STARTED, time.Now().Add(-SlowStepWaitTime-time.Second)) suite.False(op.CheckTimeout()) // addPeer1, transferLeader1, removePeer2 @@ -137,9 +137,9 @@ func (suite *operatorTestSuite) TestOperator() { suite.Equal(RemovePeer{FromStore: 2}, op.Check(region)) suite.Equal(int32(2), atomic.LoadInt32(&op.currentStep)) suite.False(op.CheckTimeout()) - SetOperatorStatusReachTime(op, STARTED, op.GetStartTime().Add(-FastStepWaitTime-2*FastStepWaitTime+time.Second)) + op.SetStatusReachTime(STARTED, op.GetStartTime().Add(-FastStepWaitTime-2*FastStepWaitTime+time.Second)) suite.False(op.CheckTimeout()) - SetOperatorStatusReachTime(op, STARTED, op.GetStartTime().Add(-SlowStepWaitTime-2*FastStepWaitTime-time.Second)) + op.SetStatusReachTime(STARTED, op.GetStartTime().Add(-SlowStepWaitTime-2*FastStepWaitTime-time.Second)) suite.True(op.CheckTimeout()) res, err := json.Marshal(op) suite.NoError(err) @@ -150,7 +150,7 @@ func (suite *operatorTestSuite) TestOperator() { op = suite.newTestOperator(1, OpLeader, steps...) op.Start() suite.False(op.CheckTimeout()) - SetOperatorStatusReachTime(op, STARTED, op.GetStartTime().Add(-FastStepWaitTime-time.Second)) + op.SetStatusReachTime(STARTED, op.GetStartTime().Add(-FastStepWaitTime-time.Second)) suite.True(op.CheckTimeout()) // case2: check timeout operator will return false not panic. @@ -311,7 +311,7 @@ func (suite *operatorTestSuite) TestCheckTimeout() { suite.Equal(CREATED, op.Status()) suite.True(op.Start()) op.currentStep = int32(len(op.steps)) - SetOperatorStatusReachTime(op, STARTED, time.Now().Add(-SlowStepWaitTime)) + op.SetStatusReachTime(STARTED, time.Now().Add(-SlowStepWaitTime)) suite.False(op.CheckTimeout()) suite.Equal(SUCCESS, op.Status()) } @@ -340,7 +340,7 @@ func (suite *operatorTestSuite) TestCheckExpired() { op := suite.newTestOperator(1, OpLeader|OpRegion, steps...) suite.False(op.CheckExpired()) suite.Equal(CREATED, op.Status()) - SetOperatorStatusReachTime(op, CREATED, time.Now().Add(-OperatorExpireTime)) + op.SetStatusReachTime(CREATED, time.Now().Add(-OperatorExpireTime)) suite.True(op.CheckExpired()) suite.Equal(EXPIRED, op.Status()) } @@ -374,7 +374,7 @@ func (suite *operatorTestSuite) TestCheck() { suite.True(op.Start()) suite.NotNil(op.Check(region)) suite.Equal(STARTED, op.Status()) - SetOperatorStatusReachTime(op, STARTED, time.Now().Add(-SlowStepWaitTime-2*FastStepWaitTime)) + op.SetStatusReachTime(STARTED, time.Now().Add(-SlowStepWaitTime-2*FastStepWaitTime)) suite.NotNil(op.Check(region)) suite.Equal(TIMEOUT, op.Status()) } diff --git a/server/schedule/operator/step.go b/server/schedule/operator/step.go index 4adbaf7c747c..5b17e62f11a3 100644 --- a/server/schedule/operator/step.go +++ b/server/schedule/operator/step.go @@ -25,9 +25,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "go.uber.org/zap" ) diff --git a/server/schedule/operator/step_test.go b/server/schedule/operator/step_test.go index 5bf097fa0867..5640b3eff311 100644 --- a/server/schedule/operator/step_test.go +++ b/server/schedule/operator/step_test.go @@ -20,9 +20,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) type operatorStepTestSuite struct { diff --git a/server/schedule/operator/test_util.go b/server/schedule/operator/test_util.go deleted file mode 100644 index 328973ad35c0..000000000000 --- a/server/schedule/operator/test_util.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2019 TiKV Project Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package operator - -import ( - "time" -) - -// SetOperatorStatusReachTime sets the reach time of the operator. -// NOTE: Should only use in test. -func SetOperatorStatusReachTime(op *Operator, st OpStatus, t time.Time) { - op.status.setTime(st, t) -} diff --git a/server/schedule/operator_controller.go b/server/schedule/operator_controller.go index 662fdb9883b6..650172c49aff 100644 --- a/server/schedule/operator_controller.go +++ b/server/schedule/operator_controller.go @@ -25,11 +25,11 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/pkg/versioninfo" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/labeler" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedule/operator_controller_test.go b/server/schedule/operator_controller_test.go index afbfdc22e1b2..2417e697fc0f 100644 --- a/server/schedule/operator_controller_test.go +++ b/server/schedule/operator_controller_test.go @@ -27,10 +27,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/labeler" "github.com/tikv/pd/server/schedule/operator" @@ -122,7 +122,7 @@ func (suite *operatorControllerTestSuite) TestOperatorStatus() { oc.SetOperator(op2) suite.Equal(pdpb.OperatorStatus_RUNNING, oc.GetOperatorStatus(1).Status) suite.Equal(pdpb.OperatorStatus_RUNNING, oc.GetOperatorStatus(2).Status) - operator.SetOperatorStatusReachTime(op1, operator.STARTED, time.Now().Add(-operator.SlowStepWaitTime-operator.FastStepWaitTime)) + op1.SetStatusReachTime(operator.STARTED, time.Now().Add(-operator.SlowStepWaitTime-operator.FastStepWaitTime)) region2 = ApplyOperatorStep(region2, op2) tc.PutRegion(region2) oc.Dispatch(region1, "test") @@ -233,8 +233,8 @@ func (suite *operatorControllerTestSuite) TestCheckAddUnexpectedStatus() { op1 := operator.NewTestOperator(1, &metapb.RegionEpoch{}, operator.OpRegion, operator.TransferLeader{ToStore: 2}) op2 := operator.NewTestOperator(2, &metapb.RegionEpoch{}, operator.OpRegion, operator.TransferLeader{ToStore: 1}) suite.True(oc.checkAddOperator(false, op1, op2)) - operator.SetOperatorStatusReachTime(op1, operator.CREATED, time.Now().Add(-operator.OperatorExpireTime)) - operator.SetOperatorStatusReachTime(op2, operator.CREATED, time.Now().Add(-operator.OperatorExpireTime)) + op1.SetStatusReachTime(operator.CREATED, time.Now().Add(-operator.OperatorExpireTime)) + op2.SetStatusReachTime(operator.CREATED, time.Now().Add(-operator.OperatorExpireTime)) suite.False(oc.checkAddOperator(false, op1, op2)) suite.Equal(operator.EXPIRED, op1.Status()) suite.Equal(operator.EXPIRED, op2.Status()) @@ -246,7 +246,7 @@ func (suite *operatorControllerTestSuite) TestCheckAddUnexpectedStatus() { op := operator.NewTestOperator(1, &metapb.RegionEpoch{}, operator.OpRegion, steps...) suite.True(oc.checkAddOperator(false, op)) op.Start() - operator.SetOperatorStatusReachTime(op, operator.STARTED, time.Now().Add(-operator.SlowStepWaitTime-operator.FastStepWaitTime)) + op.SetStatusReachTime(operator.STARTED, time.Now().Add(-operator.SlowStepWaitTime-operator.FastStepWaitTime)) suite.True(op.CheckTimeout()) suite.False(oc.checkAddOperator(false, op)) } diff --git a/server/schedule/placement/fit.go b/server/schedule/placement/fit.go index 0856aa660ffd..7a4a056a176e 100644 --- a/server/schedule/placement/fit.go +++ b/server/schedule/placement/fit.go @@ -20,8 +20,8 @@ import ( "sort" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" ) const replicaBaseScore = 100 diff --git a/server/schedule/placement/fit_region_test.go b/server/schedule/placement/fit_region_test.go index c8a5f2f2f797..55b0e76a2d22 100644 --- a/server/schedule/placement/fit_region_test.go +++ b/server/schedule/placement/fit_region_test.go @@ -20,7 +20,7 @@ import ( "time" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) type mockStoresSet struct { diff --git a/server/schedule/placement/fit_test.go b/server/schedule/placement/fit_test.go index 164720fe9aa5..dcd643d4a968 100644 --- a/server/schedule/placement/fit_test.go +++ b/server/schedule/placement/fit_test.go @@ -23,7 +23,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func makeStores() StoreSet { @@ -42,7 +42,7 @@ func makeStores() StoreSet { if x == 5 { labels["engine"] = "tiflash" } - stores.SetStore(core.NewStoreInfoWithLabel(id, 0, labels)) + stores.SetStore(core.NewStoreInfoWithLabel(id, labels)) } } } diff --git a/server/schedule/placement/label_constraint.go b/server/schedule/placement/label_constraint.go index 4c615e1b28fe..2fcef35d05dc 100644 --- a/server/schedule/placement/label_constraint.go +++ b/server/schedule/placement/label_constraint.go @@ -17,8 +17,8 @@ package placement import ( "strings" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/slice" - "github.com/tikv/pd/server/core" ) // LabelConstraintOp defines how a LabelConstraint matches a store. It can be one of diff --git a/server/schedule/placement/label_constraint_test.go b/server/schedule/placement/label_constraint_test.go index dd6feebe94f5..e65676f0a5ed 100644 --- a/server/schedule/placement/label_constraint_test.go +++ b/server/schedule/placement/label_constraint_test.go @@ -18,7 +18,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func TestLabelConstraint(t *testing.T) { @@ -50,7 +50,7 @@ func TestLabelConstraint(t *testing.T) { for i, constraint := range constraints { var matched []int for j, store := range stores { - if constraint.MatchStore(core.NewStoreInfoWithLabel(uint64(j), 0, store)) { + if constraint.MatchStore(core.NewStoreInfoWithLabel(uint64(j), store)) { matched = append(matched, j+1) } } @@ -89,7 +89,7 @@ func TestLabelConstraints(t *testing.T) { for i, cs := range constraints { var matched []int for j, store := range stores { - if MatchLabelConstraints(core.NewStoreInfoWithLabel(uint64(j), 0, store), cs) { + if MatchLabelConstraints(core.NewStoreInfoWithLabel(uint64(j), store), cs) { matched = append(matched, j+1) } } diff --git a/server/schedule/placement/region_rule_cache.go b/server/schedule/placement/region_rule_cache.go index a7006ba6c5dc..41efff3023ae 100644 --- a/server/schedule/placement/region_rule_cache.go +++ b/server/schedule/placement/region_rule_cache.go @@ -16,9 +16,9 @@ package placement import ( "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" ) // RegionRuleFitCacheManager stores each region's RegionFit Result and involving variables diff --git a/server/schedule/placement/region_rule_cache_test.go b/server/schedule/placement/region_rule_cache_test.go index a9224c49162b..63beaa98c349 100644 --- a/server/schedule/placement/region_rule_cache_test.go +++ b/server/schedule/placement/region_rule_cache_test.go @@ -21,7 +21,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func TestRegionRuleFitCache(t *testing.T) { diff --git a/server/schedule/placement/rule_manager.go b/server/schedule/placement/rule_manager.go index ff13f155afb6..eabafe327491 100644 --- a/server/schedule/placement/rule_manager.go +++ b/server/schedule/placement/rule_manager.go @@ -26,12 +26,12 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/log" "github.com/tikv/pd/pkg/codec" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "go.uber.org/zap" "golang.org/x/exp/slices" ) diff --git a/server/schedule/placement/rule_manager_test.go b/server/schedule/placement/rule_manager_test.go index 21735341af7e..84b7620e5264 100644 --- a/server/schedule/placement/rule_manager_test.go +++ b/server/schedule/placement/rule_manager_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" "github.com/tikv/pd/pkg/codec" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/storage/kv" - "github.com/tikv/pd/server/core" ) func newTestManager(t *testing.T) (endpoint.RuleStorage, *RuleManager) { diff --git a/server/schedule/range_cluster.go b/server/schedule/range_cluster.go index 631e6b043252..5c2645c4a3eb 100644 --- a/server/schedule/range_cluster.go +++ b/server/schedule/range_cluster.go @@ -16,7 +16,7 @@ package schedule import ( "github.com/docker/go-units" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // RangeCluster isolates the cluster by range. diff --git a/server/schedule/region_scatterer.go b/server/schedule/region_scatterer.go index 26993f1292f1..8500598a3736 100644 --- a/server/schedule/region_scatterer.go +++ b/server/schedule/region_scatterer.go @@ -26,10 +26,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/cache" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" diff --git a/server/schedule/region_scatterer_test.go b/server/schedule/region_scatterer_test.go index 965b5b989997..3657bd8e4b88 100644 --- a/server/schedule/region_scatterer_test.go +++ b/server/schedule/region_scatterer_test.go @@ -26,10 +26,10 @@ import ( "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" diff --git a/server/schedule/region_splitter.go b/server/schedule/region_splitter.go index 60e6c269e565..3c4c70283385 100644 --- a/server/schedule/region_splitter.go +++ b/server/schedule/region_splitter.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/logutil" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" "go.uber.org/zap" diff --git a/server/schedule/region_splitter_test.go b/server/schedule/region_splitter_test.go index b135800f9b1f..10bf81411fef 100644 --- a/server/schedule/region_splitter_test.go +++ b/server/schedule/region_splitter_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) type mockSplitRegionsHandler struct { diff --git a/server/schedule/test_util.go b/server/schedule/test_util.go index 67b6f8914742..118770e60f1f 100644 --- a/server/schedule/test_util.go +++ b/server/schedule/test_util.go @@ -16,8 +16,8 @@ package schedule import ( "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedule/waiting_operator_test.go b/server/schedule/waiting_operator_test.go index 8c639c1568ca..f09b7a01eed5 100644 --- a/server/schedule/waiting_operator_test.go +++ b/server/schedule/waiting_operator_test.go @@ -19,7 +19,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule/operator" ) diff --git a/server/schedulers/balance_leader.go b/server/schedulers/balance_leader.go index cc2b2090dea9..afab6b175585 100644 --- a/server/schedulers/balance_leader.go +++ b/server/schedulers/balance_leader.go @@ -25,12 +25,12 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/log" "github.com/prometheus/client_golang/prometheus" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/reflectutil" "github.com/tikv/pd/pkg/utils/syncutil" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/balance_leader_test.go b/server/schedulers/balance_leader_test.go index 06257ff072d0..6e485effa064 100644 --- a/server/schedulers/balance_leader_test.go +++ b/server/schedulers/balance_leader_test.go @@ -20,9 +20,9 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) func TestBalanceLeaderSchedulerConfigClone(t *testing.T) { diff --git a/server/schedulers/balance_plan.go b/server/schedulers/balance_plan.go index 04dd1a494c19..34c16943a090 100644 --- a/server/schedulers/balance_plan.go +++ b/server/schedulers/balance_plan.go @@ -15,8 +15,8 @@ package schedulers import ( + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/plan" ) diff --git a/server/schedulers/balance_plan_test.go b/server/schedulers/balance_plan_test.go index 842fc984b3d7..465429f7d8d2 100644 --- a/server/schedulers/balance_plan_test.go +++ b/server/schedulers/balance_plan_test.go @@ -20,7 +20,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/suite" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule/plan" ) diff --git a/server/schedulers/balance_region.go b/server/schedulers/balance_region.go index 4a78fc3e1b74..8d661c246f56 100644 --- a/server/schedulers/balance_region.go +++ b/server/schedulers/balance_region.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" "github.com/prometheus/client_golang/prometheus" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/balance_test.go b/server/schedulers/balance_test.go index d1fb637d98bb..2394f38112bd 100644 --- a/server/schedulers/balance_test.go +++ b/server/schedulers/balance_test.go @@ -25,11 +25,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/hbstream" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/evict_leader.go b/server/schedulers/evict_leader.go index 8249cb8bb1f9..ffdc60108684 100644 --- a/server/schedulers/evict_leader.go +++ b/server/schedulers/evict_leader.go @@ -22,11 +22,11 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/evict_leader_test.go b/server/schedulers/evict_leader_test.go index 6138a6d238a1..609b84dc9136 100644 --- a/server/schedulers/evict_leader_test.go +++ b/server/schedulers/evict_leader_test.go @@ -22,10 +22,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/storage" diff --git a/server/schedulers/evict_slow_store.go b/server/schedulers/evict_slow_store.go index e2fc4417441b..915cdc8c34d6 100644 --- a/server/schedulers/evict_slow_store.go +++ b/server/schedulers/evict_slow_store.go @@ -18,8 +18,8 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/failpoint" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/plan" diff --git a/server/schedulers/evict_slow_store_test.go b/server/schedulers/evict_slow_store_test.go index ec0453f3ed13..f1dca1472ede 100644 --- a/server/schedulers/evict_slow_store_test.go +++ b/server/schedulers/evict_slow_store_test.go @@ -22,10 +22,10 @@ import ( "github.com/pingcap/failpoint" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/storage" diff --git a/server/schedulers/grant_hot_region.go b/server/schedulers/grant_hot_region.go index 39fde37eb4cf..83f654b2de50 100644 --- a/server/schedulers/grant_hot_region.go +++ b/server/schedulers/grant_hot_region.go @@ -23,12 +23,12 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/grant_leader.go b/server/schedulers/grant_leader.go index 95fc4061c6ec..d62fa07bfd21 100644 --- a/server/schedulers/grant_leader.go +++ b/server/schedulers/grant_leader.go @@ -21,11 +21,11 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/errors" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/hot_region.go b/server/schedulers/hot_region.go index fddaa61b2cef..6c4c68c682d3 100644 --- a/server/schedulers/hot_region.go +++ b/server/schedulers/hot_region.go @@ -25,11 +25,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/hot_region_test.go b/server/schedulers/hot_region_test.go index 19ba8c638bdf..a19925c5d14c 100644 --- a/server/schedulers/hot_region_test.go +++ b/server/schedulers/hot_region_test.go @@ -24,13 +24,13 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" @@ -137,8 +137,8 @@ func TestGCPendingOpInfos(t *testing.T) { re.NoError(err) re.NotNil(op) op.Start() - operator.SetOperatorStatusReachTime(op, operator.CREATED, time.Now().Add(-5*statistics.StoreHeartBeatReportInterval*time.Second)) - operator.SetOperatorStatusReachTime(op, operator.STARTED, time.Now().Add((-5*statistics.StoreHeartBeatReportInterval+1)*time.Second)) + op.SetStatusReachTime(operator.CREATED, time.Now().Add(-5*statistics.StoreHeartBeatReportInterval*time.Second)) + op.SetStatusReachTime(operator.STARTED, time.Now().Add((-5*statistics.StoreHeartBeatReportInterval+1)*time.Second)) return newPendingInfluence(op, 2, 4, statistics.Influence{}, hb.conf.GetStoreStatZombieDuration()) } justDoneOpInfluence := func(region *core.RegionInfo, ty opType) *pendingInfluence { @@ -148,7 +148,7 @@ func TestGCPendingOpInfos(t *testing.T) { } shouldRemoveOpInfluence := func(region *core.RegionInfo, ty opType) *pendingInfluence { infl := justDoneOpInfluence(region, ty) - operator.SetOperatorStatusReachTime(infl.op, operator.CANCELED, time.Now().Add(-3*statistics.StoreHeartBeatReportInterval*time.Second)) + infl.op.SetStatusReachTime(operator.CANCELED, time.Now().Add(-3*statistics.StoreHeartBeatReportInterval*time.Second)) return infl } opInfluenceCreators := [3]func(region *core.RegionInfo, ty opType) *pendingInfluence{shouldRemoveOpInfluence, notDoneOpInfluence, justDoneOpInfluence} diff --git a/server/schedulers/label.go b/server/schedulers/label.go index 7a772f1e814a..856a39d978ae 100644 --- a/server/schedulers/label.go +++ b/server/schedulers/label.go @@ -16,10 +16,10 @@ package schedulers import ( "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/random_merge.go b/server/schedulers/random_merge.go index cfa8909f5c62..ecd9903dc308 100644 --- a/server/schedulers/random_merge.go +++ b/server/schedulers/random_merge.go @@ -18,9 +18,9 @@ import ( "math/rand" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/checker" "github.com/tikv/pd/server/schedule/filter" diff --git a/server/schedulers/scatter_range.go b/server/schedulers/scatter_range.go index 8579c2d149e7..e428c6994a66 100644 --- a/server/schedulers/scatter_range.go +++ b/server/schedulers/scatter_range.go @@ -20,11 +20,11 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/errors" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/plan" diff --git a/server/schedulers/scheduler_test.go b/server/schedulers/scheduler_test.go index c6cf0caa6677..5e8c3f8986a8 100644 --- a/server/schedulers/scheduler_test.go +++ b/server/schedulers/scheduler_test.go @@ -21,11 +21,11 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" diff --git a/server/schedulers/shuffle_hot_region.go b/server/schedulers/shuffle_hot_region.go index 79ec205bf48e..731510c2ed80 100644 --- a/server/schedulers/shuffle_hot_region.go +++ b/server/schedulers/shuffle_hot_region.go @@ -19,9 +19,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/shuffle_leader.go b/server/schedulers/shuffle_leader.go index 038a6b0b3b2c..d243a48ce922 100644 --- a/server/schedulers/shuffle_leader.go +++ b/server/schedulers/shuffle_leader.go @@ -16,9 +16,9 @@ package schedulers import ( "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/shuffle_region.go b/server/schedulers/shuffle_region.go index 919ce3662335..dfc08fc20642 100644 --- a/server/schedulers/shuffle_region.go +++ b/server/schedulers/shuffle_region.go @@ -18,9 +18,9 @@ import ( "net/http" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/shuffle_region_config.go b/server/schedulers/shuffle_region_config.go index 5f429a071c97..1dbe1a362f25 100644 --- a/server/schedulers/shuffle_region_config.go +++ b/server/schedulers/shuffle_region_config.go @@ -18,11 +18,11 @@ import ( "net/http" "github.com/gorilla/mux" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/apiutil" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/placement" "github.com/unrolled/render" diff --git a/server/schedulers/split_bucket.go b/server/schedulers/split_bucket.go index be69fda23ba7..ed99d5c5133c 100644 --- a/server/schedulers/split_bucket.go +++ b/server/schedulers/split_bucket.go @@ -23,9 +23,9 @@ import ( "github.com/gorilla/mux" "github.com/pingcap/kvproto/pkg/pdpb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/plan" diff --git a/server/schedulers/split_bucket_test.go b/server/schedulers/split_bucket_test.go index 0101b7169de5..2d703082e394 100644 --- a/server/schedulers/split_bucket_test.go +++ b/server/schedulers/split_bucket_test.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/statistics/buckets" diff --git a/server/schedulers/transfer_witness_leader.go b/server/schedulers/transfer_witness_leader.go index 5d2980fc0ce2..daefb180911a 100644 --- a/server/schedulers/transfer_witness_leader.go +++ b/server/schedulers/transfer_witness_leader.go @@ -17,9 +17,9 @@ package schedulers import ( "github.com/pingcap/errors" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/filter" "github.com/tikv/pd/server/schedule/operator" diff --git a/server/schedulers/transfer_witness_leader_test.go b/server/schedulers/transfer_witness_leader_test.go index 7c2d71098f0c..0a8321d5d6f7 100644 --- a/server/schedulers/transfer_witness_leader_test.go +++ b/server/schedulers/transfer_witness_leader_test.go @@ -21,10 +21,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockcluster" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/storage" diff --git a/server/schedulers/utils.go b/server/schedulers/utils.go index 277ca904fdb4..1ec55d8a5eaf 100644 --- a/server/schedulers/utils.go +++ b/server/schedulers/utils.go @@ -20,8 +20,8 @@ import ( "time" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/schedule/placement" diff --git a/server/schedulers/utils_test.go b/server/schedulers/utils_test.go index aee8de1eaae0..f9c4b5e2bd53 100644 --- a/server/schedulers/utils_test.go +++ b/server/schedulers/utils_test.go @@ -19,7 +19,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func TestRetryQuota(t *testing.T) { diff --git a/server/server.go b/server/server.go index f09721b48441..93fd57bfbcb6 100644 --- a/server/server.go +++ b/server/server.go @@ -40,6 +40,7 @@ import ( "github.com/pingcap/log" "github.com/pingcap/sysutil" "github.com/tikv/pd/pkg/audit" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/id" @@ -58,7 +59,6 @@ import ( "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/gc" "github.com/tikv/pd/server/keyspace" syncer "github.com/tikv/pd/server/region_syncer" diff --git a/server/statistics/buckets/bucket_stat_informer.go b/server/statistics/buckets/bucket_stat_informer.go index bfa0b4fd7f8a..5e7aa28059f3 100644 --- a/server/statistics/buckets/bucket_stat_informer.go +++ b/server/statistics/buckets/bucket_stat_informer.go @@ -18,10 +18,10 @@ import ( "bytes" "fmt" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/rangetree" "github.com/tikv/pd/pkg/slice" "github.com/tikv/pd/pkg/utils/keyutil" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/rangetree" "github.com/tikv/pd/server/statistics" ) diff --git a/server/statistics/buckets/hot_bucket_cache.go b/server/statistics/buckets/hot_bucket_cache.go index 4addb224f664..4de3ec99f7cc 100644 --- a/server/statistics/buckets/hot_bucket_cache.go +++ b/server/statistics/buckets/hot_bucket_cache.go @@ -21,9 +21,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core/rangetree" "github.com/tikv/pd/pkg/utils/keyutil" "github.com/tikv/pd/pkg/utils/logutil" - "github.com/tikv/pd/server/core/rangetree" "go.uber.org/zap" ) diff --git a/server/statistics/collector.go b/server/statistics/collector.go index 73fff9b4c843..23312ede9d3c 100644 --- a/server/statistics/collector.go +++ b/server/statistics/collector.go @@ -14,7 +14,7 @@ package statistics -import "github.com/tikv/pd/server/core" +import "github.com/tikv/pd/pkg/core" // storeCollector define the behavior of different engines of stores. type storeCollector interface { diff --git a/server/statistics/hot_cache.go b/server/statistics/hot_cache.go index 66121e8d0268..8d315b994c08 100644 --- a/server/statistics/hot_cache.go +++ b/server/statistics/hot_cache.go @@ -18,8 +18,8 @@ import ( "context" "time" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/movingaverage" - "github.com/tikv/pd/server/core" ) // HotCache is a cache hold hot regions. diff --git a/server/statistics/hot_cache_task.go b/server/statistics/hot_cache_task.go index 3fbf24b71f1c..b6fdd1c4f471 100644 --- a/server/statistics/hot_cache_task.go +++ b/server/statistics/hot_cache_task.go @@ -17,7 +17,7 @@ package statistics import ( "context" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // FlowItemTask indicates the task in flowItem queue diff --git a/server/statistics/hot_peer_cache.go b/server/statistics/hot_peer_cache.go index b55df21133e9..a268b5f86a4a 100644 --- a/server/statistics/hot_peer_cache.go +++ b/server/statistics/hot_peer_cache.go @@ -21,8 +21,8 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/slice" - "github.com/tikv/pd/server/core" ) const ( diff --git a/server/statistics/hot_peer_cache_test.go b/server/statistics/hot_peer_cache_test.go index e627d9c9023e..c62b5689c246 100644 --- a/server/statistics/hot_peer_cache_test.go +++ b/server/statistics/hot_peer_cache_test.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/movingaverage" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" ) func TestStoreTimeUnsync(t *testing.T) { diff --git a/server/statistics/hot_regions_stat.go b/server/statistics/hot_regions_stat.go index 92a5181ab8ab..d606a0d8bb40 100644 --- a/server/statistics/hot_regions_stat.go +++ b/server/statistics/hot_regions_stat.go @@ -17,7 +17,7 @@ package statistics import ( "time" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // HotPeersStat records all hot regions statistics diff --git a/server/statistics/kind.go b/server/statistics/kind.go index 06f8f64ca072..55c61750b107 100644 --- a/server/statistics/kind.go +++ b/server/statistics/kind.go @@ -15,7 +15,7 @@ package statistics import ( - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) const ( diff --git a/server/statistics/kind_test.go b/server/statistics/kind_test.go index cd3769d700b6..9928c7851a4e 100644 --- a/server/statistics/kind_test.go +++ b/server/statistics/kind_test.go @@ -20,7 +20,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func TestGetLoads(t *testing.T) { diff --git a/server/statistics/region.go b/server/statistics/region.go index 2822bb64eade..95954def0864 100644 --- a/server/statistics/region.go +++ b/server/statistics/region.go @@ -15,7 +15,7 @@ package statistics import ( - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // RegionStats records a list of regions' statistics and distribution status. diff --git a/server/statistics/region_collection.go b/server/statistics/region_collection.go index ab5e6b22d9c1..f852e39bc872 100644 --- a/server/statistics/region_collection.go +++ b/server/statistics/region_collection.go @@ -19,8 +19,8 @@ import ( "time" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" ) diff --git a/server/statistics/region_collection_test.go b/server/statistics/region_collection_test.go index 7c686f1c9cef..3960b7a7ded2 100644 --- a/server/statistics/region_collection_test.go +++ b/server/statistics/region_collection_test.go @@ -20,8 +20,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/server/storage" ) diff --git a/server/statistics/region_stat_informer.go b/server/statistics/region_stat_informer.go index 48c80c2978e7..8b5ba536cb7c 100644 --- a/server/statistics/region_stat_informer.go +++ b/server/statistics/region_stat_informer.go @@ -14,7 +14,7 @@ package statistics -import "github.com/tikv/pd/server/core" +import "github.com/tikv/pd/pkg/core" // RegionStatInformer provides access to a shared informer of statistics. type RegionStatInformer interface { diff --git a/server/statistics/store.go b/server/statistics/store.go index 9e66b1906ca4..d8288a9b9cf6 100644 --- a/server/statistics/store.go +++ b/server/statistics/store.go @@ -19,9 +19,9 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/log" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/movingaverage" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/server/statistics/store_collection.go b/server/statistics/store_collection.go index 04138f61c588..2af6d1768328 100644 --- a/server/statistics/store_collection.go +++ b/server/statistics/store_collection.go @@ -19,8 +19,8 @@ import ( "strconv" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) const ( diff --git a/server/statistics/store_collection_test.go b/server/statistics/store_collection_test.go index 7fa5d9e94fc6..63ffc5b52cdf 100644 --- a/server/statistics/store_collection_test.go +++ b/server/statistics/store_collection_test.go @@ -20,8 +20,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" ) func TestStoreStatistics(t *testing.T) { diff --git a/server/statistics/store_hot_peers_infos.go b/server/statistics/store_hot_peers_infos.go index 17ed6f475988..a43170d62fc6 100644 --- a/server/statistics/store_hot_peers_infos.go +++ b/server/statistics/store_hot_peers_infos.go @@ -18,7 +18,7 @@ import ( "fmt" "math" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // StoreHotPeersInfos is used to get human-readable description for hot regions. diff --git a/server/statistics/store_load.go b/server/statistics/store_load.go index cbdac6854016..13c4aa57635d 100644 --- a/server/statistics/store_load.go +++ b/server/statistics/store_load.go @@ -17,7 +17,7 @@ package statistics import ( "math" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) // StoreLoadDetail records store load information. diff --git a/server/statistics/store_test.go b/server/statistics/store_test.go index 89508be41b75..9f5d9a1cc42e 100644 --- a/server/statistics/store_test.go +++ b/server/statistics/store_test.go @@ -21,7 +21,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) func TestFilterUnhealtyStore(t *testing.T) { diff --git a/server/storage/hot_region_storage.go b/server/storage/hot_region_storage.go index a49cb5a95eb9..52fe045fddc2 100644 --- a/server/storage/hot_region_storage.go +++ b/server/storage/hot_region_storage.go @@ -30,11 +30,11 @@ import ( "github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb/iterator" "github.com/syndtr/goleveldb/leveldb/util" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/storage/kv" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "go.uber.org/zap" ) diff --git a/server/storage/hot_region_storage_test.go b/server/storage/hot_region_storage_test.go index ba1f52ba60e4..2de7d66fe1b8 100644 --- a/server/storage/hot_region_storage_test.go +++ b/server/storage/hot_region_storage_test.go @@ -25,7 +25,7 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" ) type MockPackHotRegionInfo struct { diff --git a/server/storage/storage.go b/server/storage/storage.go index 4a4d4c604faa..2327301a9929 100644 --- a/server/storage/storage.go +++ b/server/storage/storage.go @@ -19,11 +19,11 @@ import ( "sync/atomic" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/encryption" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/storage/kv" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "go.etcd.io/etcd/clientv3" ) diff --git a/server/storage/storage_test.go b/server/storage/storage_test.go index 5aa9f0265a05..077af087deca 100644 --- a/server/storage/storage_test.go +++ b/server/storage/storage_test.go @@ -28,8 +28,8 @@ import ( "github.com/pingcap/failpoint" "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/storage/endpoint" - "github.com/tikv/pd/server/core" "go.etcd.io/etcd/clientv3" ) diff --git a/tests/client/client_test.go b/tests/client/client_test.go index dd31aa0c68b9..5b21f3b190f1 100644 --- a/tests/client/client_test.go +++ b/tests/client/client_test.go @@ -33,6 +33,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" pd "github.com/tikv/pd/client" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockid" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/utils/assertutil" @@ -41,7 +42,6 @@ import ( "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/tso" "github.com/tikv/pd/tests" "go.uber.org/goleak" diff --git a/tests/cluster.go b/tests/cluster.go index fb1682fabc4e..fcaef68bf806 100644 --- a/tests/cluster.go +++ b/tests/cluster.go @@ -28,6 +28,7 @@ import ( "github.com/pingcap/log" "github.com/stretchr/testify/require" "github.com/tikv/pd/pkg/autoscaling" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/dashboard" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/id" @@ -38,7 +39,6 @@ import ( "github.com/tikv/pd/server/apiv2" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/join" "github.com/tikv/pd/server/tso" "go.etcd.io/etcd/clientv3" diff --git a/tests/pdctl/helper.go b/tests/pdctl/helper.go index 87e2ecb04f52..2b958a6d41f0 100644 --- a/tests/pdctl/helper.go +++ b/tests/pdctl/helper.go @@ -24,11 +24,11 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/spf13/cobra" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/pkg/versioninfo" "github.com/tikv/pd/server" "github.com/tikv/pd/server/api" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" ) diff --git a/tests/pdctl/hot/hot_test.go b/tests/pdctl/hot/hot_test.go index 2300d4ae3695..378db52641bb 100644 --- a/tests/pdctl/hot/hot_test.go +++ b/tests/pdctl/hot/hot_test.go @@ -25,11 +25,11 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server/api" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/statistics" "github.com/tikv/pd/server/storage" "github.com/tikv/pd/tests" diff --git a/tests/pdctl/operator/operator_test.go b/tests/pdctl/operator/operator_test.go index b84335203816..c53c5a42a0f6 100644 --- a/tests/pdctl/operator/operator_test.go +++ b/tests/pdctl/operator/operator_test.go @@ -23,8 +23,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" "github.com/tikv/pd/tests/pdctl" pdctlCmd "github.com/tikv/pd/tools/pd-ctl/pdctl" diff --git a/tests/pdctl/region/region_test.go b/tests/pdctl/region/region_test.go index 951433bd432f..d56463d728d7 100644 --- a/tests/pdctl/region/region_test.go +++ b/tests/pdctl/region/region_test.go @@ -23,8 +23,8 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/api" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" "github.com/tikv/pd/tests/pdctl" pdctlCmd "github.com/tikv/pd/tools/pd-ctl/pdctl" diff --git a/tests/pdctl/store/store_test.go b/tests/pdctl/store/store_test.go index 590333d4f5fb..8390cd35c543 100644 --- a/tests/pdctl/store/store_test.go +++ b/tests/pdctl/store/store_test.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/server/api" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" "github.com/tikv/pd/server/statistics" "github.com/tikv/pd/tests" "github.com/tikv/pd/tests/pdctl" diff --git a/tests/server/api/api_test.go b/tests/server/api/api_test.go index 2204d88c4ed5..3ac8a7cf7d26 100644 --- a/tests/server/api/api_test.go +++ b/tests/server/api/api_test.go @@ -33,13 +33,13 @@ import ( "github.com/pingcap/log" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/apiutil/serverapi" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/pkg/utils/typeutil" "github.com/tikv/pd/server" "github.com/tikv/pd/server/api" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" "github.com/tikv/pd/tests/pdctl" "go.uber.org/goleak" diff --git a/tests/server/cluster/cluster_test.go b/tests/server/cluster/cluster_test.go index 7b74e3e3f572..3cc2d94aeddd 100644 --- a/tests/server/cluster/cluster_test.go +++ b/tests/server/cluster/cluster_test.go @@ -30,6 +30,8 @@ import ( "github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/kvproto/pkg/replication_modepb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/storelimit" "github.com/tikv/pd/pkg/dashboard" "github.com/tikv/pd/pkg/id" "github.com/tikv/pd/pkg/mock/mockid" @@ -39,8 +41,6 @@ import ( "github.com/tikv/pd/server" "github.com/tikv/pd/server/cluster" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" - "github.com/tikv/pd/server/core/storelimit" syncer "github.com/tikv/pd/server/region_syncer" "github.com/tikv/pd/server/schedule/operator" "github.com/tikv/pd/server/storage" diff --git a/tests/server/cluster/cluster_work_test.go b/tests/server/cluster/cluster_work_test.go index 32ffc3bf05ae..f0f24ca67770 100644 --- a/tests/server/cluster/cluster_work_test.go +++ b/tests/server/cluster/cluster_work_test.go @@ -24,9 +24,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/utils/testutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" ) diff --git a/tests/server/region_syncer/region_syncer_test.go b/tests/server/region_syncer/region_syncer_test.go index a7ccebf9c229..d6451dd6f50f 100644 --- a/tests/server/region_syncer/region_syncer_test.go +++ b/tests/server/region_syncer/region_syncer_test.go @@ -23,10 +23,10 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/mock/mockid" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tests" "go.uber.org/goleak" ) diff --git a/tests/server/storage/hot_region_storage_test.go b/tests/server/storage/hot_region_storage_test.go index 376fc143882d..0bbe16fd7f85 100644 --- a/tests/server/storage/hot_region_storage_test.go +++ b/tests/server/storage/hot_region_storage_test.go @@ -22,9 +22,9 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" "github.com/stretchr/testify/require" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/testutil" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/statistics" "github.com/tikv/pd/server/storage" "github.com/tikv/pd/tests" diff --git a/tools/pd-ctl/pdctl/command/label_command.go b/tools/pd-ctl/pdctl/command/label_command.go index 929b69dadb37..3f01cee5fba0 100644 --- a/tools/pd-ctl/pdctl/command/label_command.go +++ b/tools/pd-ctl/pdctl/command/label_command.go @@ -20,9 +20,9 @@ import ( "net/http" "github.com/spf13/cobra" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/api" "github.com/tikv/pd/server/config" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/statistics" ) diff --git a/tools/pd-simulator/simulator/cases/add_nodes.go b/tools/pd-simulator/simulator/cases/add_nodes.go index 22aa935ab71c..833ead89f53a 100644 --- a/tools/pd-simulator/simulator/cases/add_nodes.go +++ b/tools/pd-simulator/simulator/cases/add_nodes.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/add_nodes_dynamic.go b/tools/pd-simulator/simulator/cases/add_nodes_dynamic.go index 76b6e0c8339d..410d5e984c75 100644 --- a/tools/pd-simulator/simulator/cases/add_nodes_dynamic.go +++ b/tools/pd-simulator/simulator/cases/add_nodes_dynamic.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/balance_leader.go b/tools/pd-simulator/simulator/cases/balance_leader.go index 4de326bfa52b..8f2b87e31800 100644 --- a/tools/pd-simulator/simulator/cases/balance_leader.go +++ b/tools/pd-simulator/simulator/cases/balance_leader.go @@ -17,7 +17,7 @@ package cases import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/balance_region.go b/tools/pd-simulator/simulator/cases/balance_region.go index 15cc545f5558..39f3ef29379c 100644 --- a/tools/pd-simulator/simulator/cases/balance_region.go +++ b/tools/pd-simulator/simulator/cases/balance_region.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/cases.go b/tools/pd-simulator/simulator/cases/cases.go index 35816777e549..96dbdee1afd0 100644 --- a/tools/pd-simulator/simulator/cases/cases.go +++ b/tools/pd-simulator/simulator/cases/cases.go @@ -16,8 +16,8 @@ package cases import ( "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" diff --git a/tools/pd-simulator/simulator/cases/delete_nodes.go b/tools/pd-simulator/simulator/cases/delete_nodes.go index bc2b7ba85dd1..33f7ada14a05 100644 --- a/tools/pd-simulator/simulator/cases/delete_nodes.go +++ b/tools/pd-simulator/simulator/cases/delete_nodes.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/diagnose_label_isolation.go b/tools/pd-simulator/simulator/cases/diagnose_label_isolation.go index e237fb27d097..bd056bdf9c12 100644 --- a/tools/pd-simulator/simulator/cases/diagnose_label_isolation.go +++ b/tools/pd-simulator/simulator/cases/diagnose_label_isolation.go @@ -20,7 +20,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/diagnose_rule.go b/tools/pd-simulator/simulator/cases/diagnose_rule.go index 63831b56fd7c..46bca6ad4927 100644 --- a/tools/pd-simulator/simulator/cases/diagnose_rule.go +++ b/tools/pd-simulator/simulator/cases/diagnose_rule.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" diff --git a/tools/pd-simulator/simulator/cases/hot_read.go b/tools/pd-simulator/simulator/cases/hot_read.go index 659aaaded4d0..9df4f8796e85 100644 --- a/tools/pd-simulator/simulator/cases/hot_read.go +++ b/tools/pd-simulator/simulator/cases/hot_read.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/hot_write.go b/tools/pd-simulator/simulator/cases/hot_write.go index 645f647e26c6..8efe32c56574 100644 --- a/tools/pd-simulator/simulator/cases/hot_write.go +++ b/tools/pd-simulator/simulator/cases/hot_write.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/import_data.go b/tools/pd-simulator/simulator/cases/import_data.go index 7b02e1e01230..7a8ffd6a1d89 100644 --- a/tools/pd-simulator/simulator/cases/import_data.go +++ b/tools/pd-simulator/simulator/cases/import_data.go @@ -25,7 +25,7 @@ import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/log" "github.com/tikv/pd/pkg/codec" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/makeup_down_replica.go b/tools/pd-simulator/simulator/cases/makeup_down_replica.go index 97796755e4db..57eb2dd1f53d 100644 --- a/tools/pd-simulator/simulator/cases/makeup_down_replica.go +++ b/tools/pd-simulator/simulator/cases/makeup_down_replica.go @@ -17,7 +17,7 @@ package cases import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/region_merge.go b/tools/pd-simulator/simulator/cases/region_merge.go index 09790cf25f9e..501803d439ea 100644 --- a/tools/pd-simulator/simulator/cases/region_merge.go +++ b/tools/pd-simulator/simulator/cases/region_merge.go @@ -19,7 +19,7 @@ import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/cases/region_split.go b/tools/pd-simulator/simulator/cases/region_split.go index c365a4a73c53..6a69386cb6bd 100644 --- a/tools/pd-simulator/simulator/cases/region_split.go +++ b/tools/pd-simulator/simulator/cases/region_split.go @@ -17,7 +17,7 @@ package cases import ( "github.com/docker/go-units" "github.com/pingcap/kvproto/pkg/metapb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/client.go b/tools/pd-simulator/simulator/client.go index 932c100df352..e71ead920eb1 100644 --- a/tools/pd-simulator/simulator/client.go +++ b/tools/pd-simulator/simulator/client.go @@ -27,8 +27,8 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/server/schedule/placement" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/drive.go b/tools/pd-simulator/simulator/drive.go index c6a4ffee431c..c7f64324c19d 100644 --- a/tools/pd-simulator/simulator/drive.go +++ b/tools/pd-simulator/simulator/drive.go @@ -23,8 +23,8 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/typeutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tools/pd-simulator/simulator/cases" "github.com/tikv/pd/tools/pd-simulator/simulator/info" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" diff --git a/tools/pd-simulator/simulator/event.go b/tools/pd-simulator/simulator/event.go index 3433a57fa649..04ad10a0db84 100644 --- a/tools/pd-simulator/simulator/event.go +++ b/tools/pd-simulator/simulator/event.go @@ -17,7 +17,7 @@ package simulator import ( "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-simulator/simulator/cases" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/raft.go b/tools/pd-simulator/simulator/raft.go index 2dffab12af60..617edd7f84c9 100644 --- a/tools/pd-simulator/simulator/raft.go +++ b/tools/pd-simulator/simulator/raft.go @@ -19,8 +19,8 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/syncutil" - "github.com/tikv/pd/server/core" "github.com/tikv/pd/tools/pd-simulator/simulator/cases" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/pd-simulator/simulator/task.go b/tools/pd-simulator/simulator/task.go index 379707f4b3bf..e7517e7e832d 100644 --- a/tools/pd-simulator/simulator/task.go +++ b/tools/pd-simulator/simulator/task.go @@ -24,7 +24,7 @@ import ( "github.com/pingcap/kvproto/pkg/eraftpb" "github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/pdpb" - "github.com/tikv/pd/server/core" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/tools/pd-analysis/analysis" "github.com/tikv/pd/tools/pd-simulator/simulator/simutil" "go.uber.org/zap" diff --git a/tools/regions-dump/main.go b/tools/regions-dump/main.go index 7d57d0cea29d..dddbcbba8546 100644 --- a/tools/regions-dump/main.go +++ b/tools/regions-dump/main.go @@ -27,8 +27,8 @@ import ( "github.com/pingcap/errors" "github.com/pingcap/kvproto/pkg/metapb" + "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/utils/etcdutil" - "github.com/tikv/pd/server/core" "go.etcd.io/etcd/clientv3" "go.etcd.io/etcd/pkg/transport" )