server

package
v1.1.0-beta.0...-dd8df1a Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 92 Imported by: 1

Documentation

Index

Constants

View Source
const (

	// PD is name of member.
	PD = "PD"
)

Variables

View Source
var EtcdStartTimeout = time.Minute * 5

EtcdStartTimeout the timeout of the startup etcd.

View Source
var SchedulerConfigHandlerPath = "/api/v1/scheduler-config"

SchedulerConfigHandlerPath is the api router path of the schedule config handler.

Functions

func CheckAndGetPDVersion

func CheckAndGetPDVersion() *semver.Version

CheckAndGetPDVersion checks and returns the PD version.

func CheckPDVersionWithClusterVersion

func CheckPDVersionWithClusterVersion(opt *config.PersistOptions)

CheckPDVersionWithClusterVersion checks if PD needs to be upgraded by comparing the PD version with the cluster version.

func NewTestMultiConfig

func NewTestMultiConfig(c *assertutil.Checker, count int) []*config.Config

NewTestMultiConfig is only for test to create multiple pd configurations. Because PD client also needs this, so export here.

func NewTestSingleConfig

func NewTestSingleConfig(c *assertutil.Checker) *config.Config

NewTestSingleConfig is only for test to create one pd. Because PD client also needs this, so export here.

Types

type GrpcServer

type GrpcServer struct {
	*Server
	// contains filtered or unexported fields
}

GrpcServer wraps Server to provide grpc service.

func (*GrpcServer) AllocID

func (s *GrpcServer) AllocID(ctx context.Context, request *pdpb.AllocIDRequest) (*pdpb.AllocIDResponse, error)

AllocID implements gRPC PDServer.

func (*GrpcServer) AskBatchSplit

func (s *GrpcServer) AskBatchSplit(ctx context.Context, request *pdpb.AskBatchSplitRequest) (*pdpb.AskBatchSplitResponse, error)

AskBatchSplit implements gRPC PDServer.

func (*GrpcServer) AskSplit

func (s *GrpcServer) AskSplit(ctx context.Context, request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error)

AskSplit implements gRPC PDServer.

func (*GrpcServer) BatchScanRegions

BatchScanRegions implements gRPC PDServer.

func (*GrpcServer) Bootstrap

func (s *GrpcServer) Bootstrap(ctx context.Context, request *pdpb.BootstrapRequest) (*pdpb.BootstrapResponse, error)

Bootstrap implements gRPC PDServer.

func (*GrpcServer) GetAllGCSafePointV2

GetAllGCSafePointV2 return all gc safe point v2.

func (*GrpcServer) GetAllStores

func (s *GrpcServer) GetAllStores(ctx context.Context, request *pdpb.GetAllStoresRequest) (*pdpb.GetAllStoresResponse, error)

GetAllStores implements gRPC PDServer.

func (*GrpcServer) GetClusterConfig

GetClusterConfig implements gRPC PDServer.

func (*GrpcServer) GetClusterInfo

GetClusterInfo implements gRPC PDServer.

func (*GrpcServer) GetDCLocationInfo

Deprecated

func (*GrpcServer) GetExternalTimestamp

GetExternalTimestamp implements gRPC PDServer.

func (*GrpcServer) GetGCSafePoint

GetGCSafePoint implements gRPC PDServer.

func (*GrpcServer) GetGCSafePointV2

GetGCSafePointV2 return gc safe point for the given keyspace.

func (*GrpcServer) GetMembers

GetMembers implements gRPC PDServer.

func (*GrpcServer) GetMinTS

func (s *GrpcServer) GetMinTS(
	ctx context.Context, request *pdpb.GetMinTSRequest,
) (*pdpb.GetMinTSResponse, error)

GetMinTS implements gRPC PDServer. In non-microservice env, it simply returns a timestamp. In microservice env, if the tso server exist, it queries all tso servers and gets the minimum timestamp across all keyspace groups. Otherwise, it generates a timestamp locally.

func (*GrpcServer) GetMinTSFromTSOService

func (s *GrpcServer) GetMinTSFromTSOService() (*pdpb.Timestamp, error)

GetMinTSFromTSOService queries all tso servers and gets the minimum timestamp across all keyspace groups.

func (*GrpcServer) GetOperator

func (s *GrpcServer) GetOperator(ctx context.Context, request *pdpb.GetOperatorRequest) (*pdpb.GetOperatorResponse, error)

GetOperator gets information about the operator belonging to the specify region.

func (*GrpcServer) GetPrevRegion

func (s *GrpcServer) GetPrevRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error)

GetPrevRegion implements gRPC PDServer

