From 2a7be6782d18dc224254010f2d4400d1d6338b9c Mon Sep 17 00:00:00 2001 From: Ryan Leung Date: Thu, 10 Aug 2023 15:50:24 +0800 Subject: [PATCH] resolve the conflicts Signed-off-by: Ryan Leung --- pkg/mcs/scheduling/server/cluster.go | 15 +++---------- pkg/mcs/scheduling/server/config/config.go | 25 ++++++++++++++++++++++ pkg/mock/mockcluster/mockcluster.go | 10 ++++----- tests/integrations/client/client_test.go | 7 +++--- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/pkg/mcs/scheduling/server/cluster.go b/pkg/mcs/scheduling/server/cluster.go index 49f7fb4379fc..f58fba2ed0b3 100644 --- a/pkg/mcs/scheduling/server/cluster.go +++ b/pkg/mcs/scheduling/server/cluster.go @@ -103,15 +103,6 @@ func (c *Cluster) BucketsStats(degree int, regionIDs ...uint64) map[uint64][]*bu return c.hotStat.BucketsStats(degree, regionIDs...) } -<<<<<<< HEAD -// TODO: implement the following methods -======= -// GetPersistOptions returns the persist options. -func (c *Cluster) GetPersistOptions() sc.ConfProvider { - return c.persistConfig -} ->>>>>>> remove some store config - // GetStorage returns the storage. func (c *Cluster) GetStorage() storage.Storage { return c.storage @@ -123,6 +114,9 @@ func (c *Cluster) GetCheckerConfig() sc.CheckerConfigProvider { return c.persist // GetSchedulerConfig returns the scheduler config. func (c *Cluster) GetSchedulerConfig() sc.SchedulerConfigProvider { return c.persistConfig } +// GetStoreConfig returns the store config. +func (c *Cluster) GetStoreConfig() sc.StoreConfigProvider { return c.persistConfig } + // TODO: implement the following methods // UpdateRegionsLabelLevelStats updates the region label level stats. @@ -130,6 +124,3 @@ func (c *Cluster) UpdateRegionsLabelLevelStats(regions []*core.RegionInfo) {} // AllocID allocates a new ID. func (c *Cluster) AllocID() (uint64, error) { return 0, nil } - -// GetStoreConfig returns the store config. -func (c *Cluster) GetStoreConfig() sc.StoreConfigProvider { return nil } diff --git a/pkg/mcs/scheduling/server/config/config.go b/pkg/mcs/scheduling/server/config/config.go index 7b396afe35b5..7839ec7f2749 100644 --- a/pkg/mcs/scheduling/server/config/config.go +++ b/pkg/mcs/scheduling/server/config/config.go @@ -564,6 +564,31 @@ func (o *PersistConfig) SetHaltScheduling(halt bool, source string) { o.SetScheduleConfig(v) } +// CheckRegionKeys return error if the smallest region's keys is less than mergeKeys +func (o *PersistConfig) CheckRegionKeys(keys, mergeKeys uint64) error { + return o.GetStoreConfig().CheckRegionKeys(keys, mergeKeys) +} + +// CheckRegionSize return error if the smallest region's size is less than mergeSize +func (o *PersistConfig) CheckRegionSize(size, mergeSize uint64) error { + return o.GetStoreConfig().CheckRegionSize(size, mergeSize) +} + +// GetRegionMaxSize returns the max region size in MB +func (o *PersistConfig) GetRegionMaxSize() uint64 { + return o.GetStoreConfig().GetRegionMaxSize() +} + +// GetRegionMaxKeys returns the region split keys +func (o *PersistConfig) GetRegionMaxKeys() uint64 { + return o.GetStoreConfig().GetRegionMaxKeys() +} + +// IsEnableRegionBucket return true if the region bucket is enabled. +func (o *PersistConfig) IsEnableRegionBucket() bool { + return o.GetStoreConfig().IsEnableRegionBucket() +} + // TODO: implement the following methods // AddSchedulerCfg adds the scheduler configurations. diff --git a/pkg/mock/mockcluster/mockcluster.go b/pkg/mock/mockcluster/mockcluster.go index 8baa852117e8..ce392d26a391 100644 --- a/pkg/mock/mockcluster/mockcluster.go +++ b/pkg/mock/mockcluster/mockcluster.go @@ -84,12 +84,12 @@ func NewCluster(ctx context.Context, opts *config.PersistOptions) *Cluster { // GetStoreConfig returns the store config. func (mc *Cluster) GetStoreConfig() sc.StoreConfigProvider { - return mc + return mc.PersistOptions.GetStoreConfig() } // SetRegionBucketEnabled sets the region bucket enabled. func (mc *Cluster) SetRegionBucketEnabled(enabled bool) { - cfg, ok := mc.GetStoreConfig().(*config.StoreConfig) + cfg, ok := mc.GetStoreConfig().(*sc.StoreConfig) if !ok || cfg == nil { return } @@ -99,17 +99,17 @@ func (mc *Cluster) SetRegionBucketEnabled(enabled bool) { // GetCheckerConfig returns the checker config. func (mc *Cluster) GetCheckerConfig() sc.CheckerConfigProvider { - return mc + return mc.PersistOptions } // GetSchedulerConfig returns the scheduler config. func (mc *Cluster) GetSchedulerConfig() sc.SchedulerConfigProvider { - return mc + return mc.PersistOptions } // GetSharedConfig returns the shared config. func (mc *Cluster) GetSharedConfig() sc.SharedConfigProvider { - return mc + return mc.PersistOptions } // GetStorage returns the storage. diff --git a/tests/integrations/client/client_test.go b/tests/integrations/client/client_test.go index 712952cc2fcb..99b74078ad9b 100644 --- a/tests/integrations/client/client_test.go +++ b/tests/integrations/client/client_test.go @@ -39,6 +39,7 @@ import ( "github.com/tikv/pd/pkg/core" "github.com/tikv/pd/pkg/errs" "github.com/tikv/pd/pkg/mock/mockid" + sc "github.com/tikv/pd/pkg/schedule/config" "github.com/tikv/pd/pkg/storage/endpoint" "github.com/tikv/pd/pkg/tso" "github.com/tikv/pd/pkg/utils/assertutil" @@ -804,7 +805,7 @@ func (suite *clientTestSuite) SetupSuite() { })) suite.grpcSvr.GetRaftCluster().GetBasicCluster().PutStore(newStore) } - cluster.GetStoreConfig().(*config.StoreConfig).SetRegionBucketEnabled(true) + cluster.GetStoreConfig().(*sc.StoreConfig).SetRegionBucketEnabled(true) } func (suite *clientTestSuite) TearDownSuite() { @@ -893,7 +894,7 @@ func (suite *clientTestSuite) TestGetRegion() { } return r.Buckets != nil }) - suite.srv.GetRaftCluster().GetStoreConfig().(*config.StoreConfig).SetRegionBucketEnabled(false) + suite.srv.GetRaftCluster().GetStoreConfig().(*sc.StoreConfig).SetRegionBucketEnabled(false) testutil.Eventually(re, func() bool { r, err := suite.client.GetRegion(context.Background(), []byte("a"), pd.WithBuckets()) @@ -903,7 +904,7 @@ func (suite *clientTestSuite) TestGetRegion() { } return r.Buckets == nil }) - suite.srv.GetRaftCluster().GetStoreConfig().(*config.StoreConfig).SetRegionBucketEnabled(true) + suite.srv.GetRaftCluster().GetStoreConfig().(*sc.StoreConfig).SetRegionBucketEnabled(true) suite.NoError(failpoint.Enable("github.com/tikv/pd/server/grpcClientClosed", `return(true)`)) suite.NoError(failpoint.Enable("github.com/tikv/pd/server/useForwardRequest", `return(true)`))