pdapi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PdClientURL

func PdClientURL(namespace Namespace, clusterName string) string

pdClientUrl builds the url of pd client

Types

type Action

type Action struct {
	ID     uint64
	Name   string
	Labels map[string]string
}

type ActionType

type ActionType string
const (
	GetHealthActionType                ActionType = "GetHealth"
	GetConfigActionType                ActionType = "GetConfig"
	GetClusterActionType               ActionType = "GetCluster"
	GetMembersActionType               ActionType = "GetMembers"
	GetStoresActionType                ActionType = "GetStores"
	GetTombStoneStoresActionType       ActionType = "GetTombStoneStores"
	GetStoreActionType                 ActionType = "GetStore"
	DeleteStoreActionType              ActionType = "DeleteStore"
	DeleteMemberByIDActionType         ActionType = "DeleteMemberByID"
	DeleteMemberActionType             ActionType = "DeleteMember "
	SetStoreLabelsActionType           ActionType = "SetStoreLabels"
	BeginEvictLeaderActionType         ActionType = "BeginEvictLeader"
	EndEvictLeaderActionType           ActionType = "EndEvictLeader"
	GetEvictLeaderSchedulersActionType ActionType = "GetEvictLeaderSchedulers"
	GetPDLeaderActionType              ActionType = "GetPDLeader"
	TransferPDLeaderActionType         ActionType = "TransferPDLeader"
)

type FakePDClient

type FakePDClient struct {
	// contains filtered or unexported fields
}

func NewFakePDClient

func NewFakePDClient() *FakePDClient

func (*FakePDClient) AddReaction

func (pc *FakePDClient) AddReaction(actionType ActionType, reaction Reaction)

func (*FakePDClient) BeginEvictLeader

func (pc *FakePDClient) BeginEvictLeader(storeID uint64) error

func (*FakePDClient) DeleteMember

func (pc *FakePDClient) DeleteMember(name string) error

func (*FakePDClient) DeleteMemberByID

func (pc *FakePDClient) DeleteMemberByID(id uint64) error

func (*FakePDClient) DeleteStore

func (pc *FakePDClient) DeleteStore(id uint64) error

func (*FakePDClient) EndEvictLeader

func (pc *FakePDClient) EndEvictLeader(storeID uint64) error

func (*FakePDClient) GetCluster

func (pc *FakePDClient) GetCluster() (*metapb.Cluster, error)

func (*FakePDClient) GetConfig

func (pc *FakePDClient) GetConfig() (*server.Config, error)

func (*FakePDClient) GetEvictLeaderSchedulers

func (pc *FakePDClient) GetEvictLeaderSchedulers() ([]string, error)

func (*FakePDClient) GetHealth

func (pc *FakePDClient) GetHealth() (*HealthInfo, error)

func (*FakePDClient) GetMembers

func (pc *FakePDClient) GetMembers() (*MembersInfo, error)

func (*FakePDClient) GetPDLeader

func (pc *FakePDClient) GetPDLeader() (*pdpb.Member, error)

func (*FakePDClient) GetStore

func (pc *FakePDClient) GetStore(id uint64) (*StoreInfo, error)

func (*FakePDClient) GetStores

func (pc *FakePDClient) GetStores() (*StoresInfo, error)

func (*FakePDClient) GetTombStoneStores

func (pc *FakePDClient) GetTombStoneStores() (*StoresInfo, error)

func (*FakePDClient) SetStoreLabels

func (pc *FakePDClient) SetStoreLabels(storeID uint64, labels map[string]string) (bool, error)

SetStoreLabels sets TiKV labels

func (*FakePDClient) TransferPDLeader

func (pc *FakePDClient) TransferPDLeader(memberName string) error

type FakePDControl

type FakePDControl struct {
	// contains filtered or unexported fields
}

func NewFakePDControl

func NewFakePDControl() *FakePDControl

func (*FakePDControl) GetPDClient

func (pdc *FakePDControl) GetPDClient(namespace Namespace, tcName string) PDClient

GetPDClient provides a PDClient of real pd cluster,if the PDClient not existing, it will create new one.

func (*FakePDControl) SetPDClient

func (fpc *FakePDControl) SetPDClient(namespace Namespace, tcName string, pdclient PDClient)

type HealthInfo

type HealthInfo struct {
	Healths []MemberHealth
}

HealthInfo define PD's healthy info

type MemberHealth

