Versions in this module Expand all Collapse all v0 v0.1.0 Jun 15, 2023 Changes in this version + const APIServiceMode + const PDMode + var ErrAddOperator = errors.New("failed to add operator, maybe already have one") + var ErrNotFoundTSOAddr = status.Errorf(codes.NotFound, "not found tso address") + var ErrNotLeader = status.Errorf(codes.Unavailable, "not leader") + var ErrNotStarted = status.Errorf(codes.Unavailable, "server not started") + var ErrOperatorNotFound = errors.New("operator not found") + var ErrPluginNotFound = func(pluginPath string) error + var ErrRegionAbnormalPeer = func(regionID uint64) error + var ErrRegionNotAdjacent = errors.New("two regions are not adjacent") + var ErrRegionNotFound = func(regionID uint64) error + var ErrSendHeartbeatTimeout = status.Errorf(codes.DeadlineExceeded, "send heartbeat timeout") + var ErrStoreNotFound = func(storeID uint64) error + var EtcdStartTimeout = time.Minute * 5 + var SchedulerConfigHandlerPath = "/api/v1/scheduler-config" + func CheckPDVersion(opt *config.PersistOptions) + func NewTestMultiConfig(c *assertutil.Checker, count int) []*config.Config + func NewTestSingleConfig(c *assertutil.Checker) *config.Config + type GrpcServer struct + func (s *GrpcServer) AllocID(ctx context.Context, request *pdpb.AllocIDRequest) (*pdpb.AllocIDResponse, error) + func (s *GrpcServer) AskBatchSplit(ctx context.Context, request *pdpb.AskBatchSplitRequest) (*pdpb.AskBatchSplitResponse, error) + func (s *GrpcServer) AskSplit(ctx context.Context, request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error) + func (s *GrpcServer) Bootstrap(ctx context.Context, request *pdpb.BootstrapRequest) (*pdpb.BootstrapResponse, error) + func (s *GrpcServer) GetAllStores(ctx context.Context, request *pdpb.GetAllStoresRequest) (*pdpb.GetAllStoresResponse, error) + func (s *GrpcServer) GetClusterConfig(ctx context.Context, request *pdpb.GetClusterConfigRequest) (*pdpb.GetClusterConfigResponse, error) + func (s *GrpcServer) GetClusterInfo(ctx context.Context, _ *pdpb.GetClusterInfoRequest) (*pdpb.GetClusterInfoResponse, error) + func (s *GrpcServer) GetDCLocationInfo(ctx context.Context, request *pdpb.GetDCLocationInfoRequest) (*pdpb.GetDCLocationInfoResponse, error) + func (s *GrpcServer) GetExternalTimestamp(ctx context.Context, request *pdpb.GetExternalTimestampRequest) (*pdpb.GetExternalTimestampResponse, error) + func (s *GrpcServer) GetGCSafePoint(ctx context.Context, request *pdpb.GetGCSafePointRequest) (*pdpb.GetGCSafePointResponse, error) + func (s *GrpcServer) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb.GetMembersResponse, error) + func (s *GrpcServer) GetOperator(ctx context.Context, request *pdpb.GetOperatorRequest) (*pdpb.GetOperatorResponse, error) + func (s *GrpcServer) GetPrevRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error) + func (s *GrpcServer) GetRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error) + func (s *GrpcServer) GetRegionByID(ctx context.Context, request *pdpb.GetRegionByIDRequest) (*pdpb.GetRegionResponse, error) + func (s *GrpcServer) GetStore(ctx context.Context, request *pdpb.GetStoreRequest) (*pdpb.GetStoreResponse, error) + func (s *GrpcServer) IsBootstrapped(ctx context.Context, request *pdpb.IsBootstrappedRequest) (*pdpb.IsBootstrappedResponse, error) + func (s *GrpcServer) IsSnapshotRecovering(ctx context.Context, request *pdpb.IsSnapshotRecoveringRequest) (*pdpb.IsSnapshotRecoveringResponse, error) + func (s *GrpcServer) LoadGlobalConfig(ctx context.Context, request *pdpb.LoadGlobalConfigRequest) (*pdpb.LoadGlobalConfigResponse, error) + func (s *GrpcServer) PutClusterConfig(ctx context.Context, request *pdpb.PutClusterConfigRequest) (*pdpb.PutClusterConfigResponse, error) + func (s *GrpcServer) PutStore(ctx context.Context, request *pdpb.PutStoreRequest) (*pdpb.PutStoreResponse, error) + func (s *GrpcServer) RegionHeartbeat(stream pdpb.PD_RegionHeartbeatServer) error + func (s *GrpcServer) ReportBatchSplit(ctx context.Context, request *pdpb.ReportBatchSplitRequest) (*pdpb.ReportBatchSplitResponse, error) + func (s *GrpcServer) ReportBuckets(stream pdpb.PD_ReportBucketsServer) error + func (s *GrpcServer) ReportMinResolvedTS(ctx context.Context, request *pdpb.ReportMinResolvedTsRequest) (*pdpb.ReportMinResolvedTsResponse, error) + func (s *GrpcServer) ReportSplit(ctx context.Context, request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error) + func (s *GrpcServer) ScanRegions(ctx context.Context, request *pdpb.ScanRegionsRequest) (*pdpb.ScanRegionsResponse, error) + func (s *GrpcServer) ScatterRegion(ctx context.Context, request *pdpb.ScatterRegionRequest) (*pdpb.ScatterRegionResponse, error) + func (s *GrpcServer) SetExternalTimestamp(ctx context.Context, request *pdpb.SetExternalTimestampRequest) (*pdpb.SetExternalTimestampResponse, error) + func (s *GrpcServer) SplitAndScatterRegions(ctx context.Context, request *pdpb.SplitAndScatterRegionsRequest) (*pdpb.SplitAndScatterRegionsResponse, error) + func (s *GrpcServer) SplitRegions(ctx context.Context, request *pdpb.SplitRegionsRequest) (*pdpb.SplitRegionsResponse, error) + func (s *GrpcServer) StoreGlobalConfig(_ context.Context, request *pdpb.StoreGlobalConfigRequest) (*pdpb.StoreGlobalConfigResponse, error) + func (s *GrpcServer) StoreHeartbeat(ctx context.Context, request *pdpb.StoreHeartbeatRequest) (*pdpb.StoreHeartbeatResponse, error) + func (s *GrpcServer) SyncMaxTS(_ context.Context, request *pdpb.SyncMaxTSRequest) (*pdpb.SyncMaxTSResponse, error) + func (s *GrpcServer) SyncRegions(stream pdpb.PD_SyncRegionsServer) error + func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error + func (s *GrpcServer) UpdateGCSafePoint(ctx context.Context, request *pdpb.UpdateGCSafePointRequest) (*pdpb.UpdateGCSafePointResponse, error) + func (s *GrpcServer) UpdateServiceGCSafePoint(ctx context.Context, request *pdpb.UpdateServiceGCSafePointRequest) (*pdpb.UpdateServiceGCSafePointResponse, error) + func (s *GrpcServer) WatchGlobalConfig(req *pdpb.WatchGlobalConfigRequest, server pdpb.PD_WatchGlobalConfigServer) error + type Handler struct + func (h *Handler) AddAddLearnerOperator(regionID uint64, toStoreID uint64) error + func (h *Handler) AddAddPeerOperator(regionID uint64, toStoreID uint64) error + func (h *Handler) AddBalanceHotRegionScheduler() error + func (h *Handler) AddBalanceLeaderScheduler() error + func (h *Handler) AddBalanceRegionScheduler() error + func (h *Handler) AddBalanceWitnessScheduler() error + func (h *Handler) AddEvictLeaderScheduler(storeID uint64) error + func (h *Handler) AddEvictOrGrant(storeID float64, name string) error + func (h *Handler) AddEvictSlowStoreScheduler() error + func (h *Handler) AddEvictSlowTrendScheduler() error + func (h *Handler) AddGrantHotRegionScheduler(leaderID, peers string) error + func (h *Handler) AddGrantLeaderScheduler(storeID uint64) error + func (h *Handler) AddLabelScheduler() error + func (h *Handler) AddMergeRegionOperator(regionID uint64, targetID uint64) error + func (h *Handler) AddRandomMergeScheduler() error + func (h *Handler) AddRemovePeerOperator(regionID uint64, fromStoreID uint64) error + func (h *Handler) AddScatterRangeScheduler(args ...string) error + func (h *Handler) AddScatterRegionOperator(regionID uint64, group string) error + func (h *Handler) AddScatterRegionsOperators(regionIDs []uint64, startRawKey, endRawKey, group string, retryLimit int) (int, error) + func (h *Handler) AddScheduler(name string, args ...string) error + func (h *Handler) AddShuffleHotRegionScheduler(limit uint64) error + func (h *Handler) AddShuffleLeaderScheduler() error + func (h *Handler) AddShuffleRegionScheduler() error + func (h *Handler) AddSplitBucketScheduler() error + func (h *Handler) AddSplitRegionOperator(regionID uint64, policyStr string, keys []string) error + func (h *Handler) AddTransferLeaderOperator(regionID uint64, storeID uint64) error + func (h *Handler) AddTransferPeerOperator(regionID uint64, fromStoreID, toStoreID uint64) error + func (h *Handler) AddTransferRegionOperator(regionID uint64, storeIDs map[uint64]placement.PeerRoleType) error + func (h *Handler) AddTransferWitnessLeaderScheduler() error + func (h *Handler) GetAddr() string + func (h *Handler) GetAdminOperators() ([]*operator.Operator, error) + func (h *Handler) GetAllStoresLimit(limitType storelimit.Type) (map[uint64]config.StoreLimitConfig, error) + func (h *Handler) GetHistory(start time.Time) ([]operator.OpHistory, error) + func (h *Handler) GetHistoryHotRegionIter(hotRegionTypes []string, startTime, endTime int64) storage.HotRegionStorageIterator + func (h *Handler) GetHotReadRegions() *statistics.StoreHotPeersInfos + func (h *Handler) GetHotRegionsReservedDays() uint64 + func (h *Handler) GetHotRegionsWriteInterval() time.Duration + func (h *Handler) GetHotWriteRegions() *statistics.StoreHotPeersInfos + func (h *Handler) GetLeaderOperators() ([]*operator.Operator, error) + func (h *Handler) GetOfflinePeer(typ statistics.RegionStatisticType) ([]*core.RegionInfo, error) + func (h *Handler) GetOperator(regionID uint64) (*operator.Operator, error) + func (h *Handler) GetOperatorController() (*schedule.OperatorController, error) + func (h *Handler) GetOperatorStatus(regionID uint64) (*schedule.OperatorWithStatus, error) + func (h *Handler) GetOperators() ([]*operator.Operator, error) + func (h *Handler) GetOperatorsOfKind(mask operator.OpKind) ([]*operator.Operator, error) + func (h *Handler) GetPausedSchedulerDelayAt(name string) (int64, error) + func (h *Handler) GetPausedSchedulerDelayUntil(name string) (int64, error) + func (h *Handler) GetProgressByAction(action string) (p, ls, cs float64, err error) + func (h *Handler) GetProgressByID(storeID string) (action string, p, ls, cs float64, err error) + func (h *Handler) GetRaftCluster() (*cluster.RaftCluster, error) + func (h *Handler) GetRecords(from time.Time) ([]*operator.OpRecord, error) + func (h *Handler) GetRegionOperators() ([]*operator.Operator, error) + func (h *Handler) GetRegionsByType(typ statistics.RegionStatisticType) ([]*core.RegionInfo, error) + func (h *Handler) GetScheduleConfig() *config.ScheduleConfig + func (h *Handler) GetSchedulerConfigHandler() (http.Handler, error) + func (h *Handler) GetSchedulers() ([]string, error) + func (h *Handler) GetStoreLimitScene(limitType storelimit.Type) *storelimit.Scene + func (h *Handler) GetStores() ([]*core.StoreInfo, error) + func (h *Handler) GetStoresLoads() map[uint64][]float64 + func (h *Handler) GetWaitingOperators() ([]*operator.Operator, error) + func (h *Handler) IsCheckerPaused(name string) (bool, error) + func (h *Handler) IsLeader() bool + func (h *Handler) IsSchedulerDisabled(name string) (bool, error) + func (h *Handler) IsSchedulerExisted(name string) (bool, error) + func (h *Handler) IsSchedulerPaused(name string) (bool, error) + func (h *Handler) PackHistoryHotReadRegions() ([]storage.HistoryHotRegion, error) + func (h *Handler) PackHistoryHotWriteRegions() ([]storage.HistoryHotRegion, error) + func (h *Handler) PauseOrResumeChecker(name string, t int64) error + func (h *Handler) PauseOrResumeScheduler(name string, t int64) error + func (h *Handler) PluginLoad(pluginPath string) error + func (h *Handler) PluginUnload(pluginPath string) error + func (h *Handler) RemoveOperator(regionID uint64) error + func (h *Handler) RemoveScheduler(name string) error + func (h *Handler) ResetTS(ts uint64, ignoreSmaller, skipUpperBoundCheck bool, _ uint32) error + func (h *Handler) SetAllStoresLimit(ratePerMin float64, limitType storelimit.Type) error + func (h *Handler) SetAllStoresLimitTTL(ratePerMin float64, limitType storelimit.Type, ttl time.Duration) error + func (h *Handler) SetLabelStoresLimit(ratePerMin float64, limitType storelimit.Type, labels []*metapb.StoreLabel) error + func (h *Handler) SetStoreLimit(storeID uint64, ratePerMin float64, limitType storelimit.Type) error + func (h *Handler) SetStoreLimitScene(scene *storelimit.Scene, limitType storelimit.Type) + func (h *Handler) SetStoreLimitTTL(data string, value float64, ttl time.Duration) error + type HandlerBuilder func(context.Context, *Server) (http.Handler, apiutil.APIServiceGroup, error) + func CreateMockHandler(re *require.Assertions, ip string) HandlerBuilder + type KeyspaceServer struct + func (s *KeyspaceServer) LoadKeyspace(_ context.Context, request *keyspacepb.LoadKeyspaceRequest) (*keyspacepb.LoadKeyspaceResponse, error) + func (s *KeyspaceServer) UpdateKeyspaceState(_ context.Context, request *keyspacepb.UpdateKeyspaceStateRequest) (*keyspacepb.UpdateKeyspaceStateResponse, error) + func (s *KeyspaceServer) WatchKeyspaces(request *keyspacepb.WatchKeyspacesRequest, ...) error + type Server struct + func CreateServer(ctx context.Context, cfg *config.Config, services []string, ...) (*Server, error) + func MustWaitLeader(re *require.Assertions, svrs []*Server) *Server + func NewTestServer(re *require.Assertions, c *assertutil.Checker) (*Server, testutil.CleanupFunc, error) + func (s *Server) AddCloseCallback(callbacks ...func()) + func (s *Server) AddServiceLabel(serviceLabel string, accessPath apiutil.AccessPath) + func (s *Server) AddServiceReadyCallback(callbacks ...func(context.Context)) + func (s *Server) AddStartCallback(callbacks ...func()) + func (s *Server) Close() + func (s *Server) ClusterID() uint64 + func (s *Server) Context() context.Context + func (s *Server) DeleteLabelProperty(typ, labelKey, labelValue string) error + func (s *Server) GetAPIAccessServiceLabel(accessPath apiutil.AccessPath) string + func (s *Server) GetAddr() string + func (s *Server) GetAllocator() id.Allocator + func (s *Server) GetAuditBackend() []audit.Backend + func (s *Server) GetAuditConfig() *config.AuditConfig + func (s *Server) GetBasicCluster() *core.BasicCluster + func (s *Server) GetClient() *clientv3.Client + func (s *Server) GetClientScheme() string + func (s *Server) GetCluster() *metapb.Cluster + func (s *Server) GetClusterStatus() (*cluster.Status, error) + func (s *Server) GetClusterVersion() semver.Version + func (s *Server) GetConfig() *config.Config + func (s *Server) GetControllerConfig() *rm_server.ControllerConfig + func (s *Server) GetEndpoints() []string + func (s *Server) GetExternalTS() uint64 + func (s *Server) GetHBStreams() *hbstream.HeartbeatStreams + func (s *Server) GetHTTPClient() *http.Client + func (s *Server) GetHandler() *Handler + func (s *Server) GetHistoryHotRegionStorage() *storage.HotRegionStorage + func (s *Server) GetKeyspaceGroupManager() *keyspace.GroupManager + func (s *Server) GetKeyspaceManager() *keyspace.Manager + func (s *Server) GetLabelProperty() config.LabelPropertyConfig + func (s *Server) GetLeader() *pdpb.Member + func (s *Server) GetLeaderLease() int64 + func (s *Server) GetLeaderListenUrls() []string + func (s *Server) GetMaxResetTSGap() time.Duration + func (s *Server) GetMember() *member.EmbeddedEtcdMember + func (s *Server) GetMemberInfo() *pdpb.Member + func (s *Server) GetMembers() ([]*pdpb.Member, error) + func (s *Server) GetMetaRegions() []*metapb.Region + func (s *Server) GetPDServerConfig() *config.PDServerConfig + func (s *Server) GetPersistOptions() *config.PersistOptions + func (s *Server) GetRaftCluster() *cluster.RaftCluster + func (s *Server) GetRateLimitConfig() *config.RateLimitConfig + func (s *Server) GetRegions() []*core.RegionInfo + func (s *Server) GetReplicationConfig() *config.ReplicationConfig + func (s *Server) GetReplicationModeConfig() *config.ReplicationModeConfig + func (s *Server) GetScheduleConfig() *config.ScheduleConfig + func (s *Server) GetServerOption() *config.PersistOptions + func (s *Server) GetServiceAuditBackendLabels(serviceLabel string) *audit.BackendLabels + func (s *Server) GetServiceLabels(serviceLabel string) []apiutil.AccessPath + func (s *Server) GetServiceMiddlewareConfig() *config.ServiceMiddlewareConfig + func (s *Server) GetServiceMiddlewarePersistOptions() *config.ServiceMiddlewarePersistOptions + func (s *Server) GetServicePrimaryAddr(ctx context.Context, serviceName string) (string, bool) + func (s *Server) GetServiceRateLimiter() *ratelimit.Limiter + func (s *Server) GetStorage() storage.Storage + func (s *Server) GetTLSConfig() *grpcutil.TLSConfig + func (s *Server) GetTSOAllocatorManager() *tso.AllocatorManager + func (s *Server) GetTSOSaveInterval() time.Duration + func (s *Server) GetTSOUpdatePhysicalInterval() time.Duration + func (s *Server) IsAPIServiceMode() bool + func (s *Server) IsClosed() bool + func (s *Server) IsInRateLimitAllowList(serviceLabel string) bool + func (s *Server) IsLocalTSOEnabled() bool + func (s *Server) IsServing() bool + func (s *Server) IsSnapshotRecovering(ctx context.Context) (bool, error) + func (s *Server) IsTTLConfigExist(key string) bool + func (s *Server) LoopContext() context.Context + func (s *Server) MarkSnapshotRecovering() error + func (s *Server) Name() string + func (s *Server) PersistFile(name string, data []byte) error + func (s *Server) RecoverAllocID(ctx context.Context, id uint64) error + func (s *Server) ReplicateFileToMember(ctx context.Context, member *pdpb.Member, name string, data []byte) error + func (s *Server) Run() error + func (s *Server) SaveTTLConfig(data map[string]interface{}, ttl time.Duration) error + func (s *Server) SetAuditConfig(cfg config.AuditConfig) error + func (s *Server) SetClusterVersion(v string) error + func (s *Server) SetEnableLocalTSO(enableLocalTSO bool) + func (s *Server) SetExternalTS(externalTS, globalTS uint64) error + func (s *Server) SetLabelProperty(typ, labelKey, labelValue string) error + func (s *Server) SetLabelPropertyConfig(cfg config.LabelPropertyConfig) error + func (s *Server) SetLogLevel(level string) error + func (s *Server) SetPDServerConfig(cfg config.PDServerConfig) error + func (s *Server) SetRateLimitConfig(cfg config.RateLimitConfig) error + func (s *Server) SetReplicationConfig(cfg config.ReplicationConfig) error + func (s *Server) SetReplicationModeConfig(cfg config.ReplicationModeConfig) error + func (s *Server) SetScheduleConfig(cfg config.ScheduleConfig) error + func (s *Server) SetServiceAuditBackendForHTTP(route *mux.Route, labels ...string) + func (s *Server) SetServiceAuditBackendLabels(serviceLabel string, labels []string) + func (s *Server) SetStorage(storage storage.Storage) + func (s *Server) StartTimestamp() int64 + func (s *Server) UnmarkSnapshotRecovering(ctx context.Context) error + func (s *Server) UpdateRateLimit(cfg *config.RateLimitConfig, key string, value interface{}) error + func (s *Server) UpdateRateLimitConfig(key, label string, value ratelimit.DimensionConfig) error + func (s *Server) UpdateServiceRateLimiter(serviceLabel string, opts ...ratelimit.Option) ratelimit.UpdateStatus