diff --git a/pkg/mock/mockcluster/mockcluster.go b/pkg/mock/mockcluster/mockcluster.go index d2d51b6e1f5f..6ff059d5fae4 100644 --- a/pkg/mock/mockcluster/mockcluster.go +++ b/pkg/mock/mockcluster/mockcluster.go @@ -45,8 +45,6 @@ const ( defaultRegionSize = 96 * units.MiB // 96MiB ) -var _ statistics.StoreStatInformer = &Cluster{} - // Cluster is used to mock a cluster for test purpose. type Cluster struct { *core.BasicCluster diff --git a/pkg/movingaverage/exponential_moving_average.go b/pkg/movingaverage/exponential_moving_average.go index 4e1d1f595658..6c1904a97308 100644 --- a/pkg/movingaverage/exponential_moving_average.go +++ b/pkg/movingaverage/exponential_moving_average.go @@ -31,8 +31,6 @@ type EMA struct { instantaneous float64 } -var _ MovingAvg = &EMA{} - // NewEMA returns an EMA. func NewEMA(decays ...float64) *EMA { decay := defaultDecay diff --git a/pkg/movingaverage/hull_moving_average.go b/pkg/movingaverage/hull_moving_average.go index 9bb2eda3ea6c..14b550d43f5a 100644 --- a/pkg/movingaverage/hull_moving_average.go +++ b/pkg/movingaverage/hull_moving_average.go @@ -26,8 +26,6 @@ type HMA struct { wma []*WMA } -var _ MovingAvg = &HMA{} - // NewHMA returns a WMA. func NewHMA(sizes ...float64) *HMA { size := defaultHMASize diff --git a/pkg/movingaverage/max_filter.go b/pkg/movingaverage/max_filter.go index 59f9993e7a2c..70bd45f98de5 100644 --- a/pkg/movingaverage/max_filter.go +++ b/pkg/movingaverage/max_filter.go @@ -16,8 +16,6 @@ package movingaverage import "github.com/elliotchance/pie/v2" -var _ MovingAvg = &MaxFilter{} - // MaxFilter works as a maximum filter with specified window size. // There are at most `size` data points for calculating. type MaxFilter struct { diff --git a/pkg/movingaverage/moving_average_test.go b/pkg/movingaverage/moving_average_test.go index 84c235db4846..49c20637c209 100644 --- a/pkg/movingaverage/moving_average_test.go +++ b/pkg/movingaverage/moving_average_test.go @@ -80,7 +80,6 @@ func TestMedianFilter(t *testing.T) { mf := NewMedianFilter(5) re.Equal(empty, mf.Get()) - re.Equal([]float64{}, mf.GetAll()) checkReset(re, mf, empty) checkAdd(re, mf, data, expected) diff --git a/pkg/movingaverage/weight_moving_average.go b/pkg/movingaverage/weight_moving_average.go index ce682ec18f35..f8a72b493ee9 100644 --- a/pkg/movingaverage/weight_moving_average.go +++ b/pkg/movingaverage/weight_moving_average.go @@ -16,8 +16,6 @@ package movingaverage const defaultWMASize = 10 -var _ MovingAvg = &WMA{} - // WMA works as a weight with specified window size. // There are at most `size` data points for calculating. // References:https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average diff --git a/pkg/statistics/collector.go b/pkg/statistics/collector.go index 0e93f556fc58..f4785103c890 100644 --- a/pkg/statistics/collector.go +++ b/pkg/statistics/collector.go @@ -29,9 +29,6 @@ type storeCollector interface { GetLoads(storeLoads, peerLoadSum []float64, rwTy RWType, kind constant.ResourceKind) (loads []float64) } -var _ storeCollector = tikvCollector{} -var _ storeCollector = tiflashCollector{} - type tikvCollector struct{} func newTikvCollector() storeCollector { diff --git a/pkg/statistics/store.go b/pkg/statistics/store.go index 329a1abb4869..d8288a9b9cf6 100644 --- a/pkg/statistics/store.go +++ b/pkg/statistics/store.go @@ -34,8 +34,6 @@ const ( RegionsStatsRollingWindowsSize = 9 ) -var _ StoreStatInformer = &StoresStats{} - // StoresStats is a cache hold hot regions. type StoresStats struct { syncutil.RWMutex diff --git a/pkg/statistics/store_hot_peers_infos.go b/pkg/statistics/store_hot_peers_infos.go index 683977773ab0..ad0f33c9fbe1 100644 --- a/pkg/statistics/store_hot_peers_infos.go +++ b/pkg/statistics/store_hot_peers_infos.go @@ -185,8 +185,9 @@ func summaryStoresLoadByEngine( } loads := collector.GetLoads(storeLoads, peerLoadSum, rwTy, kind) + var historyLoads [][]float64 if storesHistoryLoads != nil { - historyLoads := storesHistoryLoads.Get(id, rwTy, kind) + historyLoads = storesHistoryLoads.Get(id, rwTy, kind) for i, loads := range historyLoads { if allStoreHistoryLoadSum[i] == nil || len(allStoreHistoryLoadSum[i]) < len(loads) { allStoreHistoryLoadSum[i] = make([]float64, len(loads)) diff --git a/pkg/statistics/store_load.go b/pkg/statistics/store_load.go index 616b39948136..8553f26cde1c 100644 --- a/pkg/statistics/store_load.go +++ b/pkg/statistics/store_load.go @@ -15,11 +15,11 @@ package statistics import ( - "github.com/tikv/pd/pkg/core/constant" "math" "time" "github.com/tikv/pd/pkg/core" + "github.com/tikv/pd/pkg/core/constant" ) // StoreLoadDetail records store load information. @@ -245,10 +245,10 @@ func MaxLoad(a, b *StoreLoad) *StoreLoad { } var ( - // historyLoadInterval is the duration for saving history load. - historyLoadInterval = 30 * time.Second - // HistorySampleDuration is the sampling interval for history load - HistorySampleDuration = 5 * time.Minute + // historySampleInterval is the sampling interval for history load. + historySampleInterval = 30 * time.Second + // historySampleDuration is the duration for saving history load. + historySampleDuration = 5 * time.Minute ) type StoreHistoryLoads struct { @@ -272,8 +272,8 @@ func (s *StoreHistoryLoads) Add(storeID uint64, rwTp RWType, kind constant.Resou load, ok := s.loads[rwTp][kind][storeID] if !ok { size := 10 - if historyLoadInterval != 0 { - size = int(HistorySampleDuration / historyLoadInterval) + if historySampleInterval != 0 { + size = int(historySampleDuration / historySampleInterval) } load = newStoreHistoryLoad(size, s.dim) s.loads[rwTp][kind][storeID] = load @@ -305,7 +305,7 @@ func newStoreHistoryLoad(size int, dim int) *storeHistoryLoad { } func (s *storeHistoryLoad) add(loads []float64) { - if time.Now().Sub(s.update) < historyLoadInterval { + if time.Now().Sub(s.update) < historySampleInterval { return } if s.count == 0 { diff --git a/pkg/statistics/store_load_test.go b/pkg/statistics/store_load_test.go index ff69d99447cd..ea4246edec64 100644 --- a/pkg/statistics/store_load_test.go +++ b/pkg/statistics/store_load_test.go @@ -23,7 +23,7 @@ import ( func TestHistoryLoads(t *testing.T) { re := require.New(t) - historyLoadInterval = 0 + historySampleInterval = 0 historyLoads := NewStoreHistoryLoads(DimLen) loads := []float64{1.0, 2.0, 3.0} rwTp := Read diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index 8fa3f5bfea22..c4b9db33ea5f 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -109,8 +109,6 @@ type Server interface { ReplicateFileToMember(ctx context.Context, member *pdpb.Member, name string, data []byte) error } -var _ statistics.StoreStatInformer = &RaftCluster{} - // RaftCluster is used for cluster config management. // Raft cluster key format: // cluster 1 -> /1/raft, value is metapb.Cluster diff --git a/server/handler.go b/server/handler.go index c752403f3265..35cec65527f9 100644 --- a/server/handler.go +++ b/server/handler.go @@ -78,8 +78,6 @@ var ( schedulerConfigPrefix = "pd/api/v1/scheduler-config" ) -var _ statistics.StoreStatInformer = &Handler{} - // Handler is a helper to export methods to handle API/RPC requests. type Handler struct { s *Server