func (*GrpcServer) GetRegion

func (s *GrpcServer) GetRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error)

GetRegion implements gRPC PDServer.

func (*GrpcServer) GetRegionByID

func (s *GrpcServer) GetRegionByID(ctx context.Context, request *pdpb.GetRegionByIDRequest) (*pdpb.GetRegionResponse, error)

GetRegionByID implements gRPC PDServer.

func (*GrpcServer) GetStore

func (s *GrpcServer) GetStore(ctx context.Context, request *pdpb.GetStoreRequest) (*pdpb.GetStoreResponse, error)

GetStore implements gRPC PDServer.

func (*GrpcServer) IsBootstrapped

IsBootstrapped implements gRPC PDServer.

func (*GrpcServer) IsSnapshotRecovering

IsSnapshotRecovering implements gRPC PDServer.

func (*GrpcServer) LoadGlobalConfig

LoadGlobalConfig support 2 ways to load global config from etcd - `Names` iteratively get value from `ConfigPath/Name` but not care about revision - `ConfigPath` if `Names` is nil can get all values and revision of current path

func (*GrpcServer) PutClusterConfig

PutClusterConfig implements gRPC PDServer.

func (*GrpcServer) PutStore

func (s *GrpcServer) PutStore(ctx context.Context, request *pdpb.PutStoreRequest) (*pdpb.PutStoreResponse, error)

PutStore implements gRPC PDServer.

func (*GrpcServer) RegionHeartbeat

func (s *GrpcServer) RegionHeartbeat(stream pdpb.PD_RegionHeartbeatServer) error

RegionHeartbeat implements gRPC PDServer.

func (*GrpcServer) ReportBatchSplit

ReportBatchSplit implements gRPC PDServer.

func (*GrpcServer) ReportBuckets

func (s *GrpcServer) ReportBuckets(stream pdpb.PD_ReportBucketsServer) error

ReportBuckets implements gRPC PDServer

func (*GrpcServer) ReportMinResolvedTS

ReportMinResolvedTS implements gRPC PDServer.

func (*GrpcServer) ReportSplit

func (s *GrpcServer) ReportSplit(ctx context.Context, request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)

ReportSplit implements gRPC PDServer.

func (*GrpcServer) ScanRegions deprecated

func (s *GrpcServer) ScanRegions(ctx context.Context, request *pdpb.ScanRegionsRequest) (*pdpb.ScanRegionsResponse, error)

Deprecated: use BatchScanRegions instead. ScanRegions implements gRPC PDServer.

func (*GrpcServer) ScatterRegion

func (s *GrpcServer) ScatterRegion(ctx context.Context, request *pdpb.ScatterRegionRequest) (*pdpb.ScatterRegionResponse, error)

ScatterRegion implements gRPC PDServer.

func (*GrpcServer) SetExternalTimestamp

SetExternalTimestamp implements gRPC PDServer.

func (*GrpcServer) SplitAndScatterRegions

SplitAndScatterRegions split regions by the given split keys, and scatter regions. Only regions which split successfully will be scattered. scatterFinishedPercentage indicates the percentage of successfully split regions that are scattered.

func (*GrpcServer) SplitRegions

func (s *GrpcServer) SplitRegions(ctx context.Context, request *pdpb.SplitRegionsRequest) (*pdpb.SplitRegionsResponse, error)

SplitRegions split regions by the given split keys

func (*GrpcServer) StoreGlobalConfig

StoreGlobalConfig store global config into etcd by transaction Since item value needs to support marshal of different struct types, it should be set to `Payload bytes` instead of `Value string`

func (*GrpcServer) StoreHeartbeat

StoreHeartbeat implements gRPC PDServer.

func (*GrpcServer) SyncMaxTS

Deprecated.

func (*GrpcServer) SyncRegions

func (s *GrpcServer) SyncRegions(stream pdpb.PD_SyncRegionsServer) error

SyncRegions syncs the regions.

func (*GrpcServer) Tso

func (s *GrpcServer) Tso(stream pdpb.PD_TsoServer) error

Tso implements gRPC PDServer.

func (*GrpcServer) UpdateGCSafePoint

UpdateGCSafePoint implements gRPC PDServer.

func (*GrpcServer) UpdateGCSafePointV2

UpdateGCSafePointV2 update gc safe point for the given keyspace.

func (*GrpcServer) UpdateServiceGCSafePoint

UpdateServiceGCSafePoint update the safepoint for specific service

func (*GrpcServer) UpdateServiceSafePointV2

UpdateServiceSafePointV2 update service safe point for the given keyspace.

func (*GrpcServer) WatchGCSafePointV2

