Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schedule: impl balance range scheduler #9005

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions pkg/core/basic_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package core

import (
"bytes"
"encoding/json"

"github.com/tikv/pd/pkg/core/constant"
)
Expand Down Expand Up @@ -156,6 +157,15 @@ type KeyRange struct {
EndKey []byte `json:"end-key"`
}

// MarshalJSON marshals to json.
func (kr KeyRange) MarshalJSON() ([]byte, error) {
m := map[string]string{
"start-key": HexRegionKeyStr(kr.StartKey),
"end-key": HexRegionKeyStr(kr.EndKey),
}
return json.Marshal(m)
}

// NewKeyRange create a KeyRange with the given start key and end key.
func NewKeyRange(startKey, endKey string) KeyRange {
return KeyRange{
Expand All @@ -169,6 +179,17 @@ type KeyRanges struct {
krs []*KeyRange
}

// NewKeyRanges creates a KeyRanges.
func NewKeyRanges(ranges []KeyRange) *KeyRanges {
krs := make([]*KeyRange, 0, len(ranges))
for _, kr := range ranges {
krs = append(krs, &kr)
}
return &KeyRanges{
krs,
}
}

// NewKeyRangesWithSize creates a KeyRanges with the hint size.
func NewKeyRangesWithSize(size int) *KeyRanges {
return &KeyRanges{
Expand Down
5 changes: 4 additions & 1 deletion pkg/core/constant/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
RegionKind
// WitnessKind indicates the witness kind resource
WitnessKind

// ResourceKindLen represents the ResourceKind count
ResourceKindLen
)
Expand All @@ -79,6 +78,10 @@
return "region"
case WitnessKind:
return "witness"
case LearnerKind:

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / tso-function-test

undefined: LearnerKind

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (3, Unit Test(3))

undefined: LearnerKind

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (2, Unit Test(2))

undefined: LearnerKind

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (4, Tests(1))

undefined: LearnerKind

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (1, Unit Test(1))

undefined: LearnerKind

Check failure on line 81 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (5, Tests(2))

undefined: LearnerKind
return `learner`
case unKnownKind:

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / tso-function-test

undefined: unKnownKind

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (3, Unit Test(3))

undefined: unKnownKind

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (2, Unit Test(2))

undefined: unKnownKind

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (4, Tests(1))

undefined: unKnownKind

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (1, Unit Test(1))

undefined: unKnownKind

Check failure on line 83 in pkg/core/constant/kind.go

View workflow job for this annotation

GitHub Actions / chunks (5, Tests(2))

undefined: unKnownKind
return "unknown"
default:
return "unknown"
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/mcs/scheduling/server/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ func (c *Cluster) updateScheduler() {
)
// Create the newly added schedulers.
for _, scheduler := range latestSchedulersConfig {
schedulerType := types.ConvertOldStrToType[scheduler.Type]
schedulerType, ok := types.ConvertOldStrToType[scheduler.Type]
if !ok {
log.Error("scheduler not found", zap.String("type", scheduler.Type))
continue
}
s, err := schedulers.CreateScheduler(
schedulerType,
c.coordinator.GetOperatorController(),
Expand Down
2 changes: 2 additions & 0 deletions pkg/schedule/filter/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ var (
allSpecialEngines = []string{core.EngineTiFlash}
// NotSpecialEngines is used to filter the special engine.
NotSpecialEngines = placement.LabelConstraint{Key: core.EngineKey, Op: placement.NotIn, Values: allSpecialEngines}
// TiFlashEngineConstraint is used to filter the TiFlash engine.
TiFlashEngineConstraint = placement.LabelConstraint{Key: core.EngineKey, Op: placement.In, Values: allSpecialEngines}
)

type isolationFilter struct {
Expand Down
Loading
Loading