pdapi

package
v0.0.0-...-f0aa2c5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CodeSuccess success code
	CodeSuccess = 0
	// CodeError error code
	CodeError = 1
)
View Source
const (
	// APIPrefix url prefix for api
	APIPrefix = "/pd"
)

Variables

This section is empty.

Functions

func NewAPIHandler

func NewAPIHandler(service Service) http.Handler

NewAPIHandler returns a HTTP handler for API.

Types

type CellInfo

type CellInfo struct {
	Meta         metapb.Cell      `json:"meta"`
	LeaderPeer   *metapb.Peer     `json:"leader"`
	DownPeers    []pdpb.PeerStats `json:"downPeers"`
	PendingPeers []metapb.Peer    `json:"pendingPeers"`
}

CellInfo The cell info

type InitParams

type InitParams struct {
	InitCellCount uint64 `json:"initCellCount"`
	CellCapacity  uint64 `json:"cellCapacity"`
}

InitParams initialize the elasticell cluster

func (*InitParams) Marshal

func (p *InitParams) Marshal() (string, error)

Marshal marshal

type Result

type Result struct {
	Code  int         `json:"code"`
	Error string      `json:"error, omitempty"`
	Value interface{} `json:"value, omitempty"`
}

Result is the return value of api server

type Service

type Service interface {
	Name() string
	IsLeader() bool
	GetLeader() (*pdpb.Leader, error)

	GetSystem() (*System, error)
	InitCluster(params *InitParams) error

	ListStore() ([]*StoreInfo, error)
	GetStore(id uint64) (*StoreInfo, error)
	DeleteStore(id uint64, force bool) error
	SetStoreLogLevel(set *SetLogLevel) error

	ListCellInStore(storeID uint64) ([]*CellInfo, error)
	ListCell() ([]*CellInfo, error)
	GetCell(id uint64) (*CellInfo, error)
	TransferLeader(transfer *TransferLeader) error
	GetOperator(id uint64) (interface{}, error)

	GetOperators() ([]interface{}, error)

	ListIndex() ([]*pdpb.IndexDef, error)
	GetIndex(id string) (*pdpb.IndexDef, error)
	CreateIndex(idxDef *pdpb.IndexDef) error
	DeleteIndex(id string) error
}

Service service interface

type SetLogLevel

type SetLogLevel struct {
	Targets []uint64 `json:"targets"`
	Level   int32    `json:"level"`
}

SetLogLevel set log level for components

type StoreInfo

type StoreInfo struct {
	Meta   metapb.Store `json:"meta"`
	Status *StoreStatus `json:"status"`
}

StoreInfo store info

type StoreStatus

type StoreStatus struct {
	Stats           *pdpb.StoreStats `json:"stats"`
	LeaderCount     uint32           `json:"leaderCount"`
	LastHeartbeatTS int64            `json:"lastHeartbeatTS"`
}

StoreStatus store status

type System

type System struct {
	AlreadyBootstrapped bool        `json:"alreadyBootstrapped"`
	InitParams          *InitParams `json:"initParams, omitempty"`

	MaxReplicas uint32 `json:"maxReplicas, omitempty"`

	StoreCount          int `json:"storeCount, omitempty"`
	OfflineStoreCount   int `json:"offlineStoreCount, omitempty"`
	TombStoneStoreCount int `json:"tombStoneStoreCount, omitempty"`

	CellCount                int `json:"cellCount, omitempty"`
	ReplicasNotFullCellCount int `json:"replicasNotFullCellCount, omitempty"`

	StorageCapacity  uint64 `json:"storageCapacity, omitempty"`
	StorageAvailable uint64 `json:"storageAvailable, omitempty"`

	OperatorCount int `json:"operatorCount, omitempty"`
}

System The system info of the elasticell cluster

type TransferLeader

type TransferLeader struct {
	CellID   uint64 `json:"cellId"`
	ToPeerID uint64 `json:"toPeerId"`
}

TransferLeader transfer leader to spec peer

Jump to

Keyboard shortcuts

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