Documentation
¶
Index ¶
- Variables
- type BinlogClient
- func (c *BinlogClient) IsDrainerTombstone(ctx context.Context, addr string) (bool, error)
- func (c *BinlogClient) IsPumpTombstone(ctx context.Context, addr string) (bool, error)
- func (c *BinlogClient) OfflineDrainer(ctx context.Context, addr string) error
- func (c *BinlogClient) OfflinePump(ctx context.Context, addr string) error
- func (c *BinlogClient) UpdateDrainerState(ctx context.Context, addr string, state string) error
- func (c *BinlogClient) UpdatePumpState(ctx context.Context, addr string, state string) error
- type DMMasterClient
- func (dm *DMMasterClient) EvictDMMasterLeader(retryOpt *utils.RetryOption) error
- func (dm *DMMasterClient) GetLeader(retryOpt *utils.RetryOption) (string, error)
- func (dm *DMMasterClient) GetMaster(name string) (isFound bool, isActive bool, isLeader bool, err error)
- func (dm *DMMasterClient) GetRegisteredMembers() ([]string, []string, error)
- func (dm *DMMasterClient) GetURL(addr string) string
- func (dm *DMMasterClient) GetWorker(name string) (string, error)
- func (dm *DMMasterClient) OfflineMaster(name string, retryOpt *utils.RetryOption) error
- func (dm *DMMasterClient) OfflineMember(query string, retryOpt *utils.RetryOption) error
- func (dm *DMMasterClient) OfflineWorker(name string, retryOpt *utils.RetryOption) error
- type LabelInfo
- type MetaStore
- type NoStoreErr
- type NodeStatus
- type PDClient
- func (pc *PDClient) CheckHealth() error
- func (pc *PDClient) CheckRegion(state string) (*RegionsInfo, error)
- func (pc *PDClient) DelPD(name string, retryOpt *utils.RetryOption) error
- func (pc *PDClient) DelStore(host string, retryOpt *utils.RetryOption) error
- func (pc *PDClient) EvictPDLeader(retryOpt *utils.RetryOption) error
- func (pc *PDClient) EvictStoreLeader(host string, retryOpt *utils.RetryOption, ...) error
- func (pc *PDClient) GetClusterID() (int64, error)
- func (pc *PDClient) GetConfig() (map[string]interface{}, error)
- func (pc *PDClient) GetCurrentStore(addr string) (*StoreInfo, error)
- func (pc *PDClient) GetDashboardAddress() (string, error)
- func (pc *PDClient) GetLeader() (*pdpb.Member, error)
- func (pc *PDClient) GetLocationLabels() ([]string, bool, error)
- func (pc *PDClient) GetMembers() (*pdpb.GetMembersResponse, error)
- func (pc *PDClient) GetReplicateConfig() ([]byte, error)
- func (pc *PDClient) GetStores() (*StoresInfo, error)
- func (pc *PDClient) GetTiKVLabels() (map[string]map[string]string, []map[string]LabelInfo, error)
- func (pc *PDClient) GetURL(addr string) string
- func (pc *PDClient) IsTombStone(host string) (bool, error)
- func (pc *PDClient) IsUp(host string) (bool, error)
- func (pc *PDClient) RemoveStoreEvict(host string) error
- func (pc *PDClient) SetAllStoreLimits(value int) error
- func (pc *PDClient) SetReplicationConfig(key string, value int) error
- func (pc *PDClient) UpdateReplicateConfig(body io.Reader) error
- func (pc *PDClient) UpdateScheduleConfig(body io.Reader) error
- func (pc *PDClient) WaitLeader(retryOpt *utils.RetryOption) error
- type PDReplicationConfig
- type RegionInfo
- type RegionsInfo
- type ReplicationStatus
- type StatusResp
- type StoreInfo
- type StoreStatus
- type StoresInfo
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoStore is an empty NoStoreErr object, useful for type checking ErrNoStore = &NoStoreErr{} )
Functions ¶
This section is empty.
Types ¶
type BinlogClient ¶
type BinlogClient struct {
// contains filtered or unexported fields
}
BinlogClient is the client of binlog.
func NewBinlogClient ¶
func NewBinlogClient(pdEndpoints []string, timeout time.Duration, tlsConfig *tls.Config) (*BinlogClient, error)
NewBinlogClient create a BinlogClient.
func (*BinlogClient) IsDrainerTombstone ¶
IsDrainerTombstone check if drainer is tombstone.
func (*BinlogClient) IsPumpTombstone ¶
IsPumpTombstone check if drainer is tombstone.
func (*BinlogClient) OfflineDrainer ¶
func (c *BinlogClient) OfflineDrainer(ctx context.Context, addr string) error
OfflineDrainer offline a drainer.
func (*BinlogClient) OfflinePump ¶
func (c *BinlogClient) OfflinePump(ctx context.Context, addr string) error
OfflinePump offline a pump.
func (*BinlogClient) UpdateDrainerState ¶ added in v1.0.8
UpdateDrainerState update the specify state as the specified state.
func (*BinlogClient) UpdatePumpState ¶ added in v1.0.8
UpdatePumpState update the specify state as the specified state.
type DMMasterClient ¶
type DMMasterClient struct {
// contains filtered or unexported fields
}
DMMasterClient is an HTTP client of the dm-master server
func NewDMMasterClient ¶
func NewDMMasterClient(addrs []string, timeout time.Duration, tlsConfig *tls.Config) *DMMasterClient
NewDMMasterClient returns a new PDClient
func (*DMMasterClient) EvictDMMasterLeader ¶
func (dm *DMMasterClient) EvictDMMasterLeader(retryOpt *utils.RetryOption) error
EvictDMMasterLeader evicts the dm master leader
func (*DMMasterClient) GetLeader ¶
func (dm *DMMasterClient) GetLeader(retryOpt *utils.RetryOption) (string, error)
GetLeader gets leader of dm cluster
func (*DMMasterClient) GetMaster ¶
func (dm *DMMasterClient) GetMaster(name string) (isFound bool, isActive bool, isLeader bool, err error)
GetMaster returns the dm master leader returns isFound, isActive, isLeader, error
func (*DMMasterClient) GetRegisteredMembers ¶
func (dm *DMMasterClient) GetRegisteredMembers() ([]string, []string, error)
GetRegisteredMembers gets all registerer members of dm cluster
func (*DMMasterClient) GetURL ¶
func (dm *DMMasterClient) GetURL(addr string) string
GetURL builds the the client URL of DMClient
func (*DMMasterClient) GetWorker ¶
func (dm *DMMasterClient) GetWorker(name string) (string, error)
GetWorker returns the dm worker status returns (worker stage, error). If worker stage is "", that means this worker is in cluster
func (*DMMasterClient) OfflineMaster ¶
func (dm *DMMasterClient) OfflineMaster(name string, retryOpt *utils.RetryOption) error
OfflineMaster offlines the dm master
func (*DMMasterClient) OfflineMember ¶
func (dm *DMMasterClient) OfflineMember(query string, retryOpt *utils.RetryOption) error
OfflineMember offlines the member of dm cluster
func (*DMMasterClient) OfflineWorker ¶
func (dm *DMMasterClient) OfflineWorker(name string, retryOpt *utils.RetryOption) error
OfflineWorker offlines the dm worker
type LabelInfo ¶ added in v1.7.0
type LabelInfo struct {
Machine string `json:"machine"`
Port string `json:"port"`
Store uint64 `json:"store"`
Status string `json:"status"`
Leaders int `json:"leaders"`
Regions int `json:"regions"`
Capacity string `json:"capacity"`
Available string `json:"available"`
Labels string `json:"labels"`
}
LabelInfo represents an instance label info
type NoStoreErr ¶ added in v1.3.1
type NoStoreErr struct {
// contains filtered or unexported fields
}
NoStoreErr is the error that no store matching address can be found in PD
func (*NoStoreErr) Error ¶ added in v1.3.1
func (e *NoStoreErr) Error() string
Error implement the error interface
func (*NoStoreErr) Is ¶ added in v1.3.1
func (e *NoStoreErr) Is(target error) bool
Is implements the error interface
type NodeStatus ¶
type NodeStatus struct {
NodeID string `json:"nodeId"`
Addr string `json:"host"`
State string `json:"state"`
MaxCommitTS int64 `json:"maxCommitTS"`
UpdateTS int64 `json:"updateTS"`
}
NodeStatus represents the status saved in etcd.
type PDClient ¶
type PDClient struct {
// contains filtered or unexported fields
}
PDClient is an HTTP client of the PD server
func NewPDClient ¶
func NewPDClient( ctx context.Context, addrs []string, timeout time.Duration, tlsConfig *tls.Config, ) *PDClient
NewPDClient returns a new PDClient, the context must have a *logprinter.Logger as value of "logger"
func (*PDClient) CheckHealth ¶ added in v1.0.5
CheckHealth checks the health of PD node
func (*PDClient) CheckRegion ¶ added in v1.4.0
func (pc *PDClient) CheckRegion(state string) (*RegionsInfo, error)
CheckRegion queries for the region with specific status
func (*PDClient) DelPD ¶
func (pc *PDClient) DelPD(name string, retryOpt *utils.RetryOption) error
DelPD deletes a PD node from the cluster, name is the Name of the PD member
func (*PDClient) DelStore ¶
func (pc *PDClient) DelStore(host string, retryOpt *utils.RetryOption) error
DelStore deletes stores from a (TiKV) host The host parameter should be in format of IP:Port, that matches store's address
func (*PDClient) EvictPDLeader ¶
func (pc *PDClient) EvictPDLeader(retryOpt *utils.RetryOption) error
EvictPDLeader evicts the PD leader
func (*PDClient) EvictStoreLeader ¶
func (pc *PDClient) EvictStoreLeader(host string, retryOpt *utils.RetryOption, countLeader func(string) (int, error)) error
EvictStoreLeader evicts the store leaders The host parameter should be in format of IP:Port, that matches store's address
func (*PDClient) GetClusterID ¶ added in v1.7.0
GetClusterID return cluster ID
func (*PDClient) GetCurrentStore ¶ added in v1.3.1
GetCurrentStore gets the current store info of a given host
func (*PDClient) GetDashboardAddress ¶
GetDashboardAddress get the PD node address which runs dashboard
func (*PDClient) GetLocationLabels ¶ added in v1.2.0
GetLocationLabels gets the replication.location-labels config from pd server
func (*PDClient) GetMembers ¶
func (pc *PDClient) GetMembers() (*pdpb.GetMembersResponse, error)
GetMembers queries for member list from the PD server
func (*PDClient) GetReplicateConfig ¶
GetReplicateConfig gets the PD replication config
func (*PDClient) GetStores ¶
func (pc *PDClient) GetStores() (*StoresInfo, error)
GetStores queries the stores info from PD server
func (*PDClient) GetTiKVLabels ¶ added in v1.2.3
GetTiKVLabels implements TiKVLabelProvider
func (*PDClient) IsTombStone ¶
IsTombStone check if the node is Tombstone. The host parameter should be in format of IP:Port, that matches store's address
func (*PDClient) IsUp ¶ added in v1.0.2
IsUp check if the node is Up state. The host parameter should be in format of IP:Port, that matches store's address
func (*PDClient) RemoveStoreEvict ¶
RemoveStoreEvict removes a store leader evict scheduler, which allows following leaders to be transffered to it again.
func (*PDClient) SetAllStoreLimits ¶ added in v1.4.0
SetAllStoreLimits sets store for all stores and types, it has the same effect as `pd-ctl store limit all value`
func (*PDClient) SetReplicationConfig ¶ added in v1.4.0
SetReplicationConfig sets a config key value of PD replication, it has the same effect as `pd-ctl config set key value`
func (*PDClient) UpdateReplicateConfig ¶
UpdateReplicateConfig updates the PD replication config
func (*PDClient) UpdateScheduleConfig ¶ added in v1.0.2
UpdateScheduleConfig updates the PD schedule config
func (*PDClient) WaitLeader ¶
func (pc *PDClient) WaitLeader(retryOpt *utils.RetryOption) error
WaitLeader wait until there's a leader or timeout.
type PDReplicationConfig ¶ added in v1.4.0
type PDReplicationConfig struct {
// MaxReplicas is the number of replicas for each region.
MaxReplicas uint64 `toml:"max-replicas" 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" json:"location-labels"`
// StrictlyMatchLabel strictly checks if the label of TiKV is matched with LocationLabels.
StrictlyMatchLabel bool `toml:"strictly-match-label" json:"strictly-match-label,string"`
// When PlacementRules feature is enabled. MaxReplicas, LocationLabels and IsolationLabels are not used any more.
EnablePlacementRules bool `toml:"enable-placement-rules" json:"enable-placement-rules,string"`
// IsolationLevel is used to isolate replicas explicitly and forcibly if it's not empty.
// Its value must be empty or one of LocationLabels.
// Example:
// location-labels = ["zone", "rack", "host"]
// isolation-level = "zone"
// With configuration like above, PD ensure that all replicas be placed in different zones.
// Even if a zone is down, PD will not try to make up replicas in other zone
// because other zones already have replicas on it.
IsolationLevel string `toml:"isolation-level" json:"isolation-level"`
}
PDReplicationConfig is the replication type configuration ReplicationConfig from PD.
type RegionInfo ¶ added in v1.4.0
type RegionInfo struct {
ID uint64 `json:"id"`
StartKey string `json:"start_key"`
EndKey string `json:"end_key"`
RegionEpoch *metapb.RegionEpoch `json:"epoch,omitempty"`
Peers []*metapb.Peer `json:"peers,omitempty"`
Leader *metapb.Peer `json:"leader,omitempty"`
DownPeers []*pdpb.PeerStats `json:"down_peers,omitempty"`
PendingPeers []*metapb.Peer `json:"pending_peers,omitempty"`
WrittenBytes uint64 `json:"written_bytes"`
ReadBytes uint64 `json:"read_bytes"`
WrittenKeys uint64 `json:"written_keys"`
ReadKeys uint64 `json:"read_keys"`
ApproximateSize int64 `json:"approximate_size"`
ApproximateKeys int64 `json:"approximate_keys"`
ReplicationStatus *ReplicationStatus `json:"replication_status,omitempty"`
}
RegionInfo records detail region info for api usage.
type RegionsInfo ¶ added in v1.4.0
type RegionsInfo struct {
Count int `json:"count"`
Regions []*RegionInfo `json:"regions"`
}
RegionsInfo contains some regions with the detailed region info.
type ReplicationStatus ¶ added in v1.4.0
ReplicationStatus represents the replication mode status of the region.
type StatusResp ¶
StatusResp represents the response of status api.
type StoreInfo ¶ added in v1.4.0
type StoreInfo struct {
Store *MetaStore `json:"store"`
Status *StoreStatus `json:"status"`
}
StoreInfo contains information about a store.
type StoreStatus ¶ added in v1.4.0
type StoreStatus struct {
Capacity typeutil.ByteSize `json:"capacity"`
Available typeutil.ByteSize `json:"available"`
UsedSize typeutil.ByteSize `json:"used_size"`
LeaderCount int `json:"leader_count"`
LeaderWeight float64 `json:"leader_weight"`
LeaderScore float64 `json:"leader_score"`
LeaderSize int64 `json:"leader_size"`
RegionCount int `json:"region_count"`
RegionWeight float64 `json:"region_weight"`
RegionScore float64 `json:"region_score"`
RegionSize int64 `json:"region_size"`
SendingSnapCount uint32 `json:"sending_snap_count,omitempty"`
ReceivingSnapCount uint32 `json:"receiving_snap_count,omitempty"`
ApplyingSnapCount uint32 `json:"applying_snap_count,omitempty"`
IsBusy bool `json:"is_busy,omitempty"`
StartTS *time.Time `json:"start_ts,omitempty"`
LastHeartbeatTS *time.Time `json:"last_heartbeat_ts,omitempty"`
Uptime *typeutil.Duration `json:"uptime,omitempty"`
}
StoreStatus contains status about a store.
type StoresInfo ¶ added in v1.4.0
StoresInfo records stores' info.