Documentation ¶
Index ¶
- Variables
- func GetMembers(etcdClient *clientv3.Client) ([]*pdpb.Member, error)
- func LogPDInfo()
- func NewTestServer(c *C) (*Config, *Server, CleanupFunc)
- func ParseUrls(s string) ([]url.URL, error)
- func PrepareJoinCluster(cfg *Config) error
- func PrintPDInfo()
- type BalanceType
- type CleanupFunc
- type ClusterStatus
- type Config
- type Filter
- type Handler
- func (h *Handler) AddBalanceLeaderScheduler() error
- func (h *Handler) AddEvictLeaderScheduler(storeID uint64) error
- func (h *Handler) AddGrantLeaderScheduler(storeID uint64) error
- func (h *Handler) AddScheduler(s Scheduler) error
- func (h *Handler) AddShuffleLeaderScheduler() error
- func (h *Handler) AddShuffleRegionScheduler() 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]struct{}) error
- func (h *Handler) GetAdminOperators() ([]Operator, error)
- func (h *Handler) GetHistoryOperators() ([]Operator, error)
- func (h *Handler) GetHistoryOperatorsOfKind(kind ResourceKind) ([]Operator, error)
- func (h *Handler) GetHotWriteRegions() *StoreHotRegionInfos
- func (h *Handler) GetHotWriteStores() map[uint64]uint64
- func (h *Handler) GetLeaderOperators() ([]Operator, error)
- func (h *Handler) GetOperator(regionID uint64) (Operator, error)
- func (h *Handler) GetOperators() ([]Operator, error)
- func (h *Handler) GetOperatorsOfKind(kind ResourceKind) ([]Operator, error)
- func (h *Handler) GetRegionOperators() ([]Operator, error)
- func (h *Handler) GetSchedulers() ([]string, error)
- func (h *Handler) RemoveOperator(regionID uint64) error
- func (h *Handler) RemoveScheduler(name string) error
- type HotRegionsStat
- type IDAllocator
- type LogEvent
- type Operator
- type OperatorState
- type RaftCluster
- func (c *RaftCluster) BuryStore(storeID uint64, force bool) error
- func (c *RaftCluster) FetchEvents(key uint64, all bool) []LogEvent
- func (c *RaftCluster) GetConfig() *metapb.Cluster
- func (c *RaftCluster) GetRegionByID(regionID uint64) (*metapb.Region, *metapb.Peer)
- func (c *RaftCluster) GetRegionByKey(regionKey []byte) (*metapb.Region, *metapb.Peer)
- func (c *RaftCluster) GetRegionInfoByID(regionID uint64) *RegionInfo
- func (c *RaftCluster) GetRegionInfoByKey(regionKey []byte) *RegionInfo
- func (c *RaftCluster) GetRegions() []*metapb.Region
- func (c *RaftCluster) GetStore(storeID uint64) (*metapb.Store, *StoreStatus, error)
- func (c *RaftCluster) GetStores() []*metapb.Store
- func (c *RaftCluster) RemoveStore(storeID uint64) error
- func (c *RaftCluster) UpdateStoreLabels(storeID uint64, labels []*metapb.StoreLabel) error
- type RegionInfo
- func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetFollower() *metapb.Peer
- func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
- func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
- func (r *RegionInfo) GetStoreIds() map[uint64]struct{}
- func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
- func (r *RegionInfo) RemoveStorePeer(storeID uint64)
- type RegionStat
- type RegionsStat
- type Replication
- type ReplicationConfig
- type ResourceKind
- type ScheduleConfig
- type Scheduler
- type Selector
- type Server
- func (s *Server) AllocID(ctx context.Context, request *pdpb.AllocIDRequest) (*pdpb.AllocIDResponse, error)
- func (s *Server) AskSplit(ctx context.Context, request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error)
- func (s *Server) Bootstrap(ctx context.Context, request *pdpb.BootstrapRequest) (*pdpb.BootstrapResponse, error)
- func (s *Server) Close()
- func (s *Server) ClusterID() uint64
- func (s *Server) GetAddr() string
- func (s *Server) GetClient() *clientv3.Client
- func (s *Server) GetCluster() *metapb.Cluster
- func (s *Server) GetClusterConfig(ctx context.Context, request *pdpb.GetClusterConfigRequest) (*pdpb.GetClusterConfigResponse, error)
- func (s *Server) GetClusterStatus() (*ClusterStatus, error)
- func (s *Server) GetConfig() *Config
- func (s *Server) GetEndpoints() []string
- func (s *Server) GetHandler() *Handler
- func (s *Server) GetLeader() (*pdpb.Member, error)
- func (s *Server) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb.GetMembersResponse, error)
- func (s *Server) GetRaftCluster() *RaftCluster
- func (s *Server) GetRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error)
- func (s *Server) GetRegionByID(ctx context.Context, request *pdpb.GetRegionByIDRequest) (*pdpb.GetRegionResponse, error)
- func (s *Server) GetReplicationConfig() *ReplicationConfig
- func (s *Server) GetScheduleConfig() *ScheduleConfig
- func (s *Server) GetStore(ctx context.Context, request *pdpb.GetStoreRequest) (*pdpb.GetStoreResponse, error)
- func (s *Server) ID() uint64
- func (s *Server) IsBootstrapped(ctx context.Context, request *pdpb.IsBootstrappedRequest) (*pdpb.IsBootstrappedResponse, error)
- func (s *Server) IsLeader() bool
- func (s *Server) Name() string
- func (s *Server) PutClusterConfig(ctx context.Context, request *pdpb.PutClusterConfigRequest) (*pdpb.PutClusterConfigResponse, error)
- func (s *Server) PutStore(ctx context.Context, request *pdpb.PutStoreRequest) (*pdpb.PutStoreResponse, error)
- func (s *Server) RegionHeartbeat(server pdpb.PD_RegionHeartbeatServer) error
- func (s *Server) ReportSplit(ctx context.Context, request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)
- func (s *Server) ResignLeader(nextLeader string) error
- func (s *Server) Run() error
- func (s *Server) SetReplicationConfig(cfg ReplicationConfig)
- func (s *Server) SetScheduleConfig(cfg ScheduleConfig)
- func (s *Server) StoreHeartbeat(ctx context.Context, request *pdpb.StoreHeartbeatRequest) (*pdpb.StoreHeartbeatResponse, error)
- func (s *Server) Tso(stream pdpb.PD_TsoServer) error
- type StoreHotRegionInfos
- type StoreStatus
Constants ¶
This section is empty.
Variables ¶
var ( PDBuildTS = "None" PDGitHash = "None" PDGitBranch = "None" )
Version information.
var (
ErrNotBootstrapped = errors.New("TiKV cluster is not bootstrapped, please start TiKV first")
)
Error instances
Functions ¶
func GetMembers ¶
GetMembers return a slice of Members.
func NewTestServer ¶
func NewTestServer(c *C) (*Config, *Server, CleanupFunc)
NewTestServer creates a pd server for testing.
func PrepareJoinCluster ¶
PrepareJoinCluster sends MemberAdd command to PD cluster, and returns the initial configuration of the PD cluster.
TL;TR: The join functionality is safe. With data, join does nothing, w/o data
and it is not a member of cluster, join does MemberAdd, it returns an error if PD tries to join itself, missing data or join a duplicated PD.
Etcd automatically re-joins the cluster if there is a data directory. So first it checks if there is a data directory or not. If there is, it returns an empty string (etcd will get the correct configurations from the data directory.)
If there is no data directory, there are following cases:
A new PD joins an existing cluster. What join does: MemberAdd, MemberList, then generate initial-cluster.
A failed PD re-joins the previous cluster. What join does: return an error. (etcd reports: raft log corrupted, truncated, or lost?)
A deleted PD joins to previous cluster. What join does: MemberAdd, MemberList, then generate initial-cluster. (it is not in the member list and there is no data, so we can treat it as a new PD.)
If there is a data directory, there are following special cases:
A failed PD tries to join the previous cluster but it has been deleted during its downtime. What join does: return "" (etcd will connect to other peers and find that the PD itself has been removed.)
A deleted PD joins the previous cluster. What join does: return "" (as etcd will read data directory and find that the PD itself has been removed, so an empty string is fine.)
func PrintPDInfo ¶
func PrintPDInfo()
PrintPDInfo prints the PD version information without log info.
Types ¶
type CleanupFunc ¶
type CleanupFunc func()
CleanupFunc closes test pd server(s) and deletes any files left behind.
type ClusterStatus ¶
ClusterStatus saves some state information
type Config ¶
type Config struct { *flag.FlagSet `json:"-"` Version bool `json:"-"` ClientUrls string `toml:"client-urls" json:"client-urls"` PeerUrls string `toml:"peer-urls" json:"peer-urls"` AdvertiseClientUrls string `toml:"advertise-client-urls" json:"advertise-client-urls"` AdvertisePeerUrls string `toml:"advertise-peer-urls" json:"advertise-peer-urls"` Name string `toml:"name" json:"name"` DataDir string `toml:"data-dir" json:"data-dir"` InitialCluster string `toml:"initial-cluster" json:"initial-cluster"` InitialClusterState string `toml:"initial-cluster-state" json:"initial-cluster-state"` // Join to an existing pd cluster, a string of endpoints. Join string `toml:"join" json:"join"` // 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 onlys support seoncds TTL, so here is second too. LeaderLease int64 `toml:"lease" json:"lease"` // Log related config. Log logutil.LogConfig `toml:"log" json:"log"` // Backward compatibility. LogFileDeprecated string `toml:"log-file" json:"log-file"` LogLevelDeprecated string `toml:"log-level" json:"log-level"` // TsoSaveInterval is the interval to save timestamp. TsoSaveInterval typeutil.Duration `toml:"tso-save-interval" json:"tso-save-interval"` Metric metricutil.MetricConfig `toml:"metric" json:"metric"` Schedule ScheduleConfig `toml:"schedule" json:"schedule"` Replication ReplicationConfig `toml:"replication" json:"replication"` // 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"` // AutoCompactionRetention for mvcc key value store in hour. 0 means disable auto compaction. // the default retention is 1 hour AutoCompactionRetention int `toml:"auto-compaction-retention" json:"auto-compaction-retention"` // For all warnings during parsing. WarningMsgs []string // contains filtered or unexported fields }
Config is the pd server configuration.
func NewTestMultiConfig ¶
NewTestMultiConfig is only for test to create multiple pd configurations. Because pd-client also needs this, so export here.
func NewTestSingleConfig ¶
func NewTestSingleConfig() *Config
NewTestSingleConfig is only for test to create one pd. Because pd-client also needs this, so export here.
type Filter ¶
type Filter interface { // Return true if the store should not be used as a source store. FilterSource(store *storeInfo) bool // Return true if the store should not be used as a target store. FilterTarget(store *storeInfo) bool }
Filter is an interface to filter source and target store.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a helper to export methods to handle API/RPC requests.
func (*Handler) AddBalanceLeaderScheduler ¶
AddBalanceLeaderScheduler adds a balance-leader-scheduler.
func (*Handler) AddEvictLeaderScheduler ¶
AddEvictLeaderScheduler adds an evict-leader-scheduler.
func (*Handler) AddGrantLeaderScheduler ¶
AddGrantLeaderScheduler adds a grant-leader-scheduler.
func (*Handler) AddScheduler ¶
AddScheduler adds a scheduler.
func (*Handler) AddShuffleLeaderScheduler ¶
AddShuffleLeaderScheduler adds a shuffle-leader-scheduler.
func (*Handler) AddShuffleRegionScheduler ¶
AddShuffleRegionScheduler adds a shuffle-region-scheduler.
func (*Handler) AddTransferLeaderOperator ¶
AddTransferLeaderOperator adds an operator to transfer leader to the store.
func (*Handler) AddTransferPeerOperator ¶
AddTransferPeerOperator adds an operator to transfer peer.
func (*Handler) AddTransferRegionOperator ¶
AddTransferRegionOperator adds an operator to transfer region to the stores.
func (*Handler) GetAdminOperators ¶
GetAdminOperators returns the running admin operators.
func (*Handler) GetHistoryOperators ¶
GetHistoryOperators returns history operators
func (*Handler) GetHistoryOperatorsOfKind ¶
func (h *Handler) GetHistoryOperatorsOfKind(kind ResourceKind) ([]Operator, error)
GetHistoryOperatorsOfKind returns history operators by Kind
func (*Handler) GetHotWriteRegions ¶
func (h *Handler) GetHotWriteRegions() *StoreHotRegionInfos
GetHotWriteRegions gets all hot regions status
func (*Handler) GetHotWriteStores ¶
GetHotWriteStores gets all hot write stores status
func (*Handler) GetLeaderOperators ¶
GetLeaderOperators returns the running leader operators.
func (*Handler) GetOperator ¶
GetOperator returns the region operator.
func (*Handler) GetOperators ¶
GetOperators returns the running operators.
func (*Handler) GetOperatorsOfKind ¶
func (h *Handler) GetOperatorsOfKind(kind ResourceKind) ([]Operator, error)
GetOperatorsOfKind returns the running operators of the kind.
func (*Handler) GetRegionOperators ¶
GetRegionOperators returns the running region operators.
func (*Handler) GetSchedulers ¶
GetSchedulers returns all names of schedulers.
func (*Handler) RemoveOperator ¶
RemoveOperator removes the region operator.
func (*Handler) RemoveScheduler ¶
RemoveScheduler removes a scheduler by name.
type HotRegionsStat ¶
type HotRegionsStat struct { WrittenBytes uint64 `json:"total_written_bytes"` RegionsCount int `json:"regions_count"` RegionsStat RegionsStat `json:"statistics"` }
HotRegionsStat records all hot regions statistics
type IDAllocator ¶
IDAllocator is the allocator to generate unique ID.
type LogEvent ¶
type LogEvent struct { ID uint64 `json:"id"` Code msgType `json:"code"` Status statusType `json:"status"` SplitEvent struct { Region uint64 `json:"region"` Left uint64 `json:"left"` Right uint64 `json:"right"` } `json:"split_event,omitempty"` AddReplicaEvent struct { Region uint64 `json:"region"` Store uint64 `json:"store"` } `json:"add_replica_event,omitempty"` RemoveReplicaEvent struct { Region uint64 `json:"region"` Store uint64 `json:"store"` } `json:"remove_replica_event,omitempty"` TransferLeaderEvent struct { Region uint64 `json:"region"` StoreFrom uint64 `json:"store_from"` StoreTo uint64 `json:"store_to"` } `json:"transfer_leader_event,omitempty"` }
LogEvent is operator log event.
type Operator ¶
type Operator interface { GetRegionID() uint64 GetResourceKind() ResourceKind GetState() OperatorState SetState(OperatorState) GetName() string Do(region *RegionInfo) (*pdpb.RegionHeartbeatResponse, bool) }
Operator is an interface to schedule region.
type OperatorState ¶
type OperatorState int
OperatorState indicates state of the operator
const ( // OperatorUnKnownState indicates the unknown state OperatorUnKnownState OperatorState = iota // OperatorWaiting indicates the waiting state OperatorWaiting // OperatorRunning indicates the doing state OperatorRunning // OperatorFinished indicates the finished state OperatorFinished // OperatorTimeOut indicates the time_out state OperatorTimeOut // OperatorReplaced indicates this operator replaced by more priority operator OperatorReplaced )
func (OperatorState) MarshalJSON ¶
func (o OperatorState) MarshalJSON() ([]byte, error)
MarshalJSON returns the state as a JSON string
func (OperatorState) String ¶
func (o OperatorState) String() string
func (*OperatorState) UnmarshalJSON ¶
func (o *OperatorState) UnmarshalJSON(text []byte) error
UnmarshalJSON parses a JSON string into the OperatorState
type RaftCluster ¶
RaftCluster is used for cluster config management. Raft cluster key format: cluster 1 -> /1/raft, value is metapb.Cluster cluster 2 -> /2/raft For cluster 1 store 1 -> /1/raft/s/1, value is metapb.Store region 1 -> /1/raft/r/1, value is metapb.Region
func (*RaftCluster) BuryStore ¶
func (c *RaftCluster) BuryStore(storeID uint64, force bool) error
BuryStore marks a store as tombstone in cluster. State transition: Case 1: Up -> Tombstone (if force is true); Case 2: Offline -> Tombstone.
func (*RaftCluster) FetchEvents ¶
func (c *RaftCluster) FetchEvents(key uint64, all bool) []LogEvent
FetchEvents fetches the operator events.
func (*RaftCluster) GetConfig ¶
func (c *RaftCluster) GetConfig() *metapb.Cluster
GetConfig gets config from cluster.
func (*RaftCluster) GetRegionByID ¶
GetRegionByID gets region and leader peer by regionID from cluster.
func (*RaftCluster) GetRegionByKey ¶
GetRegionByKey gets region and leader peer by region key from cluster.
func (*RaftCluster) GetRegionInfoByID ¶
func (c *RaftCluster) GetRegionInfoByID(regionID uint64) *RegionInfo
GetRegionInfoByID gets regionInfo by regionID from cluster.
func (*RaftCluster) GetRegionInfoByKey ¶
func (c *RaftCluster) GetRegionInfoByKey(regionKey []byte) *RegionInfo
GetRegionInfoByKey gets regionInfo by region key from cluster.
func (*RaftCluster) GetRegions ¶
func (c *RaftCluster) GetRegions() []*metapb.Region
GetRegions gets regions from cluster.
func (*RaftCluster) GetStore ¶
func (c *RaftCluster) GetStore(storeID uint64) (*metapb.Store, *StoreStatus, error)
GetStore gets store from cluster.
func (*RaftCluster) GetStores ¶
func (c *RaftCluster) GetStores() []*metapb.Store
GetStores gets stores from cluster.
func (*RaftCluster) RemoveStore ¶
func (c *RaftCluster) RemoveStore(storeID uint64) error
RemoveStore marks a store as offline in cluster. State transition: Up -> Offline.
func (*RaftCluster) UpdateStoreLabels ¶
func (c *RaftCluster) UpdateStoreLabels(storeID uint64, labels []*metapb.StoreLabel) error
UpdateStoreLabels updates a store's location labels.
type RegionInfo ¶
type RegionInfo struct { *metapb.Region Leader *metapb.Peer DownPeers []*pdpb.PeerStats PendingPeers []*metapb.Peer WrittenBytes uint64 }
RegionInfo record detail region info
func (*RegionInfo) GetDownPeer ¶
func (r *RegionInfo) GetDownPeer(peerID uint64) *metapb.Peer
GetDownPeer return the down peers with specified peer id
func (*RegionInfo) GetFollower ¶
func (r *RegionInfo) GetFollower() *metapb.Peer
GetFollower randomly return a follow peer
func (*RegionInfo) GetFollowers ¶
func (r *RegionInfo) GetFollowers() map[uint64]*metapb.Peer
GetFollowers return a map indicate the follow peers distributed
func (*RegionInfo) GetPeer ¶
func (r *RegionInfo) GetPeer(peerID uint64) *metapb.Peer
GetPeer return the peer with specified peer id
func (*RegionInfo) GetPendingPeer ¶
func (r *RegionInfo) GetPendingPeer(peerID uint64) *metapb.Peer
GetPendingPeer return the pending peer with specified peer id
func (*RegionInfo) GetStoreIds ¶
func (r *RegionInfo) GetStoreIds() map[uint64]struct{}
GetStoreIds return a map indicate the region distributed
func (*RegionInfo) GetStorePeer ¶
func (r *RegionInfo) GetStorePeer(storeID uint64) *metapb.Peer
GetStorePeer return the peer in specified store
func (*RegionInfo) RemoveStorePeer ¶
func (r *RegionInfo) RemoveStorePeer(storeID uint64)
RemoveStorePeer remove the peer in specified store
type RegionStat ¶
type RegionStat struct { RegionID uint64 `json:"region_id"` WrittenBytes uint64 `json:"written_bytes"` // HotDegree records the hot region update times HotDegree int `json:"hot_degree"` // LastUpdateTime used to calculate average write LastUpdateTime time.Time `json:"last_update_time"` StoreID uint64 `json:"-"` // contains filtered or unexported fields }
RegionStat records each hot region's statistics
type RegionsStat ¶
type RegionsStat []RegionStat
RegionsStat is a list of a group region state type
func (RegionsStat) Len ¶
func (m RegionsStat) Len() int
func (RegionsStat) Less ¶
func (m RegionsStat) Less(i, j int) bool
func (RegionsStat) Swap ¶
func (m RegionsStat) Swap(i, j int)
type Replication ¶
type Replication struct {
// contains filtered or unexported fields
}
Replication provides some help to do replication.
func (*Replication) GetDistinctScore ¶
func (r *Replication) GetDistinctScore(stores []*storeInfo, other *storeInfo) float64
GetDistinctScore returns the score that the other is distinct from the stores. A higher score means the other store is more different from the existed stores.
func (*Replication) GetLocationLabels ¶
func (r *Replication) GetLocationLabels() []string
GetLocationLabels returns the location labels for each region
func (*Replication) GetMaxReplicas ¶
func (r *Replication) GetMaxReplicas() int
GetMaxReplicas returns the number of replicas for each region.
func (*Replication) SetMaxReplicas ¶
func (r *Replication) SetMaxReplicas(replicas int)
SetMaxReplicas set the replicas for each region.
type ReplicationConfig ¶
type ReplicationConfig struct { // MaxReplicas is the number of replicas for each region. MaxReplicas uint64 `toml:"max-replicas,omitempty" json:"max-replicas"` // The label keys specified the location of a store. // 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,omitempty" json:"location-labels"` }
ReplicationConfig is the replication configuration.
type ResourceKind ¶
type ResourceKind int
ResourceKind distinguishes different kinds of resources.
const ( // UnKnownKind indicates the unknown kind resource UnKnownKind ResourceKind = iota // AdminKind indicates that specify by admin AdminKind // LeaderKind indicates the leader kind resource LeaderKind // RegionKind indicates the region kind resource RegionKind // PriorityKind indicates the priority kind resource PriorityKind // OtherKind indicates the other kind resource OtherKind )
func ParseResourceKind ¶
func ParseResourceKind(name string) ResourceKind
ParseResourceKind convert string to ResourceKind
func (ResourceKind) String ¶
func (k ResourceKind) String() string
type ScheduleConfig ¶
type ScheduleConfig struct { // If the snapshot count of one store is greater than this value, // it will never be used as a source or target store. MaxSnapshotCount uint64 `toml:"max-snapshot-count,omitempty" json:"max-snapshot-count"` // MaxStoreDownTime is the max duration after which // a store will be considered to be down if it hasn't reported heartbeats. MaxStoreDownTime typeutil.Duration `toml:"max-store-down-time,omitempty" json:"max-store-down-time"` // LeaderScheduleLimit is the max coexist leader schedules. LeaderScheduleLimit uint64 `toml:"leader-schedule-limit,omitempty" json:"leader-schedule-limit"` // RegionScheduleLimit is the max coexist region schedules. RegionScheduleLimit uint64 `toml:"region-schedule-limit,omitempty" json:"region-schedule-limit"` // ReplicaScheduleLimit is the max coexist replica schedules. ReplicaScheduleLimit uint64 `toml:"replica-schedule-limit,omitempty" json:"replica-schedule-limit"` }
ScheduleConfig is the schedule configuration.
type Scheduler ¶
type Scheduler interface { GetName() string GetResourceKind() ResourceKind GetResourceLimit() uint64 Prepare(cluster *clusterInfo) error Cleanup(cluster *clusterInfo) Schedule(cluster *clusterInfo) Operator }
Scheduler is an interface to schedule resources.
type Selector ¶
type Selector interface { SelectSource(stores []*storeInfo, filters ...Filter) *storeInfo SelectTarget(stores []*storeInfo, filters ...Filter) *storeInfo }
Selector is an interface to select source and target store to schedule.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the pd server.
func CreateServer ¶
CreateServer creates the UNINITIALIZED pd server with given configuration.
func (*Server) AllocID ¶
func (s *Server) AllocID(ctx context.Context, request *pdpb.AllocIDRequest) (*pdpb.AllocIDResponse, error)
AllocID implements gRPC PDServer.
func (*Server) AskSplit ¶
func (s *Server) AskSplit(ctx context.Context, request *pdpb.AskSplitRequest) (*pdpb.AskSplitResponse, error)
AskSplit implements gRPC PDServer.
func (*Server) Bootstrap ¶
func (s *Server) Bootstrap(ctx context.Context, request *pdpb.BootstrapRequest) (*pdpb.BootstrapResponse, error)
Bootstrap implements gRPC PDServer.
func (*Server) GetClusterConfig ¶
func (s *Server) GetClusterConfig(ctx context.Context, request *pdpb.GetClusterConfigRequest) (*pdpb.GetClusterConfigResponse, error)
GetClusterConfig implements gRPC PDServer.
func (*Server) GetClusterStatus ¶
func (s *Server) GetClusterStatus() (*ClusterStatus, error)
GetClusterStatus gets cluster status
func (*Server) GetEndpoints ¶
GetEndpoints returns the etcd endpoints for outer use.
func (*Server) GetHandler ¶
GetHandler returns the handler for API.
func (*Server) GetMembers ¶
func (s *Server) GetMembers(context.Context, *pdpb.GetMembersRequest) (*pdpb.GetMembersResponse, error)
GetMembers implements gRPC PDServer.
func (*Server) GetRaftCluster ¶
func (s *Server) GetRaftCluster() *RaftCluster
GetRaftCluster gets raft cluster. If cluster has not been bootstrapped, return nil.
func (*Server) GetRegion ¶
func (s *Server) GetRegion(ctx context.Context, request *pdpb.GetRegionRequest) (*pdpb.GetRegionResponse, error)
GetRegion implements gRPC PDServer.
func (*Server) GetRegionByID ¶
func (s *Server) GetRegionByID(ctx context.Context, request *pdpb.GetRegionByIDRequest) (*pdpb.GetRegionResponse, error)
GetRegionByID implements gRPC PDServer.
func (*Server) GetReplicationConfig ¶
func (s *Server) GetReplicationConfig() *ReplicationConfig
GetReplicationConfig get the replication config
func (*Server) GetScheduleConfig ¶
func (s *Server) GetScheduleConfig() *ScheduleConfig
GetScheduleConfig gets the balance config information.
func (*Server) GetStore ¶
func (s *Server) GetStore(ctx context.Context, request *pdpb.GetStoreRequest) (*pdpb.GetStoreResponse, error)
GetStore implements gRPC PDServer.
func (*Server) IsBootstrapped ¶
func (s *Server) IsBootstrapped(ctx context.Context, request *pdpb.IsBootstrappedRequest) (*pdpb.IsBootstrappedResponse, error)
IsBootstrapped implements gRPC PDServer.
func (*Server) PutClusterConfig ¶
func (s *Server) PutClusterConfig(ctx context.Context, request *pdpb.PutClusterConfigRequest) (*pdpb.PutClusterConfigResponse, error)
PutClusterConfig implements gRPC PDServer.
func (*Server) PutStore ¶
func (s *Server) PutStore(ctx context.Context, request *pdpb.PutStoreRequest) (*pdpb.PutStoreResponse, error)
PutStore implements gRPC PDServer.
func (*Server) RegionHeartbeat ¶
func (s *Server) RegionHeartbeat(server pdpb.PD_RegionHeartbeatServer) error
RegionHeartbeat implements gRPC PDServer.
func (*Server) ReportSplit ¶
func (s *Server) ReportSplit(ctx context.Context, request *pdpb.ReportSplitRequest) (*pdpb.ReportSplitResponse, error)
ReportSplit implements gRPC PDServer.
func (*Server) ResignLeader ¶
ResignLeader resigns current PD's leadership. If nextLeader is empty, all other pd-servers can campaign.
func (*Server) SetReplicationConfig ¶
func (s *Server) SetReplicationConfig(cfg ReplicationConfig)
SetReplicationConfig sets the replication config
func (*Server) SetScheduleConfig ¶
func (s *Server) SetScheduleConfig(cfg ScheduleConfig)
SetScheduleConfig sets the balance config information.
func (*Server) StoreHeartbeat ¶
func (s *Server) StoreHeartbeat(ctx context.Context, request *pdpb.StoreHeartbeatRequest) (*pdpb.StoreHeartbeatResponse, error)
StoreHeartbeat implements gRPC PDServer.
type StoreHotRegionInfos ¶
type StoreHotRegionInfos struct { AsPeer map[uint64]*HotRegionsStat `json:"as_peer"` AsLeader map[uint64]*HotRegionsStat `json:"as_leader"` }
StoreHotRegionInfos : used to get human readable description for hot regions.
type StoreStatus ¶
type StoreStatus struct { *pdpb.StoreStats LeaderCount int RegionCount int LastHeartbeatTS time.Time `json:"last_heartbeat_ts"` // contains filtered or unexported fields }
StoreStatus contains information about a store's status.
func (*StoreStatus) GetStartTS ¶
func (s *StoreStatus) GetStartTS() time.Time
GetStartTS returns the start timestamp.
func (*StoreStatus) GetUptime ¶
func (s *StoreStatus) GetUptime() time.Duration
GetUptime returns the uptime.
func (*StoreStatus) IsDown ¶
func (s *StoreStatus) IsDown() bool
IsDown returns whether the store is down