handler

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Server
}

Handler is a handler to handle http request about schedule.

func NewHandler

func NewHandler(server Server) *Handler

NewHandler creates a new handler.

func (*Handler) AccelerateRegionsScheduleInRange

func (h *Handler) AccelerateRegionsScheduleInRange(rawStartKey, rawEndKey string, limit int) error

AccelerateRegionsScheduleInRange accelerates regions scheduling in a given range.

func (*Handler) AccelerateRegionsScheduleInRanges

func (h *Handler) AccelerateRegionsScheduleInRanges(startKeys [][]byte, endKeys [][]byte, limit int) error

AccelerateRegionsScheduleInRanges accelerates regions scheduling in given ranges.

func (*Handler) AddAddLearnerOperator

func (h *Handler) AddAddLearnerOperator(regionID uint64, toStoreID uint64) error

AddAddLearnerOperator adds an operator to add learner.

func (*Handler) AddAddPeerOperator

func (h *Handler) AddAddPeerOperator(regionID uint64, toStoreID uint64) error

AddAddPeerOperator adds an operator to add peer.

func (*Handler) AddMergeRegionOperator

func (h *Handler) AddMergeRegionOperator(regionID uint64, targetID uint64) error

AddMergeRegionOperator adds an operator to merge region.

func (*Handler) AddRemovePeerOperator

func (h *Handler) AddRemovePeerOperator(regionID uint64, fromStoreID uint64) error

AddRemovePeerOperator adds an operator to remove peer.

func (*Handler) AddScatterRegionOperator

func (h *Handler) AddScatterRegionOperator(regionID uint64, group string) error

AddScatterRegionOperator adds an operator to scatter a region.

func (*Handler) AddScatterRegionsOperators

func (h *Handler) AddScatterRegionsOperators(regionIDs []uint64, startRawKey, endRawKey, group string, retryLimit int) (int, error)

AddScatterRegionsOperators add operators to scatter regions and return the processed percentage and error

func (*Handler) AddSplitRegionOperator

func (h *Handler) AddSplitRegionOperator(regionID uint64, policyStr string, keys []string) error

AddSplitRegionOperator adds an operator to split a region.

func (*Handler) AddTransferLeaderOperator

func (h *Handler) AddTransferLeaderOperator(regionID uint64, storeID uint64) error

AddTransferLeaderOperator adds an operator to transfer leader to the store.

func (*Handler) AddTransferPeerOperator

func (h *Handler) AddTransferPeerOperator(regionID uint64, fromStoreID, toStoreID uint64) error

AddTransferPeerOperator adds an operator to transfer peer.

func (*Handler) AddTransferRegionOperator

func (h *Handler) AddTransferRegionOperator(regionID uint64, storeIDs map[uint64]placement.PeerRoleType) error

AddTransferRegionOperator adds an operator to transfer region to the stores.

func (*Handler) AdjustLimit

func (*Handler) AdjustLimit(limitStr string, defaultLimits ...int) (int, error)

AdjustLimit adjusts the limit of regions to schedule.

func (*Handler) BuildScatterRegionsResp

func (*Handler) BuildScatterRegionsResp(opsCount int, failures map[uint64]error) *ScatterRegionsResponse

BuildScatterRegionsResp builds ScatterRegionsResponse.

func (*Handler) CheckRegionPlacementRule

func (h *Handler) CheckRegionPlacementRule(region *core.RegionInfo) (*placement.RegionFit, error)

CheckRegionPlacementRule checks if the region matches the placement rules.

func (*Handler) CheckRegionsReplicated

func (h *Handler) CheckRegionsReplicated(rawStartKey, rawEndKey string) (string, error)

CheckRegionsReplicated checks if regions are replicated.

func (*Handler) GetAdminOperators

func (h *Handler) GetAdminOperators() ([]*operator.Operator, error)

GetAdminOperators returns the running admin operators.

func (*Handler) GetCheckerStatus

func (h *Handler) GetCheckerStatus(name string) (map[string]bool, error)

GetCheckerStatus returns the status of the checker.

func (*Handler) GetDiagnosticResult

func (h *Handler) GetDiagnosticResult(name string) (*schedulers.DiagnosticResult, error)

