config

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// DefaultContainerLimit is the default container limit of add peer and remove peer.
	DefaultContainerLimit = ContainerLimit{AddPeer: 15, RemovePeer: 15}
)
View Source
var DefaultSchedulers = SchedulerConfigs{
	{Type: "balance-resource"},
	{Type: "balance-leader"},
}

DefaultSchedulers are the schedulers be created by default. If these schedulers are not in the persistent configuration, they will be created automatically when reloading.

Functions

func IsDefaultScheduler

func IsDefaultScheduler(typ string) bool

IsDefaultScheduler checks whether the scheduler is enable by default.

func IsSchedulerRegistered

func IsSchedulerRegistered(name string) bool

IsSchedulerRegistered checks if the named scheduler type is registered.

func IsSupportedTTLConfig

func IsSupportedTTLConfig(key string) bool

IsSupportedTTLConfig checks whether a key is a supported config item with ttl

func RegisterScheduler

func RegisterScheduler(typ string)

RegisterScheduler registers the scheduler type.

func ValidateLabels

func ValidateLabels(labels []metapb.Pair) error

ValidateLabels checks the legality of the labels.

func ValidateURLWithScheme

func ValidateURLWithScheme(rawURL string) error

ValidateURLWithScheme checks the format of the URL.

Types

type Config

type Config struct {
	Name             string            `toml:"name" json:"name"`
	DataDir          string            `toml:"data-dir"`
	RPCAddr          string            `toml:"rpc-addr"`
	AdvertiseRPCAddr string            `toml:"rpc-advertise-addr"`
	RPCTimeout       typeutil.Duration `toml:"rpc-timeout"`

	// etcd configuration
	StorageNode  bool            `toml:"storage-node"`
	ExternalEtcd []string        `toml:"external-etcd"`
	EmbedEtcd    EmbedEtcdConfig `toml:"embed-etcd"`

	// LeaderLease time, if leader doesn't update its TTL
	// in etcd after lease time, etcd will expire the leader key
	// and other servers can campaign the leader again.
	// Etcd only supports seconds TTL, so here is second too.
	LeaderLease int64 `toml:"lease" json:"lease"`

	Schedule      ScheduleConfig      `toml:"schedule" json:"schedule"`
	Replication   ReplicationConfig   `toml:"replication" json:"replication"`
	LabelProperty LabelPropertyConfig `toml:"label-property" json:"label-property"`

	Handler                         metadata.RoleChangeHandler                                                      `toml:"-" json:"-"`
	Adapter                         metadata.Adapter                                                                `toml:"-" json:"-"`
	ResourceStateChangedHandler     func(res metadata.Resource, from metapb.ResourceState, to metapb.ResourceState) `toml:"-" json:"-"`
	ContainerHeartbeatDataProcessor ContainerHeartbeatDataProcessor                                                 `toml:"-" json:"-"`

	// TODO(fagongzi): the following test-related configurations are moved to a separate struct
	// Only test can change them.
	DisableStrictReconfigCheck bool `toml:"-" json:"-"`
	// DisableResponse skip all client request
	DisableResponse bool `toml:"-" json:"-"`
	// EnableResponseNotLeader return not leader error for all client request
	EnableResponseNotLeader bool      `toml:"-" json:"-"`
	TestCtx                 *sync.Map `toml:"-" json:"-"`
	// contains filtered or unexported fields
}

Config the prophet configuration

func NewConfig

func NewConfig() *Config

NewConfig creates a new config.

func NewConfigWithFile

func NewConfigWithFile(file string) (*Config, error)

NewConfigWithFile new config with config file

func (*Config) Adjust

func (c *Config) Adjust(meta *toml.MetaData, reloading bool) error

Adjust adjust configuration

func (*Config) GenEmbedEtcdConfig

func (c *Config) GenEmbedEtcdConfig(logger *zap.Logger) (*embed.Config, error)

GenEmbedEtcdConfig gen embed etcd config

func (*Config) GetJobProcessor

func (c *Config) GetJobProcessor(jobType metapb.JobType) JobProcessor

GetJobProcessor returns the job handler

func (*Config) RegisterJobProcessor

func (c *Config) RegisterJobProcessor(jobType metapb.JobType, processor JobProcessor)

RegisterJobProcessor register job processor

func (*Config) Validate

func (c *Config) Validate() error

Validate is used to validate if some configurations are right.

type ContainerHeartbeatDataProcessor