func (s *GrpcServer) WatchGCSafePointV2(request *pdpb.WatchGCSafePointV2Request, stream pdpb.PD_WatchGCSafePointV2Server) error

WatchGCSafePointV2 watch keyspaces gc safe point changes.

func (*GrpcServer) WatchGlobalConfig

func (s *GrpcServer) WatchGlobalConfig(req *pdpb.WatchGlobalConfigRequest, server pdpb.PD_WatchGlobalConfigServer) error

WatchGlobalConfig will retry on recoverable errors forever until reconnected by Etcd.Watch() as long as the context has not been canceled or timed out. Watch on revision which greater than or equal to the required revision.

type Handler

type Handler struct {
	*handler.Handler
	// contains filtered or unexported fields
}

Handler is a helper to export methods to handle API/RPC requests.

func (*Handler) AddScheduler

func (h *Handler) AddScheduler(tp types.CheckerSchedulerType, args ...string) error

AddScheduler adds a scheduler.

func (*Handler) GetAddr

func (h *Handler) GetAddr() string

GetAddr returns the server urls for clients.

func (*Handler) GetAllRequestHistoryHotRegion

func (h *Handler) GetAllRequestHistoryHotRegion(request *HistoryHotRegionsRequest) (*storage.HistoryHotRegions, error)

GetAllRequestHistoryHotRegion gets all hot region info in HistoryHotRegion form.

func (*Handler) GetHistoryHotRegionIter

func (h *Handler) GetHistoryHotRegionIter(
	hotRegionTypes []string,
	startTime, endTime int64,
) storage.HotRegionStorageIterator

GetHistoryHotRegionIter return a iter which iter all qualified item .

func (*Handler) GetHistoryHotRegions

func (h *Handler) GetHistoryHotRegions(typ utils.RWType) ([]storage.HistoryHotRegion, error)

GetHistoryHotRegions get hot region info in HistoryHotRegion form.

func (*Handler) GetHotRegionsReservedDays

func (h *Handler) GetHotRegionsReservedDays() uint64

GetHotRegionsReservedDays gets days hot region information is kept.

func (*Handler) GetHotRegionsWriteInterval

func (h *Handler) GetHotRegionsWriteInterval() time.Duration

GetHotRegionsWriteInterval gets interval for PD to store Hot Region information..

func (*Handler) GetProgressByAction

func (h *Handler) GetProgressByAction(action string) (p, ls, cs float64, err error)

GetProgressByAction returns the progress details for a given action.

func (*Handler) GetProgressByID

func (h *Handler) GetProgressByID(storeID string) (action string, p, ls, cs float64, err error)

GetProgressByID returns the progress details for a given store ID.

func (*Handler) GetRaftCluster

func (h *Handler) GetRaftCluster() (*cluster.RaftCluster, error)

GetRaftCluster returns RaftCluster.

func (*Handler) GetRegionsByType

func (h *Handler) GetRegionsByType(typ statistics.RegionStatisticType) ([]*core.RegionInfo, error)

GetRegionsByType gets the region with specified type.

func (*Handler) GetScheduleConfig

func (h *Handler) GetScheduleConfig() *sc.ScheduleConfig

GetScheduleConfig returns ScheduleConfig.

func (*Handler) GetSchedulerConfigHandler

func (h *Handler) GetSchedulerConfigHandler() (http.Handler, error)

GetSchedulerConfigHandler gets the handler of schedulers.

func (*Handler) IsLeader

func (h *Handler) IsLeader() bool

IsLeader return true if this server is leader

func (*Handler) IsSchedulerExisted

func (h *Handler) IsSchedulerExisted(name string) (bool, error)

IsSchedulerExisted returns whether scheduler is existed.

func (*Handler) PluginLoad

func (h *Handler) PluginLoad(pluginPath string) error

PluginLoad loads the plugin referenced by the pluginPath

func (*Handler) PluginUnload

func (h *Handler) PluginUnload(pluginPath string) error

PluginUnload unloads the plugin referenced by the pluginPath

func (*Handler) RedirectSchedulerUpdate

func (h *Handler) RedirectSchedulerUpdate(name string, storeID float64) error

RedirectSchedulerUpdate update scheduler config. Export this func to help handle damaged store.

func (*Handler) RemoveScheduler

func (h *Handler) RemoveScheduler(name string) error

RemoveScheduler removes a scheduler by name.

func (*Handler) ResetTS

func (h *Handler) ResetTS(ts uint64, ignoreSmaller, skipUpperBoundCheck bool, _ uint32) error

ResetTS resets the ts with specified tso.

