api

package
v1.3.1-0...-83f5247 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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(pdEndpoint []string, tlsConfig *tls.Config) (*BinlogClient, error)

NewBinlogClient create a BinlogClient.

func (*BinlogClient) IsDrainerTombstone

func (c *BinlogClient) IsDrainerTombstone(ctx context.Context, addr string) (bool, error)

IsDrainerTombstone check if drainer is tombstone.

func (*BinlogClient) IsPumpTombstone

func (c *BinlogClient) IsPumpTombstone(ctx context.Context, addr string) (bool, error)

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

func (c *BinlogClient) UpdateDrainerState(ctx context.Context, addr string, state string) error

UpdateDrainerState update the specify state as the specified state.

func (*BinlogClient) UpdatePumpState

func (c *BinlogClient) UpdatePumpState(ctx context.Context, addr string, state string) error

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 MetaStore

type MetaStore struct {
	*metapb.Store
	StateName string `json:"state_name"`
}

MetaStore contains meta information about a store.

type NoStoreErr

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

func (e *NoStoreErr) Error() string

Error implement the error interface

func (*NoStoreErr) Is

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(addrs []string, timeout time.Duration, tlsConfig *tls.Config) *PDClient

NewPDClient returns a new PDClient

func (*PDClient) CheckHealth

func (pc *PDClient) CheckHealth() error

CheckHealth checks the health of PD node

func (*PDClient) CheckRegion

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) GetConfig

func (pc *PDClient) GetConfig() (map[string]interface{}, error)

GetConfig returns all PD configs

func (*PDClient) GetCurrentStore

func (pc *PDClient) GetCurrentStore(addr string) (*StoreInfo, error)

GetCurrentStore gets the current store info of a given host

func (*PDClient) GetDashboardAddress

func (pc *PDClient) GetDashboardAddress() (string, error)

GetDashboardAddress get the PD node address which runs dashboard

func (*PDClient) GetLeader

func (pc *PDClient) GetLeader() (*pdpb.Member, error)

GetLeader queries the leader node of PD cluster

func (*PDClient) GetLocationLabels

func (pc *PDClient) GetLocationLabels() ([]string, error)

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

func (pc *PDClient) GetReplicateConfig() ([]byte, error)

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

func (pc *PDClient) GetTiKVLabels() (map[string]map[string]string, error)

GetTiKVLabels implements TiKVLabelProvider

func (*PDClient) GetURL

func (pc *PDClient) GetURL(addr string) string

GetURL builds the the client URL of PDClient

func (*PDClient) IsTombStone

func (pc *PDClient) IsTombStone(host string) (bool, error)

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

func (pc *PDClient) IsUp(host string) (bool, error)

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

func (pc *PDClient) RemoveStoreEvict(host string) error

RemoveStoreEvict removes a store leader evict scheduler, which allows following leaders to be transffered to it again.

func (*PDClient) SetAllStoreLimits

func (pc *PDClient) SetAllStoreLimits(value int) error

SetAllStoreLimits sets store for all stores and types, it has the same effect as `pd-ctl store limit all value`

func (*PDClient) SetReplicationConfig

func (pc *PDClient) SetReplicationConfig(key string, value int) error

SetReplicationConfig sets a config key value of PD replication, it has the same effect as `pd-ctl config set key value`

func (*PDClient) UpdateReplicateConfig

func (pc *PDClient) UpdateReplicateConfig(body io.Reader) error

UpdateReplicateConfig updates the PD replication config

func (*PDClient) UpdateScheduleConfig

func (pc *PDClient) UpdateScheduleConfig(body io.Reader) error

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

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

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

type RegionsInfo struct {
	Count   int           `json:"count"`
	Regions []*RegionInfo `json:"regions"`
}

RegionsInfo contains some regions with the detailed region info.

type ReplicationStatus

type ReplicationStatus struct {
	State   string `json:"state"`
	StateID uint64 `json:"state_id"`
}

ReplicationStatus represents the replication mode status of the region.

type StatusResp

type StatusResp struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

StatusResp represents the response of status api.

type StoreInfo

type StoreInfo struct {
	Store  *MetaStore   `json:"store"`
	Status *StoreStatus `json:"status"`
}

StoreInfo contains information about a store.

type StoreStatus

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

type StoresInfo struct {
	Count  int          `json:"count"`
	Stores []*StoreInfo `json:"stores"`
}

StoresInfo records stores' info.

Directories

Path Synopsis
Package pb is a reverse proxy.
Package pb is a reverse proxy.

Jump to

Keyboard shortcuts

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