type ContainerHeartbeatDataProcessor interface {
	// Start init all customize data if the current node became the prophet leader
	Start(storage.Storage) error
	// Stop clear all customize data at current node, and other node became leader and will call `Start`
	Stop(storage.Storage) error
	// HandleHeartbeatReq handle the data from store heartbeat at the prophet leader node
	HandleHeartbeatReq(id uint64, data []byte, store storage.Storage) (responseData []byte, err error)
}

ContainerHeartbeatDataProcessor process store heartbeat data, collect, store and process customize data

type ContainerLabel

type ContainerLabel struct {
	Key   string `toml:"key" json:"key"`
	Value string `toml:"value" json:"value"`
}

ContainerLabel is the config item of LabelPropertyConfig.

type ContainerLimit

type ContainerLimit struct {

	// AddPeer is the default rate of adding peers for container limit (per minute).
	AddPeer float64
	// RemovePeer is the default rate of removing peers for container limit (per minute).
	RemovePeer float64
	// contains filtered or unexported fields
}

ContainerLimit is the default limit of adding peer and removing peer when putting containers.

func (*ContainerLimit) GetDefaultContainerLimit

func (sl *ContainerLimit) GetDefaultContainerLimit(typ limit.Type) float64

GetDefaultContainerLimit gets the default container limit for a given type.

func (*ContainerLimit) SetDefaultContainerLimit

func (sl *ContainerLimit) SetDefaultContainerLimit(typ limit.Type, ratePerMin float64)

SetDefaultContainerLimit sets the default container limit for a given type.

type ContainerLimitConfig

type ContainerLimitConfig struct {
	AddPeer    float64 `toml:"add-peer" json:"add-peer"`
	RemovePeer float64 `toml:"remove-peer" json:"remove-peer"`
}

ContainerLimitConfig is a config about scheduling rate limit of different types for a container.

type EmbedEtcdConfig

type EmbedEtcdConfig struct {
	Join                string `toml:"join"`
	ClientUrls          string `toml:"client-urls"`
	PeerUrls            string `toml:"peer-urls"`
	AdvertiseClientUrls string `toml:"advertise-client-urls"`
	AdvertisePeerUrls   string `toml:"advertise-peer-urls"`
	InitialCluster      string `toml:"initial-cluster"`
	InitialClusterState string `toml:"initial-cluster-state"`
	// TickInterval is the interval for etcd Raft tick.
	TickInterval typeutil.Duration `toml:"tick-interval"`
	// ElectionInterval is the interval for etcd Raft election.
	ElectionInterval typeutil.Duration `toml:"election-interval"`
	// Prevote is true to enable Raft Pre-Vote.
	// If enabled, Raft runs an additional election phase
	// to check whether it would get enough votes to win
	// an election, thus minimizing disruptions.
	PreVote bool `toml:"enable-prevote"`
	// AutoCompactionMode is either 'periodic' or 'revision'. The default value is 'periodic'.
	AutoCompactionMode string `toml:"auto-compaction-mode"`
	// AutoCompactionRetention is either duration string with time unit
	// (e.g. '5m' for 5-minute), or revision unit (e.g. '5000').
	// If no time unit is provided and compaction mode is 'periodic',
	// the unit defaults to hour. For example, '5' translates into 5-hour.
	// The default retention is 1 hour.
	// Before etcd v3.3.x, the type of retention is int. We add 'v2' suffix to make it backward compatible.
	AutoCompactionRetention string `toml:"auto-compaction-retention"`
	// QuotaBackendBytes Raise alarms when backend size exceeds the given quota. 0 means use the default quota.
	// the default size is 2GB, the maximum is 8GB.
	QuotaBackendBytes typeutil.ByteSize `toml:"quota-backend-bytes" json:"quota-backend-bytes"`
}

EmbedEtcdConfig embed etcd config

type JobProcessor

type JobProcessor interface {
	// Start create the job
	Start(metapb.Job, storage.JobStorage, ResourcesAware)
	// Stop stop the job, the job will restart at other node
	Stop(metapb.Job, storage.JobStorage, ResourcesAware)
	// Remove remove job, the job will never start again
	Remove(metapb.Job, storage.JobStorage, ResourcesAware)
	// Execute execute the data on job and returns the result
	Execute([]byte, storage.JobStorage, ResourcesAware) ([]byte, error)
}

JobProcessor job processor

type LabelPropertyConfig