GetDiagnosticResult returns the diagnostic results of the specified scheduler.

func (*Handler) GetHistory

func (h *Handler) GetHistory(start time.Time) ([]operator.OpHistory, error)

GetHistory returns finished operators' history since start.

func (*Handler) GetHotBuckets

func (h *Handler) GetHotBuckets(regionIDs ...uint64) (HotBucketsResponse, error)

GetHotBuckets returns all hot buckets stats.

func (*Handler) GetHotRegions

func (h *Handler) GetHotRegions(typ utils.RWType, storeIDs ...uint64) (*statistics.StoreHotPeersInfos, error)

GetHotRegions gets hot regions' statistics by RWType and storeIDs. If storeIDs is empty, it returns all hot regions' statistics by RWType.

func (*Handler) GetHotStores

func (h *Handler) GetHotStores() (*HotStoreStats, error)

GetHotStores gets all hot stores stats.

func (*Handler) GetLeaderOperators

func (h *Handler) GetLeaderOperators() ([]*operator.Operator, error)

GetLeaderOperators returns the running leader operators.

func (*Handler) GetOperator

func (h *Handler) GetOperator(regionID uint64) (*operator.Operator, error)

GetOperator returns the region operator.

func (*Handler) GetOperatorController

func (h *Handler) GetOperatorController() (*operator.Controller, error)

GetOperatorController returns OperatorController.

func (*Handler) GetOperatorStatus

func (h *Handler) GetOperatorStatus(regionID uint64) (*operator.OpWithStatus, error)

GetOperatorStatus returns the status of the region operator.

func (*Handler) GetOperators

func (h *Handler) GetOperators() ([]*operator.Operator, error)

GetOperators returns the running operators.

func (*Handler) GetOperatorsByKinds

func (h *Handler) GetOperatorsByKinds(kinds []string) ([]*operator.Operator, error)

GetOperatorsByKinds returns the running operators by kinds.

func (*Handler) GetRecords

func (h *Handler) GetRecords(from time.Time) ([]*operator.OpRecord, error)

GetRecords returns finished operators since start.

func (*Handler) GetRegion

func (h *Handler) GetRegion(id uint64) (*core.RegionInfo, error)

GetRegion returns the region labeler.

func (*Handler) GetRegionLabeler

func (h *Handler) GetRegionLabeler() (*labeler.RegionLabeler, error)

GetRegionLabeler returns the region labeler.

func (*Handler) GetRegionOperators

func (h *Handler) GetRegionOperators() ([]*operator.Operator, error)

GetRegionOperators returns the running region operators.

func (*Handler) GetRegionScatterer

func (h *Handler) GetRegionScatterer() (*scatter.RegionScatterer, error)

GetRegionScatterer returns RegionScatterer.

func (*Handler) GetRuleManager

func (h *Handler) GetRuleManager() (*placement.RuleManager, error)

GetRuleManager returns the rule manager.

func (*Handler) GetSchedulerByStatus

func (h *Handler) GetSchedulerByStatus(status string, needTS bool) (any, error)

GetSchedulerByStatus returns all names of schedulers by status.

func (*Handler) GetSchedulerNames

func (h *Handler) GetSchedulerNames() ([]string, error)

GetSchedulerNames returns all names of schedulers.

func (*Handler) GetSchedulersController

func (h *Handler) GetSchedulersController() (*schedulers.Controller, error)

GetSchedulersController returns controller of schedulers.

func (*Handler) GetStore

func (h *Handler) GetStore(storeID uint64) (*core.StoreInfo, error)

GetStore returns a store. If store does not exist, return error.

func (*Handler) GetStores

func (h *Handler) GetStores() ([]*core.StoreInfo, error)

GetStores returns all stores in the cluster.

func (*Handler) GetStoresLoads

func (h *Handler) GetStoresLoads() (map[uint64][]float64, error)

GetStoresLoads gets all hot write stores stats.

func (*Handler) GetWaitingOperators

func (h *Handler) GetWaitingOperators() ([]*operator.Operator, error)

GetWaitingOperators returns the waiting operators.

func (*Handler) HandleOperatorCreation

