Skip to content

Commit

Permalink
resolv conflict
Browse files Browse the repository at this point in the history
Signed-off-by: bufferflies <1045931706@qq.com>
  • Loading branch information
bufferflies committed Apr 12, 2023
2 parents 65c5f24 + bd1a546 commit 49231b9
Show file tree
Hide file tree
Showing 13 changed files with 11 additions and 30 deletions.
2 changes: 0 additions & 2 deletions pkg/mock/mockcluster/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions pkg/movingaverage/exponential_moving_average.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ type EMA struct {
instantaneous float64
}

var _ MovingAvg = &EMA{}

// NewEMA returns an EMA.
func NewEMA(decays ...float64) *EMA {
decay := defaultDecay
Expand Down
2 changes: 0 additions & 2 deletions pkg/movingaverage/hull_moving_average.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ type HMA struct {
wma []*WMA
}

var _ MovingAvg = &HMA{}

// NewHMA returns a WMA.
func NewHMA(sizes ...float64) *HMA {
size := defaultHMASize
Expand Down
2 changes: 0 additions & 2 deletions pkg/movingaverage/max_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion pkg/movingaverage/moving_average_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions pkg/movingaverage/weight_moving_average.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions pkg/statistics/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/statistics/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ const (
RegionsStatsRollingWindowsSize = 9
)

var _ StoreStatInformer = &StoresStats{}

// StoresStats is a cache hold hot regions.
type StoresStats struct {
syncutil.RWMutex
Expand Down
3 changes: 2 additions & 1 deletion pkg/statistics/store_hot_peers_infos.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions pkg/statistics/store_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/statistics/store_load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions server/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 49231b9

Please sign in to comment.