type LabelPropertyConfig map[string][]ContainerLabel

LabelPropertyConfig is the config section to set properties to container labels.

func (LabelPropertyConfig) Clone

Clone returns a cloned label property configuration.

type PersistOptions

type PersistOptions struct {
	// contains filtered or unexported fields
}

PersistOptions wraps all configurations that need to persist to storage and allows to access them safely.

func NewPersistOptions

func NewPersistOptions(cfg *Config, logger *zap.Logger) *PersistOptions

NewPersistOptions creates a new PersistOptions instance.

func NewTestOptions

func NewTestOptions() *PersistOptions

NewTestOptions creates default options for testing.

func (*PersistOptions) AddSchedulerCfg

func (o *PersistOptions) AddSchedulerCfg(tp string, args []string)

AddSchedulerCfg adds the scheduler configurations.

func (*PersistOptions) CASClusterVersion

func (o *PersistOptions) CASClusterVersion(old, new *semver.Version) bool

CASClusterVersion sets the cluster version.

func (*PersistOptions) CheckLabelProperty

func (o *PersistOptions) CheckLabelProperty(typ string, labels []metapb.Pair) bool

CheckLabelProperty checks the label property.

func (*PersistOptions) DeleteLabelProperty

func (o *PersistOptions) DeleteLabelProperty(typ, labelKey, labelValue string)

DeleteLabelProperty deletes the label property.

func (*PersistOptions) GetAllContainersLimit

func (o *PersistOptions) GetAllContainersLimit() map[uint64]ContainerLimitConfig

GetAllContainersLimit returns the limit of all containers.

func (*PersistOptions) GetClusterVersion

func (o *PersistOptions) GetClusterVersion() *semver.Version

GetClusterVersion returns the cluster version.

func (*PersistOptions) GetContainerLimit

func (o *PersistOptions) GetContainerLimit(containerID uint64) (returnSC ContainerLimitConfig)

GetContainerLimit returns the limit of a container.

func (*PersistOptions) GetContainerLimitByType

func (o *PersistOptions) GetContainerLimitByType(containerID uint64, typ limit.Type) (returned float64)

GetContainerLimitByType returns the limit of a container with a given type.

func (*PersistOptions) GetContainerLimitMode

func (o *PersistOptions) GetContainerLimitMode() string

GetContainerLimitMode returns the limit mode of container.

func (*PersistOptions) GetHighSpaceRatio

func (o *PersistOptions) GetHighSpaceRatio() float64

GetHighSpaceRatio returns the high space ratio.

func (*PersistOptions) GetHotResourceCacheHitsThreshold

func (o *PersistOptions) GetHotResourceCacheHitsThreshold() int

GetHotResourceCacheHitsThreshold is a threshold to decide if a resource is hot.

func (*PersistOptions) GetHotResourceScheduleLimit

func (o *PersistOptions) GetHotResourceScheduleLimit() uint64

GetHotResourceScheduleLimit returns the limit for hot resource schedule.

func (*PersistOptions) GetIsolationLevel

func (o *PersistOptions) GetIsolationLevel() string

GetIsolationLevel returns the isolation label for each resource.

func (*PersistOptions) GetLabelPropertyConfig

func (o *PersistOptions) GetLabelPropertyConfig() LabelPropertyConfig

GetLabelPropertyConfig returns the label property.

func (*PersistOptions) GetLeaderScheduleLimit

func (o *PersistOptions) GetLeaderScheduleLimit() uint64

GetLeaderScheduleLimit returns the limit for leader schedule.

func (*PersistOptions) GetLeaderSchedulePolicy

func (o *PersistOptions) GetLeaderSchedulePolicy() core.SchedulePolicy

GetLeaderSchedulePolicy is to get leader schedule policy.

func (*PersistOptions) GetLocationLabels

func (o *PersistOptions) GetLocationLabels() []string

GetLocationLabels returns the location labels for each resource.

func (*PersistOptions) GetLowSpaceRatio

func (o *PersistOptions) GetLowSpaceRatio() float64

GetLowSpaceRatio returns the low space ratio.

func (*PersistOptions) GetMaxContainerDownTime

func (o *PersistOptions) GetMaxContainerDownTime() time.Duration

GetMaxContainerDownTime returns the max down time of a container.

func (*PersistOptions) GetMaxMergeResourceKeys

func (o *PersistOptions) GetMaxMergeResourceKeys() uint64