func (*Handler) SetAllStoresLimit

func (h *Handler) SetAllStoresLimit(ratePerMin float64, limitType storelimit.Type) error

SetAllStoresLimit is used to set limit of all stores.

func (*Handler) SetAllStoresLimitTTL

func (h *Handler) SetAllStoresLimitTTL(ratePerMin float64, limitType storelimit.Type, ttl time.Duration) error

SetAllStoresLimitTTL is used to set limit of all stores with ttl

func (*Handler) SetLabelStoresLimit

func (h *Handler) SetLabelStoresLimit(ratePerMin float64, limitType storelimit.Type, labels []*metapb.StoreLabel) error

SetLabelStoresLimit is used to set limit of label stores.

func (*Handler) SetStoreLimit

func (h *Handler) SetStoreLimit(storeID uint64, ratePerMin float64, limitType storelimit.Type) error

SetStoreLimit is used to set the limit of a store.

func (*Handler) SetStoreLimitTTL

func (h *Handler) SetStoreLimitTTL(data string, value float64, ttl time.Duration) error

SetStoreLimitTTL set storeLimit with ttl

type HandlerBuilder

type HandlerBuilder func(context.Context, *Server) (http.Handler, apiutil.APIServiceGroup, error)

HandlerBuilder builds a server HTTP handler.

func CreateMockHandler

func CreateMockHandler(re *require.Assertions, ip string) HandlerBuilder

CreateMockHandler creates a mock handler for test.

type HistoryHotRegionsRequest

type HistoryHotRegionsRequest struct {
	StartTime      int64    `json:"start_time,omitempty"`
	EndTime        int64    `json:"end_time,omitempty"`
	RegionIDs      []uint64 `json:"region_ids,omitempty"`
	StoreIDs       []uint64 `json:"store_ids,omitempty"`
	PeerIDs        []uint64 `json:"peer_ids,omitempty"`
	IsLearners     []bool   `json:"is_learners,omitempty"`
	IsLeaders      []bool   `json:"is_leaders,omitempty"`
	HotRegionTypes []string `json:"hot_region_type,omitempty"`
}

HistoryHotRegionsRequest wrap request condition from tidb. it is request from tidb

type KeyspaceServer

type KeyspaceServer struct {
	*GrpcServer
}

KeyspaceServer wraps GrpcServer to provide keyspace service.

func (*KeyspaceServer) GetAllKeyspaces

GetAllKeyspaces get all keyspace's metadata.

func (*KeyspaceServer) LoadKeyspace

LoadKeyspace load and return target keyspace metadata. Request must specify keyspace name. On Error, keyspaceMeta in response will be nil, error information will be encoded in response header with corresponding error type.

func (*KeyspaceServer) UpdateKeyspaceState

UpdateKeyspaceState updates the state of keyspace specified in the request.

func (*KeyspaceServer) WatchKeyspaces

WatchKeyspaces captures and sends keyspace metadata changes to the client via gRPC stream. Note: It sends all existing keyspaces as it's first package to the client.

type Server

type Server struct {
	diagnosticspb.DiagnosticsServer
	// contains filtered or unexported fields
}

Server is the pd server. It implements bs.Server

func CreateServer

func CreateServer(ctx context.Context, cfg *config.Config, services []string, legacyServiceBuilders ...HandlerBuilder) (*Server, error)

CreateServer creates the UNINITIALIZED pd server with given configuration.

func MustWaitLeader

func MustWaitLeader(re *require.Assertions, svrs []*Server) *Server

MustWaitLeader return the leader until timeout.

func NewTestServer

NewTestServer creates a pd server for testing.

func (*Server) AddCloseCallback

func (s *Server) AddCloseCallback(callbacks ...func())

AddCloseCallback adds a callback in the Close phase.

func (*Server) AddServiceLabel

func (s *Server) AddServiceLabel(serviceLabel string, accessPath apiutil.AccessPath)

AddServiceLabel is used to add the relationship between service label and api access path TODO: this function will be used for updating api rate limit config

func (*Server) AddServiceReadyCallback

func (s *Server) AddServiceReadyCallback(callbacks ...func(context.Context) error)

AddServiceReadyCallback adds callbacks when the server becomes the leader if there is embedded etcd, or the primary otherwise.

func (*Server) AddStartCallback

func (s *Server) AddStartCallback(callbacks ...func())

AddStartCallback adds a callback in the startServer phase.

func (*Server) Close

func (s *Server) Close()

Close closes the server.

func (*Server) Context

func (s *Server) Context() context.Context

Context returns the context of server.

func (*Server) DeleteLabelProperty

