Documentation
¶
Index ¶
- Variables
- func CreateServerWrapper(cmd *cobra.Command, args []string)
- func GenerateConfig(c *config.Config) (*config.Config, error)
- func NewService[T ConfigProvider](svr bs.Server) registry.RegistrableService
- type Cluster
- func (c *Cluster) AllocID() (uint64, error)
- func (c *Cluster) BucketsStats(degree int, regionIDs ...uint64) map[uint64][]*buckets.BucketStat
- func (c *Cluster) GetBasicCluster() *core.BasicCluster
- func (c *Cluster) GetCheckerConfig() sc.CheckerConfigProvider
- func (c *Cluster) GetCoordinator() *schedule.Coordinator
- func (c *Cluster) GetHotPeerStat(rw utils.RWType, regionID, storeID uint64) *statistics.HotPeerStat
- func (c *Cluster) GetHotPeerStats(rw utils.RWType) map[uint64][]*statistics.HotPeerStat
- func (c *Cluster) GetHotStat() *statistics.HotStat
- func (c *Cluster) GetKeyRangeManager() *keyrange.Manager
- func (c *Cluster) GetLabelStats() *statistics.LabelStatistics
- func (c *Cluster) GetRegionLabeler() *labeler.RegionLabeler
- func (c *Cluster) GetRegionScatterer() *scatter.RegionScatterer
- func (c *Cluster) GetRegionSplitter() *splitter.RegionSplitter
- func (c *Cluster) GetRegionStats() *statistics.RegionStatistics
- func (c *Cluster) GetRuleManager() *placement.RuleManager
- func (c *Cluster) GetSchedulerConfig() sc.SchedulerConfigProvider
- func (c *Cluster) GetSharedConfig() sc.SharedConfigProvider
- func (c *Cluster) GetStorage() storage.Storage
- func (c *Cluster) GetStoreConfig() sc.StoreConfigProvider
- func (c *Cluster) GetStoresLoads() map[uint64][]float64
- func (c *Cluster) GetStoresStats() *statistics.StoresStats
- func (c *Cluster) HandleRegionHeartbeat(region *core.RegionInfo) error
- func (c *Cluster) HandleStoreHeartbeat(heartbeat *schedulingpb.StoreHeartbeatRequest) error
- func (c *Cluster) IsBackgroundJobsRunning() bool
- func (c *Cluster) IsPrepared() bool
- func (c *Cluster) IsRegionHot(region *core.RegionInfo) bool
- func (c *Cluster) IsSchedulingHalted() bool
- func (c *Cluster) SetPrepared()
- func (c *Cluster) StartBackgroundJobs()
- func (c *Cluster) StopBackgroundJobs()
- func (c *Cluster) SwitchAPIServerLeader(new pdpb.PDClient) bool
- func (c *Cluster) UpdateRegionsLabelLevelStats(regions []*core.RegionInfo)
- type ConfigProvider
- type Server
- func (s *Server) AddServiceExitCallback(callbacks ...func())
- func (s *Server) AddServiceReadyCallback(callbacks ...func(context.Context) error)
- func (s *Server) Close()
- func (s *Server) GetAddr() string
- func (s *Server) GetAdvertiseListenAddr() string
- func (s *Server) GetBackendEndpoints() string
- func (s *Server) GetBasicCluster() *core.BasicCluster
- func (s *Server) GetCluster() *Cluster
- func (s *Server) GetConfig() *config.Config
- func (s *Server) GetCoordinator() *schedule.Coordinator
- func (s *Server) GetLeaderListenUrls() []string
- func (s *Server) GetParticipant() *member.Participant
- func (s *Server) GetPersistConfig() *config.PersistConfig
- func (s *Server) GetTLSConfig() *grpcutil.TLSConfig
- func (s *Server) IsClosed() bool
- func (s *Server) IsServing() bool
- func (s *Server) Name() string
- func (s *Server) RegisterGRPCService(grpcServer *grpc.Server)
- func (s *Server) Run() (err error)
- func (s *Server) ServerLoopWgAdd(n int)
- func (s *Server) ServerLoopWgDone()
- func (s *Server) SetLogLevel(level string) error
- func (s *Server) SetUpRestHandler() (http.Handler, apiutil.APIServiceGroup)
- type Service
- func (s *Service) AskBatchSplit(_ context.Context, request *schedulingpb.AskBatchSplitRequest) (*schedulingpb.AskBatchSplitResponse, error)
- func (s *Service) GetOperator(_ context.Context, request *schedulingpb.GetOperatorRequest) (*schedulingpb.GetOperatorResponse, error)
- func (s *Service) RegionHeartbeat(stream schedulingpb.Scheduling_RegionHeartbeatServer) error
- func (s *Service) RegisterGRPCService(g *grpc.Server)
- func (s *Service) RegisterRESTHandler(userDefineHandlers map[string]http.Handler) error
- func (s *Service) ScatterRegions(_ context.Context, request *schedulingpb.ScatterRegionsRequest) (*schedulingpb.ScatterRegionsResponse, error)
- func (s *Service) SplitRegions(ctx context.Context, request *schedulingpb.SplitRegionsRequest) (*schedulingpb.SplitRegionsResponse, error)
- func (s *Service) StoreHeartbeat(_ context.Context, request *schedulingpb.StoreHeartbeatRequest) (*schedulingpb.StoreHeartbeatResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotStarted = status.Errorf(codes.Unavailable, "server not started") ErrClusterMismatched = status.Errorf(codes.Unavailable, "cluster mismatched") )
gRPC errors
var SetUpRestHandler = func(*Service) (http.Handler, apiutil.APIServiceGroup) { return dummyRestService{}, apiutil.APIServiceGroup{} }
SetUpRestHandler is a hook to sets up the REST service.
Functions ¶
func CreateServerWrapper ¶
CreateServerWrapper encapsulates the configuration/log/metrics initialization and create the server
func GenerateConfig ¶
GenerateConfig generates a new config with the given options.
func NewService ¶
func NewService[T ConfigProvider](svr bs.Server) registry.RegistrableService
NewService creates a new scheduling service.
Types ¶
type Cluster ¶
type Cluster struct {
*core.BasicCluster
// contains filtered or unexported fields
}
Cluster is used to manage all information for scheduling purpose.
func NewCluster ¶
func NewCluster( parentCtx context.Context, persistConfig *config.PersistConfig, storage storage.Storage, basicCluster *core.BasicCluster, hbStreams *hbstream.HeartbeatStreams, checkMembershipCh chan struct{}, ) (*Cluster, error)
NewCluster creates a new cluster.
func (*Cluster) BucketsStats ¶
BucketsStats returns hot region's buckets stats.
func (*Cluster) GetBasicCluster ¶
func (c *Cluster) GetBasicCluster() *core.BasicCluster
GetBasicCluster returns the basic cluster.
func (*Cluster) GetCheckerConfig ¶
func (c *Cluster) GetCheckerConfig() sc.CheckerConfigProvider
GetCheckerConfig returns the checker config.
func (*Cluster) GetCoordinator ¶
func (c *Cluster) GetCoordinator() *schedule.Coordinator
GetCoordinator returns the coordinator
func (*Cluster) GetHotPeerStat ¶
func (c *Cluster) GetHotPeerStat(rw utils.RWType, regionID, storeID uint64) *statistics.HotPeerStat
GetHotPeerStat returns hot peer stat with specified regionID and storeID.
func (*Cluster) GetHotPeerStats ¶
func (c *Cluster) GetHotPeerStats(rw utils.RWType) map[uint64][]*statistics.HotPeerStat
GetHotPeerStats returns the read or write statistics for hot regions. It returns a map where the keys are store IDs and the values are slices of HotPeerStat. The result only includes peers that are hot enough. GetHotPeerStats is a thread-safe method.
func (*Cluster) GetHotStat ¶
func (c *Cluster) GetHotStat() *statistics.HotStat
GetHotStat gets hot stat.
func (*Cluster) GetKeyRangeManager ¶
GetKeyRangeManager returns the key range manager
func (*Cluster) GetLabelStats ¶
func (c *Cluster) GetLabelStats() *statistics.LabelStatistics
GetLabelStats gets label statistics.
func (*Cluster) GetRegionLabeler ¶
func (c *Cluster) GetRegionLabeler() *labeler.RegionLabeler
GetRegionLabeler returns the region labeler.
func (*Cluster) GetRegionScatterer ¶
func (c *Cluster) GetRegionScatterer() *scatter.RegionScatterer
GetRegionScatterer returns the region scatter.
func (*Cluster) GetRegionSplitter ¶
func (c *Cluster) GetRegionSplitter() *splitter.RegionSplitter
GetRegionSplitter returns the region splitter.
func (*Cluster) GetRegionStats ¶
func (c *Cluster) GetRegionStats() *statistics.RegionStatistics
GetRegionStats gets region statistics.
func (*Cluster) GetRuleManager ¶
func (c *Cluster) GetRuleManager() *placement.RuleManager
GetRuleManager returns the rule manager.
func (*Cluster) GetSchedulerConfig ¶
func (c *Cluster) GetSchedulerConfig() sc.SchedulerConfigProvider
GetSchedulerConfig returns the scheduler config.
func (*Cluster) GetSharedConfig ¶
func (c *Cluster) GetSharedConfig() sc.SharedConfigProvider
GetSharedConfig returns the shared config.
func (*Cluster) GetStorage ¶
GetStorage returns the storage.
func (*Cluster) GetStoreConfig ¶
func (c *Cluster) GetStoreConfig() sc.StoreConfigProvider
GetStoreConfig returns the store config.
func (*Cluster) GetStoresLoads ¶
GetStoresLoads returns load stats of all stores.
func (*Cluster) GetStoresStats ¶
func (c *Cluster) GetStoresStats() *statistics.StoresStats
GetStoresStats returns stores' statistics from cluster. And it will be unnecessary to filter unhealthy store, because it has been solved in process heartbeat
func (*Cluster) HandleRegionHeartbeat ¶
func (c *Cluster) HandleRegionHeartbeat(region *core.RegionInfo) error
HandleRegionHeartbeat processes RegionInfo reports from client.
func (*Cluster) HandleStoreHeartbeat ¶
func (c *Cluster) HandleStoreHeartbeat(heartbeat *schedulingpb.StoreHeartbeatRequest) error
HandleStoreHeartbeat updates the store status.
func (*Cluster) IsBackgroundJobsRunning ¶
IsBackgroundJobsRunning returns whether the background jobs are running. Only for test purpose.
func (*Cluster) IsPrepared ¶
IsPrepared return true if the prepare checker is ready.
func (*Cluster) IsRegionHot ¶
func (c *Cluster) IsRegionHot(region *core.RegionInfo) bool
IsRegionHot checks if a region is in hot state.
func (*Cluster) IsSchedulingHalted ¶
IsSchedulingHalted returns whether the scheduling is halted. Currently, the microservice scheduling is halted when:
- The `HaltScheduling` persist option is set to true.
func (*Cluster) SetPrepared ¶
func (c *Cluster) SetPrepared()
SetPrepared set the prepare check to prepared. Only for test purpose.
func (*Cluster) StartBackgroundJobs ¶
func (c *Cluster) StartBackgroundJobs()
StartBackgroundJobs starts background jobs.
func (*Cluster) StopBackgroundJobs ¶
func (c *Cluster) StopBackgroundJobs()
StopBackgroundJobs stops background jobs.
func (*Cluster) SwitchAPIServerLeader ¶
SwitchAPIServerLeader switches the API server leader.
func (*Cluster) UpdateRegionsLabelLevelStats ¶
func (c *Cluster) UpdateRegionsLabelLevelStats(regions []*core.RegionInfo)
UpdateRegionsLabelLevelStats updates the status of the region label level by types.
type ConfigProvider ¶
type ConfigProvider any
ConfigProvider is used to get scheduling config from the given `bs.server` without modifying its interface.
type Server ¶
type Server struct {
*server.BaseServer
diagnosticspb.DiagnosticsServer
// contains filtered or unexported fields
}
Server is the scheduling server, and it implements bs.Server.
func CreateServer ¶
CreateServer creates the Server
func NewTestServer ¶
func NewTestServer(ctx context.Context, re *require.Assertions, cfg *config.Config) (*Server, testutil.CleanupFunc, error)
NewTestServer creates a resource manager server for testing.
func (*Server) AddServiceExitCallback ¶
func (s *Server) AddServiceExitCallback(callbacks ...func())
AddServiceExitCallback adds callbacks when the server becomes the leader, if there is embedded etcd, or the primary otherwise.
func (*Server) AddServiceReadyCallback ¶
AddServiceReadyCallback adds callbacks when the server becomes the leader, if there is embedded etcd, or the primary otherwise.
func (*Server) GetAdvertiseListenAddr ¶
GetAdvertiseListenAddr returns the advertise address of the server.
func (*Server) GetBackendEndpoints ¶
GetBackendEndpoints returns the backend endpoints.
func (*Server) GetBasicCluster ¶
func (s *Server) GetBasicCluster() *core.BasicCluster
GetBasicCluster returns the basic cluster.
func (*Server) GetCoordinator ¶
func (s *Server) GetCoordinator() *schedule.Coordinator
GetCoordinator returns the coordinator.
func (*Server) GetLeaderListenUrls ¶
GetLeaderListenUrls gets service endpoints from the leader in election group.
func (*Server) GetParticipant ¶
func (s *Server) GetParticipant() *member.Participant
GetParticipant returns the participant.
func (*Server) GetPersistConfig ¶
func (s *Server) GetPersistConfig() *config.PersistConfig
GetPersistConfig returns the persist config. It's used to test.
func (*Server) GetTLSConfig ¶
GetTLSConfig gets the security config.
func (*Server) IsServing ¶
IsServing returns whether the server is the leader, if there is embedded etcd, or the primary otherwise.
func (*Server) RegisterGRPCService ¶
RegisterGRPCService registers the grpc service.
func (*Server) ServerLoopWgAdd ¶
ServerLoopWgAdd increases the server loop wait group.
func (*Server) ServerLoopWgDone ¶
func (s *Server) ServerLoopWgDone()
ServerLoopWgDone decreases the server loop wait group.
func (*Server) SetLogLevel ¶
SetLogLevel sets log level.
func (*Server) SetUpRestHandler ¶
func (s *Server) SetUpRestHandler() (http.Handler, apiutil.APIServiceGroup)
SetUpRestHandler sets up the REST handler.
type Service ¶
type Service struct {
*Server
}
Service is the scheduling grpc service.
func (*Service) AskBatchSplit ¶
func (s *Service) AskBatchSplit(_ context.Context, request *schedulingpb.AskBatchSplitRequest) (*schedulingpb.AskBatchSplitResponse, error)
AskBatchSplit implements gRPC SchedulingServer.
func (*Service) GetOperator ¶
func (s *Service) GetOperator(_ context.Context, request *schedulingpb.GetOperatorRequest) (*schedulingpb.GetOperatorResponse, error)
GetOperator gets information about the operator belonging to the specify region.
func (*Service) RegionHeartbeat ¶
func (s *Service) RegionHeartbeat(stream schedulingpb.Scheduling_RegionHeartbeatServer) error
RegionHeartbeat implements gRPC SchedulingServer.
func (*Service) RegisterGRPCService ¶
RegisterGRPCService registers the service to gRPC server.
func (*Service) RegisterRESTHandler ¶
RegisterRESTHandler registers the service to REST server.
func (*Service) ScatterRegions ¶
func (s *Service) ScatterRegions(_ context.Context, request *schedulingpb.ScatterRegionsRequest) (*schedulingpb.ScatterRegionsResponse, error)
ScatterRegions implements gRPC SchedulingServer.
func (*Service) SplitRegions ¶
func (s *Service) SplitRegions(ctx context.Context, request *schedulingpb.SplitRegionsRequest) (*schedulingpb.SplitRegionsResponse, error)
SplitRegions split regions by the given split keys
func (*Service) StoreHeartbeat ¶
func (s *Service) StoreHeartbeat(_ context.Context, request *schedulingpb.StoreHeartbeatRequest) (*schedulingpb.StoreHeartbeatResponse, error)
StoreHeartbeat implements gRPC SchedulingServer.