GetMaxMergeResourceKeys returns the max number of keys.

func (*PersistOptions) GetMaxMergeResourceSize

func (o *PersistOptions) GetMaxMergeResourceSize() uint64

GetMaxMergeResourceSize returns the max resource size.

func (*PersistOptions) GetMaxPendingPeerCount

func (o *PersistOptions) GetMaxPendingPeerCount() uint64

GetMaxPendingPeerCount returns the number of the max pending peers.

func (*PersistOptions) GetMaxReplicas

func (o *PersistOptions) GetMaxReplicas() int

GetMaxReplicas returns the number of replicas for each resource.

func (*PersistOptions) GetMaxSnapshotCount

func (o *PersistOptions) GetMaxSnapshotCount() uint64

GetMaxSnapshotCount returns the number of the max snapshot which is allowed to send.

func (*PersistOptions) GetMergeScheduleLimit

func (o *PersistOptions) GetMergeScheduleLimit() uint64

GetMergeScheduleLimit returns the limit for merge schedule.

func (*PersistOptions) GetPatrolResourceInterval

func (o *PersistOptions) GetPatrolResourceInterval() time.Duration

GetPatrolResourceInterval returns the interval of patrolling resource.

func (*PersistOptions) GetReplicaScheduleLimit

func (o *PersistOptions) GetReplicaScheduleLimit() uint64

GetReplicaScheduleLimit returns the limit for replica schedule.

func (*PersistOptions) GetReplicationConfig

func (o *PersistOptions) GetReplicationConfig() *ReplicationConfig

GetReplicationConfig returns replication configurations.

func (*PersistOptions) GetResourceScheduleLimit

func (o *PersistOptions) GetResourceScheduleLimit() uint64

GetResourceScheduleLimit returns the limit for resource schedule.

func (*PersistOptions) GetResourceScoreFormulaVersion

func (o *PersistOptions) GetResourceScoreFormulaVersion() string

GetResourceScoreFormulaVersion returns the formula version config.

func (*PersistOptions) GetScheduleConfig

func (o *PersistOptions) GetScheduleConfig() *ScheduleConfig

GetScheduleConfig returns scheduling configurations.

func (*PersistOptions) GetSchedulerMaxWaitingOperator

func (o *PersistOptions) GetSchedulerMaxWaitingOperator() uint64

GetSchedulerMaxWaitingOperator returns the number of the max waiting operators.

func (*PersistOptions) GetSchedulers

func (o *PersistOptions) GetSchedulers() SchedulerConfigs

GetSchedulers gets the scheduler configurations.

func (*PersistOptions) GetSplitMergeInterval

func (o *PersistOptions) GetSplitMergeInterval() time.Duration

GetSplitMergeInterval returns the interval between finishing split and starting to merge.

func (*PersistOptions) GetStrictlyMatchLabel

func (o *PersistOptions) GetStrictlyMatchLabel() bool

GetStrictlyMatchLabel returns whether check label strict.

func (*PersistOptions) GetTolerantSizeRatio

func (o *PersistOptions) GetTolerantSizeRatio() float64

GetTolerantSizeRatio gets the tolerant size ratio.

func (*PersistOptions) IsCrossTableMergeEnabled

func (o *PersistOptions) IsCrossTableMergeEnabled() bool

IsCrossTableMergeEnabled returns if across table merge is enabled.

func (*PersistOptions) IsDebugMetricsEnabled

func (o *PersistOptions) IsDebugMetricsEnabled() bool

IsDebugMetricsEnabled returns if debug metrics is enabled.

func (*PersistOptions) IsLocationReplacementEnabled

func (o *PersistOptions) IsLocationReplacementEnabled() bool

IsLocationReplacementEnabled returns if location replace is enabled.

func (*PersistOptions) IsMakeUpReplicaEnabled

func (o *PersistOptions) IsMakeUpReplicaEnabled() bool

IsMakeUpReplicaEnabled returns if make up replica is enabled.

func (*PersistOptions) IsOneWayMergeEnabled

func (o *PersistOptions) IsOneWayMergeEnabled() bool

IsOneWayMergeEnabled returns if a resource can only be merged into the next resource of it.

func (*PersistOptions) IsPlacementRulesEnabled

func (o *PersistOptions) IsPlacementRulesEnabled() bool

IsPlacementRulesEnabled returns if the placement rules is enabled.

func (*PersistOptions) IsRemoveDownReplicaEnabled