func (s *Server) DeleteLabelProperty(typ, labelKey, labelValue string) error

DeleteLabelProperty deletes a label property config.

func (*Server) DirectlyGetRaftCluster

func (s *Server) DirectlyGetRaftCluster() *cluster.RaftCluster

DirectlyGetRaftCluster returns raft cluster directly. Only used for test.

func (*Server) GetAPIAccessServiceLabel

func (s *Server) GetAPIAccessServiceLabel(accessPath apiutil.AccessPath) string

GetAPIAccessServiceLabel returns service label by given access path TODO: this function will be used for updating api rate limit config

func (*Server) GetAddr

func (s *Server) GetAddr() string

GetAddr returns the server urls for clients.

func (*Server) GetAllocator

func (s *Server) GetAllocator() id.Allocator

GetAllocator returns the ID allocator of server.

func (*Server) GetAuditBackend

func (s *Server) GetAuditBackend() []audit.Backend

GetAuditBackend returns audit backends

func (*Server) GetAuditConfig

func (s *Server) GetAuditConfig() *config.AuditConfig

GetAuditConfig gets the audit config information.

func (*Server) GetBasicCluster

func (s *Server) GetBasicCluster() *core.BasicCluster

GetBasicCluster returns the basic cluster of server.

func (*Server) GetClient

func (s *Server) GetClient() *clientv3.Client

GetClient returns builtin etcd client.

func (*Server) GetClientScheme

func (s *Server) GetClientScheme() string

GetClientScheme returns the client URL scheme

func (*Server) GetCluster

func (s *Server) GetCluster() *metapb.Cluster

GetCluster gets cluster.

func (*Server) GetClusterStatus

func (s *Server) GetClusterStatus() (*cluster.Status, error)

GetClusterStatus gets cluster status.

func (*Server) GetClusterVersion

func (s *Server) GetClusterVersion() semver.Version

GetClusterVersion returns the version of cluster.

func (*Server) GetConfig

func (s *Server) GetConfig() *config.Config

GetConfig gets the config information.

func (*Server) GetControllerConfig

func (s *Server) GetControllerConfig() *rm_server.ControllerConfig

GetControllerConfig gets the resource manager controller config.

func (*Server) GetEndpoints

func (s *Server) GetEndpoints() []string

GetEndpoints returns the etcd endpoints for outer use.

func (*Server) GetExternalTS

func (s *Server) GetExternalTS() uint64

GetExternalTS returns external timestamp.

func (*Server) GetGRPCRateLimitConfig

func (s *Server) GetGRPCRateLimitConfig() *config.GRPCRateLimitConfig

GetGRPCRateLimitConfig gets the rate limit config information.

func (*Server) GetGRPCRateLimiter

func (s *Server) GetGRPCRateLimiter() *ratelimit.Controller

GetGRPCRateLimiter is used to get rate limiter

func (*Server) GetGlobalTSOAllocator

func (s *Server) GetGlobalTSOAllocator() tso.Allocator

GetGlobalTSOAllocator return global tso allocator It only is used for test.

func (*Server) GetHBStreams

func (s *Server) GetHBStreams() *hbstream.HeartbeatStreams

GetHBStreams returns the heartbeat streams.

func (*Server) GetHTTPClient

func (s *Server) GetHTTPClient() *http.Client

GetHTTPClient returns builtin http client.

func (*Server) GetHandler

func (s *Server) GetHandler() *Handler

GetHandler returns the handler for API.

func (*Server) GetHistoryHotRegionStorage

func (s *Server) GetHistoryHotRegionStorage() *storage.HotRegionStorage

GetHistoryHotRegionStorage returns the backend storage of historyHotRegion.

func (*Server) GetKeyspaceConfig

func (s *Server) GetKeyspaceConfig() *config.KeyspaceConfig

GetKeyspaceConfig gets the keyspace config information.

func (*Server) GetKeyspaceGroupManager

func (s *Server) GetKeyspaceGroupManager() *keyspace.GroupManager

GetKeyspaceGroupManager returns the keyspace group manager of server.

func (*Server) GetKeyspaceManager

func (s *Server) GetKeyspaceManager() *keyspace.Manager

GetKeyspaceManager returns the keyspace manager of server.

func (*Server) GetLabelProperty

func (s *Server) GetLabelProperty() config.LabelPropertyConfig

GetLabelProperty returns the whole label property config.

func (*Server) GetLeader

func (s *Server) GetLeader() *pdpb.Member

GetLeader returns the leader of PD cluster(i.e the PD leader).

func (*Server) GetLeaderLease

func (s *Server) GetLeaderLease() int64