func (h *Handler) HandleOperatorCreation(input map[string]any) (int, any, error)

HandleOperatorCreation processes the request and creates an operator based on the provided input. It supports various types of operators such as transfer-leader, transfer-region, add-peer, remove-peer, merge-region, split-region, scatter-region, and scatter-regions. The function validates the input, performs the corresponding operation, and returns the HTTP status code, response body, and any error encountered during the process.

func (*Handler) PauseOrResumeChecker

func (h *Handler) PauseOrResumeChecker(name string, t int64) (err error)

PauseOrResumeChecker pauses checker for delay seconds or resume checker t == 0 : resume checker. t > 0 : checker delays t seconds.

func (*Handler) PauseOrResumeScheduler

func (h *Handler) PauseOrResumeScheduler(name string, t int64) (err error)

PauseOrResumeScheduler pauses a scheduler for delay seconds or resume a paused scheduler. t == 0 : resume scheduler. t > 0 : scheduler delays t seconds.

func (*Handler) PreCheckForRegion

func (h *Handler) PreCheckForRegion(regionStr string) (*core.RegionInfo, int, error)

PreCheckForRegion checks if the region is valid.

func (*Handler) RemoveOperator

func (h *Handler) RemoveOperator(regionID uint64) error

RemoveOperator removes the region operator.

func (*Handler) RemoveOperators

func (h *Handler) RemoveOperators() error

RemoveOperators removes the all operators.

func (*Handler) ScatterRegionsByID

func (h *Handler) ScatterRegionsByID(ids []uint64, group string, retryLimit int) (int, map[uint64]error, error)

ScatterRegionsByID scatters regions by id.

func (*Handler) ScatterRegionsByRange

func (h *Handler) ScatterRegionsByRange(rawStartKey, rawEndKey string, group string, retryLimit int) (int, map[uint64]error, error)

ScatterRegionsByRange scatters regions by range.

func (*Handler) SplitRegions

func (h *Handler) SplitRegions(ctx context.Context, rawSplitKeys []any, retryLimit int) (*SplitRegionsResponse, error)

SplitRegions splits regions by split keys.

type HotBucketsItem

type HotBucketsItem struct {
	StartKey   string `json:"start_key"`
	EndKey     string `json:"end_key"`
	HotDegree  int    `json:"hot_degree"`
	ReadBytes  uint64 `json:"read_bytes"`
	ReadKeys   uint64 `json:"read_keys"`
	WriteBytes uint64 `json:"write_bytes"`
	WriteKeys  uint64 `json:"write_keys"`
}

HotBucketsItem is the item of hot buckets.

type HotBucketsResponse

type HotBucketsResponse map[uint64][]*HotBucketsItem

HotBucketsResponse is the response for hot buckets.

type HotStoreStats

type HotStoreStats struct {
	BytesWriteStats map[uint64]float64 `json:"bytes-write-rate,omitempty"`
	BytesReadStats  map[uint64]float64 `json:"bytes-read-rate,omitempty"`
	KeysWriteStats  map[uint64]float64 `json:"keys-write-rate,omitempty"`
	KeysReadStats   map[uint64]float64 `json:"keys-read-rate,omitempty"`
	QueryWriteStats map[uint64]float64 `json:"query-write-rate,omitempty"`
	QueryReadStats  map[uint64]float64 `json:"query-read-rate,omitempty"`
}

HotStoreStats is used to record the status of hot stores.

type ScatterRegionsResponse

type ScatterRegionsResponse struct {
	ProcessedPercentage int `json:"processed-percentage"`
}

ScatterRegionsResponse is the response for scatter regions.

type Server

type Server interface {
	GetCoordinator() *schedule.Coordinator
	GetCluster() sche.SchedulerCluster
}

Server is the interface for handler about schedule. TODO: remove it after GetCluster is unified between PD server and Scheduling server.

type SplitRegionsResponse

type SplitRegionsResponse struct {
	ProcessedPercentage int      `json:"processed-percentage"`
	NewRegionsID        []uint64 `json:"regions-id"`
}

SplitRegionsResponse is the response for split regions.

Jump to

Keyboard shortcuts

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