func (o *PersistOptions) IsRemoveDownReplicaEnabled() bool

IsRemoveDownReplicaEnabled returns if remove down replica is enabled.

func (*PersistOptions) IsRemoveExtraReplicaEnabled

func (o *PersistOptions) IsRemoveExtraReplicaEnabled() bool

IsRemoveExtraReplicaEnabled returns if remove extra replica is enabled.

func (*PersistOptions) IsReplaceOfflineReplicaEnabled

func (o *PersistOptions) IsReplaceOfflineReplicaEnabled() bool

IsReplaceOfflineReplicaEnabled returns if replace offline replica is enabled.

func (*PersistOptions) IsUseJointConsensus

func (o *PersistOptions) IsUseJointConsensus() bool

IsUseJointConsensus returns if using joint consensus as a operator step is enabled.

func (*PersistOptions) Persist

func (o *PersistOptions) Persist(storage storage.Storage) error

Persist saves the configuration to the storage.

func (*PersistOptions) SetAllContainersLimit

func (o *PersistOptions) SetAllContainersLimit(typ limit.Type, ratePerMin float64)

SetAllContainersLimit sets all container limit for a given type and rate.

func (*PersistOptions) SetClusterVersion

func (o *PersistOptions) SetClusterVersion(v *semver.Version)

SetClusterVersion sets the cluster version.

func (*PersistOptions) SetContainerLimit

func (o *PersistOptions) SetContainerLimit(containerID uint64, typ limit.Type, ratePerMin float64)

SetContainerLimit sets a container limit for a given type and rate.

func (*PersistOptions) SetEnableJointConsensus

func (o *PersistOptions) SetEnableJointConsensus(enableJointConsensus bool)

SetEnableJointConsensus sets whether to enable joint-consensus. It's only used to test.

func (*PersistOptions) SetLabelProperty

func (o *PersistOptions) SetLabelProperty(typ, labelKey, labelValue string)

SetLabelProperty sets the label property.

func (*PersistOptions) SetLabelPropertyConfig

func (o *PersistOptions) SetLabelPropertyConfig(cfg LabelPropertyConfig)

SetLabelPropertyConfig sets the label property configuration.

func (*PersistOptions) SetMaxReplicas

func (o *PersistOptions) SetMaxReplicas(replicas int)

SetMaxReplicas sets the number of replicas for each resource.

func (*PersistOptions) SetPlacementRuleEnabled

func (o *PersistOptions) SetPlacementRuleEnabled(enabled bool)

SetPlacementRuleEnabled set PlacementRuleEnabled

func (*PersistOptions) SetReplicationConfig

func (o *PersistOptions) SetReplicationConfig(cfg *ReplicationConfig)

SetReplicationConfig sets the PD replication configuration.

func (*PersistOptions) SetScheduleConfig

func (o *PersistOptions) SetScheduleConfig(cfg *ScheduleConfig)

SetScheduleConfig sets the PD scheduling configuration.

func (*PersistOptions) SetSplitMergeInterval

func (o *PersistOptions) SetSplitMergeInterval(splitMergeInterval time.Duration)

SetSplitMergeInterval to set the interval between finishing split and starting to merge. It's only used to test.

type ReplicationConfig

type ReplicationConfig struct {
	// MaxReplicas is the number of replicas for each resource.
	MaxReplicas uint64 `toml:"max-replicas" json:"max-replicas"`

	// The label keys specified the location of a container.
	// The placement priorities is implied by the order of label keys.
	// For example, ["zone", "rack"] means that we should place replicas to
	// different zones first, then to different racks if we don't have enough zones.
	LocationLabels typeutil.StringSlice `toml:"location-labels" json:"location-labels"`
	// StrictlyMatchLabel strictly checks if the label of your storage application is matched with LocationLabels.
	StrictlyMatchLabel bool `toml:"strictly-match-label" json:"strictly-match-label,string"`

	// When PlacementRules feature is enabled. MaxReplicas, LocationLabels and IsolationLabels are not used any more.
	EnablePlacementRules bool `toml:"enable-placement-rules" json:"enable-placement-rules,string"`

	// IsolationLevel is used to isolate replicas explicitly and forcibly if it's not empty.
	// Its value must be empty or one of LocationLabels.
	// Example:
	// location-labels = ["zone", "rack", "host"]
	// isolation-level = "zone"
	// With configuration like above, Prophet ensure that all replicas be placed in different zones.
	// Even if a zone is down, Prophet will not try to make up replicas in other zone
	// because other zones already have replicas on it.
	IsolationLevel string `toml:"isolation-level" json:"isolation-level"`

	// Groups resources groups
	Groups []uint64 `toml:"groups" json:"groups"`
}