type MemberHealth struct {
	Name       string   `json:"name"`
	MemberID   uint64   `json:"member_id"`
	ClientUrls []string `json:"client_urls"`
	Health     bool     `json:"health"`
}

MemberHealth define a pd member's healthy info

type MembersInfo

type MembersInfo struct {
	Header     *pdpb.ResponseHeader `json:"header,omitempty"`
	Members    []*pdpb.Member       `json:"members,omitempty"`
	Leader     *pdpb.Member         `json:"leader,omitempty"`
	EtcdLeader *pdpb.Member         `json:"etcd_leader,omitempty"`
}

MembersInfo is PD members info returned from PD RESTful interface type Members map[string][]*pdpb.Member

type MetaStore

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

MetaStore is TiKV store status defined in protobuf

type Namespace

type Namespace string

Namespace is a newtype of a string

type NotFoundReaction

type NotFoundReaction struct {
	// contains filtered or unexported fields
}

func (*NotFoundReaction) Error

func (nfr *NotFoundReaction) Error() string

type PDClient

type PDClient interface {
	// GetHealth returns the PD's health info
	GetHealth() (*HealthInfo, error)
	// GetConfig returns PD's config
	GetConfig() (*server.Config, error)
	// GetCluster returns used when syncing pod labels.
	GetCluster() (*metapb.Cluster, error)
	// GetMembers returns all PD members from cluster
	GetMembers() (*MembersInfo, error)
	// GetStores lists all TiKV stores from cluster
	GetStores() (*StoresInfo, error)
	// GetTombStoneStores lists all tombstone stores from cluster
	GetTombStoneStores() (*StoresInfo, error)
	// GetStore gets a TiKV store for a specific store id from cluster
	GetStore(storeID uint64) (*StoreInfo, error)
	// storeLabelsEqualNodeLabels compares store labels with node labels
	// for historic reasons, PD stores TiKV labels as []*StoreLabel which is a key-value pair slice
	SetStoreLabels(storeID uint64, labels map[string]string) (bool, error)
	// DeleteStore deletes a TiKV store from cluster
	DeleteStore(storeID uint64) error
	// DeleteMember deletes a PD member from cluster
	DeleteMember(name string) error
	// DeleteMemberByID deletes a PD member from cluster
	DeleteMemberByID(memberID uint64) error
	// BeginEvictLeader initiates leader eviction for a storeID.
	// This is used when upgrading a pod.
	BeginEvictLeader(storeID uint64) error
	// EndEvictLeader is used at the end of pod upgrade.
	EndEvictLeader(storeID uint64) error
	// GetEvictLeaderSchedulers gets schedulers of evict leader
	GetEvictLeaderSchedulers() ([]string, error)
	// GetPDLeader returns pd leader
	GetPDLeader() (*pdpb.Member, error)
	// TransferPDLeader transfers pd leader to specified member
	TransferPDLeader(name string) error
}

PDClient provides pd server's api

func NewPDClient

func NewPDClient(url string, timeout time.Duration) PDClient

NewPDClient returns a new PDClient

type PDControlInterface

type PDControlInterface interface {
	// GetPDClient provides PDClient of the tidb cluster.
	GetPDClient(Namespace, string) PDClient
}

PDControlInterface is an interface that knows how to manage and get tidb cluster's PD client

func NewDefaultPDControl

func NewDefaultPDControl() PDControlInterface

NewDefaultPDControl returns a defaultPDControl instance

type Reaction

type Reaction func(action *Action) (interface{}, error)

type StoreInfo

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

StoreInfo is a single store info returned from PD RESTful interface

type StoreStatus

type StoreStatus struct {
	Capacity           typeutil.ByteSize `json:"capacity"`
	Available          typeutil.ByteSize `json:"available"`
	LeaderCount        int               `json:"leader_count"`
	RegionCount        int               `json:"region_count"`
	SendingSnapCount   uint32            `json:"sending_snap_count"`
	ReceivingSnapCount uint32            `json:"receiving_snap_count"`
	ApplyingSnapCount  uint32            `json:"applying_snap_count"`
	IsBusy             bool              `json:"is_busy"`

	StartTS         time.Time         `json:"start_ts"`
	LastHeartbeatTS time.Time         `json:"last_heartbeat_ts"`
	Uptime          typeutil.Duration `json:"uptime"`
}

StoreStatus is TiKV store status returned from PD RESTful interface

type StoresInfo

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

StoresInfo is stores info returned from PD RESTful interface

Jump to

Keyboard shortcuts

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