GetLeaderLease returns the leader lease.

func (*Server) GetLeaderListenUrls

func (s *Server) GetLeaderListenUrls() []string

GetLeaderListenUrls gets service endpoints from the leader in election group.

func (*Server) GetMaxConcurrentTSOProxyStreamings

func (s *Server) GetMaxConcurrentTSOProxyStreamings() int

GetMaxConcurrentTSOProxyStreamings returns the max concurrent TSO proxy streamings. If the value is negative, there is no limit.

func (*Server) GetMaxResetTSGap

func (s *Server) GetMaxResetTSGap() time.Duration

GetMaxResetTSGap gets the max gap to reset the tso.

func (*Server) GetMember

func (s *Server) GetMember() *member.EmbeddedEtcdMember

GetMember returns the member of server.

func (*Server) GetMemberInfo

func (s *Server) GetMemberInfo() *pdpb.Member

GetMemberInfo returns the server member information.

func (*Server) GetMembers

func (s *Server) GetMembers() ([]*pdpb.Member, error)

GetMembers returns PD server list.

func (*Server) GetMetaRegions

func (s *Server) GetMetaRegions() []*metapb.Region

GetMetaRegions gets meta regions from cluster.

func (*Server) GetMicroserviceConfig

func (s *Server) GetMicroserviceConfig() *config.MicroserviceConfig

GetMicroserviceConfig gets the microservice config information.

func (*Server) GetPDServerConfig

func (s *Server) GetPDServerConfig() *config.PDServerConfig

GetPDServerConfig gets the balance config information.

func (*Server) GetPersistOptions

func (s *Server) GetPersistOptions() *config.PersistOptions

GetPersistOptions returns the schedule option.

func (*Server) GetRaftCluster

func (s *Server) GetRaftCluster() *cluster.RaftCluster

GetRaftCluster gets Raft cluster. If cluster has not been bootstrapped, return nil.

func (*Server) GetRateLimitConfig

func (s *Server) GetRateLimitConfig() *config.RateLimitConfig

GetRateLimitConfig gets the rate limit config information.

func (*Server) GetRegions

func (s *Server) GetRegions() []*core.RegionInfo

GetRegions gets regions from cluster.

func (*Server) GetReplicationConfig

func (s *Server) GetReplicationConfig() *sc.ReplicationConfig

GetReplicationConfig get the replication config.

func (*Server) GetReplicationModeConfig

func (s *Server) GetReplicationModeConfig() *config.ReplicationModeConfig

GetReplicationModeConfig returns the replication mode config.

func (*Server) GetSafePointV2Manager

func (s *Server) GetSafePointV2Manager() *gc.SafePointV2Manager

GetSafePointV2Manager returns the safe point v2 manager of server.

func (*Server) GetScheduleConfig

func (s *Server) GetScheduleConfig() *sc.ScheduleConfig

GetScheduleConfig gets the balance config information.

func (*Server) GetServerOption

func (s *Server) GetServerOption() *config.PersistOptions

GetServerOption gets the option of the server.

func (*Server) GetServiceAuditBackendLabels

func (s *Server) GetServiceAuditBackendLabels(serviceLabel string) *audit.BackendLabels

GetServiceAuditBackendLabels returns audit backend labels by serviceLabel

func (*Server) GetServiceLabels

func (s *Server) GetServiceLabels(serviceLabel string) []apiutil.AccessPath

GetServiceLabels returns ApiAccessPaths by given service label TODO: this function will be used for updating api rate limit config

func (*Server) GetServiceMiddlewareConfig

func (s *Server) GetServiceMiddlewareConfig() *config.ServiceMiddlewareConfig

GetServiceMiddlewareConfig gets the service middleware config information.

func (*Server) GetServiceMiddlewarePersistOptions

func (s *Server) GetServiceMiddlewarePersistOptions() *config.ServiceMiddlewarePersistOptions

GetServiceMiddlewarePersistOptions returns the service middleware persist option.

func (*Server) GetServicePrimaryAddr

func (s *Server) GetServicePrimaryAddr(ctx context.Context, serviceName string) (string, bool)

GetServicePrimaryAddr returns the primary address for a given service. Note: This function will only return primary address without judging if it's alive.

func (*Server) GetServiceRateLimiter

func (s *Server) GetServiceRateLimiter() *ratelimit.Controller

GetServiceRateLimiter is used to get rate limiter

func (*Server) GetStorage

func (s *Server) GetStorage() storage.Storage

GetStorage returns the backend storage of server.

func (*Server) GetTLSConfig

func (s *Server) GetTLSConfig() *grpcutil.TLSConfig

GetTLSConfig get the security config.

func (*Server) GetTSOAllocatorManager

func (s *Server) GetTSOAllocatorManager() *tso.AllocatorManager

GetTSOAllocatorManager returns the manager of TSO Allocator.

func (*Server) GetTSOProxyRecvFromClientTimeout

func (s *Server) GetTSOProxyRecvFromClientTimeout() time.Duration

GetTSOProxyRecvFromClientTimeout returns timeout value for TSO proxy receiving from the client.

func (*Server) GetTSOSaveInterval

func (s *Server) GetTSOSaveInterval() time.Duration

GetTSOSaveInterval returns TSO save interval.

func (*Server) GetTSOUpdatePhysicalInterval

func (s *Server) GetTSOUpdatePhysicalInterval() time.Duration

GetTSOUpdatePhysicalInterval returns TSO update physical interval.

func (*Server) IsClosed

func (s *Server) IsClosed() bool

IsClosed checks whether server is closed or not.

func (*Server) IsGRPCServiceLabelExist

func (s *Server) IsGRPCServiceLabelExist(serviceLabel string) bool

IsGRPCServiceLabelExist returns if the service label exists

func (*Server) IsInRateLimitAllowList

func (s *Server) IsInRateLimitAllowList(serviceLabel string) bool

IsInRateLimitAllowList returns whether given service label is in allow lost

func (*Server) IsKeyspaceGroupEnabled

func (s *Server) IsKeyspaceGroupEnabled() bool

IsKeyspaceGroupEnabled return whether the server is in PD.

func (*Server) IsServiceIndependent

func (s *Server) IsServiceIndependent(name string) bool

IsServiceIndependent returns whether the service is independent.

func (*Server) IsServing

func (s *Server) IsServing() bool

IsServing returns whether the server is the leader if there is embedded etcd, or the primary otherwise.

func (*Server) IsSnapshotRecovering

func (s *Server) IsSnapshotRecovering(ctx context.Context) (bool, error)

IsSnapshotRecovering check whether recovering-mark marked

func (*Server) IsTTLConfigExist

func (s *Server) IsTTLConfigExist(key string) bool

IsTTLConfigExist returns true if the ttl config is existed for a given config.

func (*Server) LoopContext

func (s *Server) LoopContext() context.Context

LoopContext returns the loop context of server.

func (*Server) MarkSnapshotRecovering

func (s *Server) MarkSnapshotRecovering() error

MarkSnapshotRecovering mark pd that we're recovering tikv will get this state during BR EBS restore. we write this info into etcd for simplicity, the key only stays inside etcd temporary during BR EBS restore in which period the cluster is not able to serve request. and is deleted after BR EBS restore is done.

func (*Server) Name

func (s *Server) Name() string

Name returns the unique etcd Name for this server in etcd cluster.

func (*Server) PersistFile

func (s *Server) PersistFile(name string, data []byte) error

PersistFile saves a file in DataDir.

func (*Server) RecoverAllocID

func (s *Server) RecoverAllocID(_ context.Context, id uint64) error

RecoverAllocID recover alloc id. set current base id to input id

func (*Server) ReplicateFileToMember

func (s *Server) ReplicateFileToMember(ctx context.Context, member *pdpb.Member, name string, data []byte) error

ReplicateFileToMember is used to synchronize state to a member. Each member will write `data` to a local file named `name`. For security reason, data should be in JSON format.

func (*Server) Run

func (s *Server) Run() error

Run runs the pd server.

func (*Server) SaveTTLConfig

func (s *Server) SaveTTLConfig(data map[string]any, ttl time.Duration) error

SaveTTLConfig save ttl config

func (*Server) SetAuditConfig

func (s *Server) SetAuditConfig(cfg config.AuditConfig) error

SetAuditConfig sets the audit config.

func (*Server) SetClient

func (s *Server) SetClient(client *clientv3.Client)

SetClient sets the etcd client. Notes: it is only used for test.

func (*Server) SetClusterVersion

func (s *Server) SetClusterVersion(v string) error

SetClusterVersion sets the version of cluster.

func (*Server) SetExternalTS

func (s *Server) SetExternalTS(externalTS, globalTS uint64) error

SetExternalTS returns external timestamp.

func (*Server) SetGRPCRateLimitConfig

func (s *Server) SetGRPCRateLimitConfig(cfg config.GRPCRateLimitConfig) error

SetGRPCRateLimitConfig sets the rate limit config.

func (*Server) SetKeyspaceConfig

func (s *Server) SetKeyspaceConfig(cfg config.KeyspaceConfig) error

SetKeyspaceConfig sets the keyspace config information.

func (*Server) SetKeyspaceManager

func (s *Server) SetKeyspaceManager(keyspaceManager *keyspace.Manager)

SetKeyspaceManager sets the keyspace manager of server. Note: it is only used for test.

func (*Server) SetLabelProperty

func (s *Server) SetLabelProperty(typ, labelKey, labelValue string) error

SetLabelProperty inserts a label property config.

func (*Server) SetLabelPropertyConfig

func (s *Server) SetLabelPropertyConfig(cfg config.LabelPropertyConfig) error

SetLabelPropertyConfig sets the label property config.

func (*Server) SetLogLevel added in v1.0.7

func (s *Server) SetLogLevel(level string) error

SetLogLevel sets log level.

func (*Server) SetMicroserviceConfig

func (s *Server) SetMicroserviceConfig(cfg config.MicroserviceConfig) error

SetMicroserviceConfig sets the microservice config information.

func (*Server) SetPDServerConfig

func (s *Server) SetPDServerConfig(cfg config.PDServerConfig) error

SetPDServerConfig sets the server config.

func (*Server) SetRateLimitConfig

func (s *Server) SetRateLimitConfig(cfg config.RateLimitConfig) error

SetRateLimitConfig sets the rate limit config.

func (*Server) SetReplicationConfig

func (s *Server) SetReplicationConfig(cfg sc.ReplicationConfig) error

SetReplicationConfig sets the replication config.

func (*Server) SetReplicationModeConfig

func (s *Server) SetReplicationModeConfig(cfg config.ReplicationModeConfig) error

SetReplicationModeConfig sets the replication mode.

func (*Server) SetScheduleConfig

func (s *Server) SetScheduleConfig(cfg sc.ScheduleConfig) error

SetScheduleConfig sets the balance config information. This function is exported to be used by the API.

func (*Server) SetServiceAuditBackendForHTTP

func (s *Server) SetServiceAuditBackendForHTTP(route *mux.Route, labels ...string)

SetServiceAuditBackendForHTTP is used to register service audit config for HTTP.

func (*Server) SetServiceAuditBackendLabels

func (s *Server) SetServiceAuditBackendLabels(serviceLabel string, labels []string)

SetServiceAuditBackendLabels is used to add audit backend labels for service by service label

func (*Server) SetServicePrimaryAddr

func (s *Server) SetServicePrimaryAddr(serviceName, addr string)

SetServicePrimaryAddr sets the primary address directly. Note: This function is only used for test.

func (*Server) SetStorage

func (s *Server) SetStorage(storage storage.Storage)

SetStorage changes the storage only for test purpose. When we use it, we should prevent calling GetStorage, otherwise, it may cause a data race problem.

func (*Server) StartTimestamp

func (s *Server) StartTimestamp() int64

StartTimestamp returns the start timestamp of this server

func (*Server) UnmarkSnapshotRecovering

func (s *Server) UnmarkSnapshotRecovering(ctx context.Context) error

UnmarkSnapshotRecovering unmark recovering mark

func (*Server) UpdateGRPCRateLimit

func (s *Server) UpdateGRPCRateLimit(cfg *config.GRPCRateLimitConfig, key string, value any) error

UpdateGRPCRateLimit is used to update gRPC rate-limit config which will overwrite limiter-config

func (*Server) UpdateGRPCRateLimitConfig

func (s *Server) UpdateGRPCRateLimitConfig(key, label string, value ratelimit.DimensionConfig) error

UpdateGRPCRateLimitConfig is used to update rate-limit config which will reserve old limiter-config

func (*Server) UpdateGRPCServiceRateLimiter

func (s *Server) UpdateGRPCServiceRateLimiter(serviceLabel string, opts ...ratelimit.Option) ratelimit.UpdateStatus

UpdateGRPCServiceRateLimiter is used to update RateLimiter

func (*Server) UpdateRateLimit

func (s *Server) UpdateRateLimit(cfg *config.RateLimitConfig, key string, value any) error

UpdateRateLimit is used to update rate-limit config which will overwrite limiter-config

func (*Server) UpdateRateLimitConfig

func (s *Server) UpdateRateLimitConfig(key, label string, value ratelimit.DimensionConfig) error

UpdateRateLimitConfig is used to update rate-limit config which will reserve old limiter-config

func (*Server) UpdateServiceRateLimiter

func (s *Server) UpdateServiceRateLimiter(serviceLabel string, opts ...ratelimit.Option) ratelimit.UpdateStatus

UpdateServiceRateLimiter is used to update RateLimiter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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