ReplicationConfig is the replication configuration.

func (*ReplicationConfig) Clone

Clone makes a deep copy of the config.

func (*ReplicationConfig) Validate

func (c *ReplicationConfig) Validate() error

Validate is used to validate if some replication configurations are right.

type ResourcesAware

type ResourcesAware interface {
	// ForeachWaittingCreateResources do every waitting resources
	ForeachWaittingCreateResources(do func(res metadata.Resource))
	// ForeachResources foreach resource by group
	ForeachResources(group uint64, fn func(res metadata.Resource))
	// GetResource returns resource runtime info
	GetResource(resourceID uint64) *core.CachedResource
}

ResourcesAware resources aware

type ScheduleConfig

type ScheduleConfig struct {
	// If the snapshot count of one container is greater than this value,
	// it will never be used as a source or target container.
	MaxSnapshotCount    uint64 `toml:"max-snapshot-count" json:"max-snapshot-count"`
	MaxPendingPeerCount uint64 `toml:"max-pending-peer-count" json:"max-pending-peer-count"`
	// If both the size of resource is smaller than MaxMergeResourceSize
	// and the number of rows in resource is smaller than MaxMergeResourceKeys,
	// it will try to merge with adjacent resources.
	MaxMergeResourceSize uint64 `toml:"max-merge-resource-size" json:"max-merge-resource-size"`
	MaxMergeResourceKeys uint64 `toml:"max-merge-resource-keys" json:"max-merge-resource-keys"`
	// SplitMergeInterval is the minimum interval time to permit merge after split.
	SplitMergeInterval typeutil.Duration `toml:"split-merge-interval" json:"split-merge-interval"`
	// EnableOneWayMerge is the option to enable one way merge. This means a resource can only be merged into the next resource of it.
	EnableOneWayMerge bool `toml:"enable-one-way-merge" json:"enable-one-way-merge,string"`
	// EnableCrossTableMerge is the option to enable cross table merge. This means two resources can be merged with different table IDs.
	// This option only works when key type is "table".
	EnableCrossTableMerge bool `toml:"enable-cross-table-merge" json:"enable-cross-table-merge,string"`
	// PatrolResourceInterval is the interval for scanning resource during patrol.
	PatrolResourceInterval typeutil.Duration `toml:"patrol-resource-interval" json:"patrol-resource-interval"`
	// MaxContainerDownTime is the max duration after which
	// a container will be considered to be down if it hasn't reported heartbeats.
	MaxContainerDownTime typeutil.Duration `toml:"max-container-down-time" json:"max-container-down-time"`
	// LeaderScheduleLimit is the max coexist leader schedules.
	LeaderScheduleLimit uint64 `toml:"leader-schedule-limit" json:"leader-schedule-limit"`
	// LeaderSchedulePolicy is the option to balance leader, there are some policies supported: ["count", "size"], default: "count"
	LeaderSchedulePolicy string `toml:"leader-schedule-policy" json:"leader-schedule-policy"`
	// ResourceScheduleLimit is the max coexist resource schedules.
	ResourceScheduleLimit uint64 `toml:"resource-schedule-limit" json:"resource-schedule-limit"`
	// ReplicaScheduleLimit is the max coexist replica schedules.
	ReplicaScheduleLimit uint64 `toml:"replica-schedule-limit" json:"replica-schedule-limit"`
	// MergeScheduleLimit is the max coexist merge schedules.
	MergeScheduleLimit uint64 `toml:"merge-schedule-limit" json:"merge-schedule-limit"`
	// HotResourceScheduleLimit is the max coexist hot resource schedules.
	HotResourceScheduleLimit uint64 `toml:"hot-resource-schedule-limit" json:"hot-resource-schedule-limit"`
	// HotResourceCacheHitsThreshold is the cache hits threshold of the hot resource.
	// If the number of times a resource hits the hot cache is greater than this
	// threshold, it is considered a hot resource.
	HotResourceCacheHitsThreshold uint64 `toml:"hot-resource-cache-hits-threshold" json:"hot-resource-cache-hits-threshold"`
	// ContainerLimit is the limit of scheduling for containers.
	ContainerLimit map[uint64]ContainerLimitConfig `toml:"container-limit" json:"container-limit"`
	// TolerantSizeRatio is the ratio of buffer size for balance scheduler.
	TolerantSizeRatio float64 `toml:"tolerant-size-ratio" json:"tolerant-size-ratio"`
	//
	//      high space stage         transition stage           low space stage
	//   |--------------------|-----------------------------|-------------------------|
	//   ^                    ^                             ^                         ^
	//   0       HighSpaceRatio * capacity       LowSpaceRatio * capacity          capacity
	//
	// LowSpaceRatio is the lowest usage ratio of container which regraded as low space.
	// When in low space, container resource score increases to very large and varies inversely with available size.
	LowSpaceRatio float64 `toml:"low-space-ratio" json:"low-space-ratio"`
	// HighSpaceRatio is the highest usage ratio of container which regraded as high space.
	// High space means there is a lot of spare capacity, and container resource score varies directly with used size.
	HighSpaceRatio float64 `toml:"high-space-ratio" json:"high-space-ratio"`
	// ResourceScoreFormulaVersion is used to control the formula used to calculate resource score.
	ResourceScoreFormulaVersion string `toml:"resource-score-formula-version" json:"resource-score-formula-version"`
	// SchedulerMaxWaitingOperator is the max coexist operators for each scheduler.
	SchedulerMaxWaitingOperator uint64 `toml:"scheduler-max-waiting-operator" json:"scheduler-max-waiting-operator"`

	// EnableRemoveDownReplica is the option to enable replica checker to remove down replica.
	EnableRemoveDownReplica bool `toml:"enable-remove-down-replica" json:"enable-remove-down-replica,string"`
	// EnableReplaceOfflineReplica is the option to enable replica checker to replace offline replica.
	EnableReplaceOfflineReplica bool `toml:"enable-replace-offline-replica" json:"enable-replace-offline-replica,string"`
	// EnableMakeUpReplica is the option to enable replica checker to make up replica.
	EnableMakeUpReplica bool `toml:"enable-make-up-replica" json:"enable-make-up-replica,string"`
	// EnableRemoveExtraReplica is the option to enable replica checker to remove extra replica.
	EnableRemoveExtraReplica bool `toml:"enable-remove-extra-replica" json:"enable-remove-extra-replica,string"`
	// EnableLocationReplacement is the option to enable replica checker to move replica to a better location.
	EnableLocationReplacement bool `toml:"enable-location-replacement" json:"enable-location-replacement,string"`
	// EnableDebugMetrics is the option to enable debug metrics.
	EnableDebugMetrics bool `toml:"enable-debug-metrics" json:"enable-debug-metrics,string"`
	// EnableJointConsensus is the option to enable using joint consensus as a operator step.
	EnableJointConsensus bool `toml:"enable-joint-consensus" json:"enable-joint-consensus,string"`

	// Schedulers support for loading customized schedulers
	Schedulers SchedulerConfigs `toml:"schedulers" json:"schedulers-v2"` // json v2 is for the sake of compatible upgrade

	// Only used to display
	SchedulersPayload map[string]interface{} `toml:"schedulers-payload" json:"schedulers-payload"`

	// ContainerLimitMode can be auto or manual, when set to auto,
	// Prophet tries to change the container limit values according to
	// the load state of the cluster dynamically. User can
	// overwrite the auto-tuned value by pd-ctl, when the value
	// is overwritten, the value is fixed until it is deleted.
	// Default: manual
	ContainerLimitMode string `toml:"container-limit-mode" json:"container-limit-mode"`
}

ScheduleConfig is the schedule configuration.

func (*ScheduleConfig) Clone

func (c *ScheduleConfig) Clone() *ScheduleConfig

Clone returns a cloned scheduling configuration.

func (*ScheduleConfig) Validate

func (c *ScheduleConfig) Validate() error

Validate is used to validate if some scheduling configurations are right.

type SchedulerConfig

type SchedulerConfig struct {
	Type        string   `toml:"type" json:"type"`
	Args        []string `toml:"args" json:"args"`
	Disable     bool     `toml:"disable" json:"disable"`
	ArgsPayload string   `toml:"args-payload" json:"args-payload"`
}

SchedulerConfig is customized scheduler configuration

type SchedulerConfigs

type SchedulerConfigs []SchedulerConfig

SchedulerConfigs is a slice of customized scheduler configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL