Documentation ¶
Overview ¶
Copyright 2016 PingCAP, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func ColumnParse(cols []string) ([]*metapb.Column, error)
- func EditProperties(properties string) ([]*metapb.Column, error)
- func GetTypeByName(name string) metapb.DataType
- func NewBalanceNodeOpsWorker(wm *WorkerManager, interval time.Duration) *balanceNodeOpsWorker
- func NewBalanceNodeRangeWorker(wm *WorkerManager, interval time.Duration) *balanceNodeRangeWorker
- func NewHBRangeManager(cluster *Cluster) *hb_range_manager
- func NewHandler(valid ValidHandler, handler HttpHandler) server.ServiceHttpHandler
- func NewIDGenerator(key []byte, step uint64, store Store) *idGenerator
- func ParseProperties(properties string) ([]*metapb.Column, []*metapb.Column, error)
- func ScopeSplit(a, b []byte, n uint64, charSet []byte) ([][]byte, error)
- func SelectMostAndLeastLeaderNode(nodes []*Node, selectors []NodeSelector) (*Node, *Node)
- func SelectMostAndLeastRangeNode(opt *scheduleOption, nodes []*Node, selectors []NodeSelector) (*Node, *Node, bool)
- func SqlParse(_sql string) (t *metapb.Table, err error)
- func ToTableProperty(cols []*metapb.Column) (string, error)
- func UpdateMetric(cluster *Cluster, addr string, interval time.Duration) error
- type AddPeerTask
- type AlarmConfig
- type AlarmReceiver
- type BaseTask
- func (t *BaseTask) AllowFail() bool
- func (t *BaseTask) CheckOver() bool
- func (t *BaseTask) Elapsed() time.Duration
- func (t *BaseTask) GetState() TaskState
- func (t *BaseTask) GetType() TaskType
- func (t *BaseTask) SetAllowFail()
- func (t *BaseTask) SetBegin()
- func (t *BaseTask) SetLogID(id string)
- func (t *BaseTask) String() string
- type Batch
- type ByLetter
- type ByPrimaryKey
- type ChangeLeaderTask
- type Cluster
- func (c *Cluster) AddBalanceLeaderWorker()
- func (c *Cluster) AddBalanceNodeOpsWorker()
- func (c *Cluster) AddBalanceRangeWorker()
- func (c *Cluster) AddCreateTableWorker()
- func (c *Cluster) AddDeleteTableWorker()
- func (c *Cluster) AddFailoverWorker()
- func (c *Cluster) AddNode(node *Node) error
- func (c *Cluster) AddRange(r *Range)
- func (c *Cluster) AddRangeHbCheckWorker()
- func (c *Cluster) AddTrashReplicaGCWorker()
- func (c *Cluster) CancelTable(dbName, tName string) error
- func (c *Cluster) Close()
- func (c *Cluster) CreateDatabase(name string, properties string) (*Database, error)
- func (c *Cluster) CreateTable(dbName, tableName string, columns, regxs []*metapb.Column, pkDupCheck bool, ...) (*Table, error)
- func (c *Cluster) DeleteDatabase(name string) error
- func (c *Cluster) DeleteNodeByAddr(addr string) error
- func (c *Cluster) DeleteNodeById(id uint64) error
- func (c *Cluster) DeleteRange(rangeId uint64)
- func (c *Cluster) DeleteTable(dbName, tableName string, fast bool) (*Table, error)
- func (c *Cluster) Dispatch(r *Range) *taskpb.Task
- func (c *Cluster) EditTable(t *Table, properties string) error
- func (c *Cluster) FindDatabase(name string) (*Database, bool)
- func (c *Cluster) FindDatabaseById(id uint64) (*Database, bool)
- func (c *Cluster) FindDeleteTableById(tableId uint64) (*Table, bool)
- func (c *Cluster) FindNodeByAddr(addr string) *Node
- func (c *Cluster) FindNodeById(id uint64) *Node
- func (c *Cluster) FindPreGCRangeById(rangeId uint64) (*metapb.Range, bool)
- func (c *Cluster) FindRange(id uint64) *Range
- func (c *Cluster) FindTableById(tableId uint64) (*Table, bool)
- func (c *Cluster) GenId() (uint64, error)
- func (c *Cluster) GetAllActiveNode() []*Node
- func (c *Cluster) GetAllDatabase() []*Database
- func (c *Cluster) GetAllNode() []*Node
- func (c *Cluster) GetAllRanges() []*Range
- func (c *Cluster) GetAllTasks() []*TaskChain
- func (c *Cluster) GetAllUnhealthyRanges() []*Range
- func (c *Cluster) GetAllUnstableRanges() []*Range
- func (c *Cluster) GetAllWorker() map[string]bool
- func (c *Cluster) GetClusterId() uint64
- func (c *Cluster) GetLeader() *Peer
- func (c *Cluster) GetNodeId(serverAddr, raftAddr, httpAddr, version string) (*Node, bool, error)
- func (c *Cluster) GetNodeRangeStatByTable(tableId uint64) map[uint64]int
- func (c *Cluster) GetTableAllRanges(tableId uint64) []*Range
- func (c *Cluster) GetWorkerInfo(workerName string) string
- func (c *Cluster) IsLeader() bool
- func (c *Cluster) LoadCache() error
- func (c *Cluster) LoginNode(nodeId uint64, force bool) error
- func (c *Cluster) LogoutNode(nodeId uint64) error
- func (c *Cluster) MultipleSearchRanges(key []byte, num int) []*Range
- func (c *Cluster) NodeLogin(nodeId uint64) error
- func (c *Cluster) NodeUpgrade(nodeID uint64) error
- func (c *Cluster) RemoveWorker(name string) error
- func (c *Cluster) ReplaceRange(old *metapb.Range, new *Range, toGc []*metapb.Peer)
- func (c *Cluster) ReplaceRangeRemote(addr string, oldRangeId uint64, newRange *metapb.Range) error
- func (c *Cluster) SearchRange(key []byte) *Range
- func (c *Cluster) Start()
- func (c *Cluster) StoreMetricConfig(m *MetricConfig) error
- func (c *Cluster) UpdateAutoScheduleInfo(autoFailoverUnable, autoTransferUnable, autoSplitUnable bool) error
- func (c *Cluster) UpdateLeader(leader *Peer)
- func (c *Cluster) UpdateNode(node *Node) error
- func (c *Cluster) UpdateNodeState(n *Node, state metapb.NodeState) error
- func (c *Cluster) UpdateRangeEpochRemote(r *Range, epoch *metapb.RangeEpoch) error
- func (c *Cluster) UpdateRangeRemote(addr string, r *metapb.Range) error
- func (c *Cluster) UpgradeNode(nodeId uint64) error
- type ClusterConfig
- type ClusterIDGenerator
- type ClusterPeer
- type Config
- type CreateTable
- type CreateTableCache
- type CreateTableWorker
- type Database
- func (db *Database) AddTable(t *Table)
- func (db *Database) DeleteTableById(id uint64) error
- func (db *Database) DeleteTableByName(name string) error
- func (db *Database) FindTable(name string) (*Table, bool)
- func (db *Database) FindTableById(id uint64) (*Table, bool)
- func (db *Database) GetAllTable() []*Table
- func (db *Database) Lock()
- func (db *Database) Name() string
- func (db *Database) UnLock()
- type DbCache
- type DeletePeerTask
- type DeleteRangeTask
- type DeleteTableWorker
- type DifferCacheNodeSelector
- type DifferIPSelector
- type DifferNodeSelector
- type Distribution
- type Distributions
- type DownPeer
- type FailoverWorker
- type GlobalDeletedRange
- type GlobalPreGCRange
- type GlobalTableCache
- type HbRingBuf
- type HttpHandler
- type HttpReply
- type IDGenerator
- type Iterator
- type LevelDBBatch
- type LevelDBDriver
- func (ld *LevelDBDriver) Close() error
- func (ld *LevelDBDriver) Delete(key []byte) error
- func (ld *LevelDBDriver) Get(key []byte) (value []byte, err error)
- func (ld *LevelDBDriver) NewBatch() Batch
- func (ld *LevelDBDriver) Open() error
- func (ld *LevelDBDriver) Put(key []byte, value []byte) error
- func (ld *LevelDBDriver) Scan(startKey, endKey []byte) Iterator
- type LevelDBIter
- type LocalDSClient
- func (lc *LocalDSClient) Close() error
- func (lc *LocalDSClient) CreateRange(addr string, r *metapb.Range) error
- func (lc *LocalDSClient) DeleteRange(addr string, rangeId uint64) error
- func (lc *LocalDSClient) GetPeerInfo(addr string, rangeId uint64) (*schpb.GetPeerInfoResponse, error)
- func (lc *LocalDSClient) OffLineRange(addr string, rangeId uint64) error
- func (lc *LocalDSClient) ReplaceRange(addr string, oldRangeId uint64, newRange *metapb.Range) error
- func (lc *LocalDSClient) SetNodeLogLevel(addr string, level string) error
- func (lc *LocalDSClient) TransferLeader(addr string, rangeId uint64) error
- func (lc *LocalDSClient) UpdateRange(addr string, r *metapb.Range) error
- type LogConfig
- type Member
- type Metric
- type MetricConfig
- type MetricServer
- type MockDs
- type Node
- func (n *Node) AddRange(r *Range)
- func (n *Node) AddTrashReplica(peer *metapb.Replica)
- func (n *Node) DeleteRange(rangeId uint64)
- func (n *Node) DeleteTrashReplica(id uint64)
- func (n *Node) GetAllRanges() []*Range
- func (n *Node) GetAllTrashRangeIds() []uint64
- func (n *Node) GetAllTrashReplicas() []*metapb.Replica
- func (n *Node) GetApplyingSnapCount() uint32
- func (n *Node) GetLeaderCount() uint32
- func (n *Node) GetRange(id uint64) (*Range, bool)
- func (n *Node) GetRangesCount() uint32
- func (n *Node) GetRangesSize() int
- func (n *Node) GetReceivingSnapCount() uint32
- func (n *Node) GetSendingSnapCount() uint32
- func (n *Node) GetStartTS() time.Time
- func (n *Node) GetUptime() time.Duration
- func (n *Node) ID() uint64
- func (n *Node) IsBusy() bool
- func (n *Node) IsDown() bool
- func (n *Node) IsFault() bool
- func (n *Node) IsLogin() bool
- func (n *Node) IsLogout() bool
- func (n *Node) UpdateState(state metapb.NodeState)
- type NodeCache
- func (nc *NodeCache) Add(n *Node)
- func (nc *NodeCache) DeleteByAddr(addr string)
- func (nc *NodeCache) DeleteById(id uint64)
- func (nc *NodeCache) FindNodeByAddr(addr string) (*Node, bool)
- func (nc *NodeCache) FindNodeById(id uint64) (*Node, bool)
- func (nc *NodeCache) GetAllActiveNode() []*Node
- func (nc *NodeCache) GetAllNode() []*Node
- func (nc *NodeCache) Size() int
- type NodeDebug
- type NodeLoginSelector
- type NodeOpsStat
- type NodeSelector
- type Peer
- type Proxy
- type RaftConfig
- type RaftStore
- func (s *RaftStore) ApplySnapshot(iter *raftgroup.SnapshotKVIterator) error
- func (s *RaftStore) Close() error
- func (s *RaftStore) Delete(key []byte) error
- func (s *RaftStore) Get(key []byte) ([]byte, error)
- func (s *RaftStore) GetSnapshot() (model.Snapshot, error)
- func (s *RaftStore) HandleApplySnapshot(peers []raftproto.Peer, iter *raftgroup.SnapshotKVIterator) error
- func (s *RaftStore) HandleCmd(req *ms_raftcmdpb.Request, raftIndex uint64) (resp *ms_raftcmdpb.Response, err error)
- func (s *RaftStore) HandleGetSnapshot() (model.Snapshot, error)
- func (s *RaftStore) HandlePeerChange(confChange *raftproto.ConfChange) (res interface{}, err error)
- func (s *RaftStore) NewBatch() Batch
- func (s *RaftStore) Open() error
- func (s *RaftStore) Put(key, value []byte) error
- func (s *RaftStore) Scan(startKey, limitKey []byte) Iterator
- type Range
- func (r *Range) GetDownPeer(peerID uint64) *DownPeer
- func (r *Range) GetDownPeers() []*DownPeer
- func (r *Range) GetFollowers() map[uint64]*metapb.Peer
- func (r *Range) GetLeader() *metapb.Peer
- func (r *Range) GetNodeIds() map[uint64]struct{}
- func (r *Range) GetNodePeer(nodeID uint64) *metapb.Peer
- func (r *Range) GetNodes(cluster *Cluster) (nodes []*Node)
- func (r *Range) GetPeer(peerID uint64) *metapb.Peer
- func (r *Range) GetPendingPeer(peerID uint64) *metapb.Peer
- func (r *Range) GetPendingPeers() []*metapb.Peer
- func (r *Range) GetRandomFollower() *metapb.Peer
- func (r *Range) GetStatus(peerID uint64) *mspb.PeerStatus
- func (r *Range) ID() uint64
- func (r *Range) IsHealthy() bool
- func (r *Range) RemoveNodePeer(NodeID uint64)
- func (r *Range) SString() string
- type RangeCache
- func (rc *RangeCache) Add(r *Range)
- func (rc *RangeCache) Delete(id uint64) *Range
- func (rc *RangeCache) FindRangeByID(id uint64) (*Range, bool)
- func (rc *RangeCache) GetAllRange() []*Range
- func (rc *RangeCache) GetAllRangeFromTopology() []*metapb.Range
- func (rc *RangeCache) GetRandomRange() *Range
- func (rc *RangeCache) GetTableAllRanges(tableId uint64) []*Range
- func (rc *RangeCache) GetTableAllRangesFromTopology(tableId uint64) []*metapb.Range
- func (rc *RangeCache) GetTableRangeDuplicate(tableId uint64) []*metapb.Range
- func (rc *RangeCache) GetTableTopologyMissing(tableId uint64) []*metapb.Range
- func (rc *RangeCache) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)
- func (rc *RangeCache) SearchRange(key []byte) (*Range, bool)
- func (rc *RangeCache) Size() int
- type RangeDebug
- type RangeHbCheckWorker
- type RangeOpsStat
- type RegionCache
- type ReplicaCache
- func (rc *ReplicaCache) Add(peer *metapb.Replica)
- func (rc *ReplicaCache) Delete(id uint64)
- func (rc *ReplicaCache) FindReplica(id uint64) (*metapb.Replica, bool)
- func (rc *ReplicaCache) GetAllRangIds() []uint64
- func (rc *ReplicaCache) GetAllReplica() []*metapb.Replica
- func (rc *ReplicaCache) Size() int
- type ReplicationConfig
- type Resolver
- type RunMode
- type SaveBatch
- type ScheduleConfig
- type Server
- func (service *Server) AddColumn(ctx context.Context, req *mspb.AddColumnRequest) (*mspb.AddColumnResponse, error)
- func (service *Server) AskSplit(ctx context.Context, req *mspb.AskSplitRequest) (*mspb.AskSplitResponse, error)
- func (service *Server) CreateDatabase(ctx context.Context, req *mspb.CreateDatabaseRequest) (*mspb.CreateDatabaseResponse, error)
- func (service *Server) CreateTable(ctx context.Context, req *mspb.CreateTableRequest) (*mspb.CreateTableResponse, error)
- func (service *Server) GetColumnById(ctx context.Context, req *mspb.GetColumnByIdRequest) (*mspb.GetColumnByIdResponse, error)
- func (service *Server) GetColumnByName(ctx context.Context, req *mspb.GetColumnByNameRequest) (*mspb.GetColumnByNameResponse, error)
- func (service *Server) GetColumns(ctx context.Context, req *mspb.GetColumnsRequest) (*mspb.GetColumnsResponse, error)
- func (service *Server) GetDB(ctx context.Context, req *mspb.GetDBRequest) (*mspb.GetDBResponse, error)
- func (service *Server) GetLeader() *Peer
- func (service *Server) GetMSLeader(ctx context.Context, req *mspb.GetMSLeaderRequest) (*mspb.GetMSLeaderResponse, error)
- func (service *Server) GetNode(ctx context.Context, req *mspb.GetNodeRequest) (*mspb.GetNodeResponse, error)
- func (service *Server) GetNodeId(ctx context.Context, req *mspb.GetNodeIdRequest) (*mspb.GetNodeIdResponse, error)
- func (service *Server) GetRoute(ctx context.Context, req *mspb.GetRouteRequest) (*mspb.GetRouteResponse, error)
- func (service *Server) GetTable(ctx context.Context, req *mspb.GetTableRequest) (*mspb.GetTableResponse, error)
- func (service *Server) GetTableById(ctx context.Context, req *mspb.GetTableByIdRequest) (*mspb.GetTableByIdResponse, error)
- func (service *Server) InitAlarmServer(conf AlarmConfig) (err error)
- func (service *Server) InitMasterServer(conf *Config)
- func (service *Server) InitMetricServer(conf *Config)
- func (service *Server) InitServer(conf *Config)
- func (service *Server) IsLeader() bool
- func (service *Server) MasterStart()
- func (service *Server) MetricStart()
- func (service *Server) NodeHeartbeat(ctx context.Context, req *mspb.NodeHeartbeatRequest) (*mspb.NodeHeartbeatResponse, error)
- func (service *Server) NodeLogin(ctx context.Context, req *mspb.NodeLoginRequest) (*mspb.NodeLoginResponse, error)
- func (service *Server) ParseClusterInfo() []*Peer
- func (service *Server) Quit()
- func (service *Server) RaftLeaderChange(leaderId uint64)
- func (service *Server) RangeHeartbeat(ctx context.Context, req *mspb.RangeHeartbeatRequest) (*mspb.RangeHeartbeatResponse, error)
- func (service *Server) ReportSplit(ctx context.Context, req *mspb.ReportSplitRequest) (*mspb.ReportSplitResponse, error)
- func (service *Server) Start() error
- func (service *Server) TruncateTable(context.Context, *mspb.TruncateTableRequest) (*mspb.TruncateTableResponse, error)
- type SignHandler
- type SnapshotCountLimitSelector
- type StorageThresholdSelector
- type Store
- type StoreConfig
- type Table
- func (t *Table) GenColId() uint64
- func (t *Table) GetColumnById(id uint64) (*metapb.Column, bool)
- func (t *Table) GetColumnByName(name string) (*metapb.Column, bool)
- func (t *Table) GetColumns() []*metapb.Column
- func (t *Table) GetPkColumns() []*metapb.Column
- func (t *Table) MergeColumn(source []*metapb.Column, cluster *Cluster) error
- func (t *Table) Name() string
- func (t *Table) UpdateSchema(columns []*metapb.Column, store Store) ([]*metapb.Column, error)
- type TableCache
- func (tc *TableCache) Add(t *Table)
- func (tc *TableCache) DeleteById(id uint64)
- func (tc *TableCache) DeleteByName(name string)
- func (tc *TableCache) FindTableById(id uint64) (*Table, bool)
- func (tc *TableCache) FindTableByName(name string) (*Table, bool)
- func (tc *TableCache) GetAllTable() []*Table
- func (tc *TableCache) Size() int
- type TableProperty
- type Task
- type TaskChain
- func (c *TaskChain) Elapsed() time.Duration
- func (c *TaskChain) GetID() uint64
- func (c *TaskChain) GetLogID() string
- func (c *TaskChain) GetName() string
- func (c *TaskChain) GetRangeID() uint64
- func (c *TaskChain) Next(cluster *Cluster, r *Range) (over bool, task *taskpb.Task)
- func (c *TaskChain) String() string
- type TaskManager
- type TaskState
- type TaskType
- type TrashReplicaGCWorker
- type ValidHandler
- type Worker
- func NewBalanceNodeLeaderWorker(wm *WorkerManager, interval time.Duration) Worker
- func NewCreateTableWorker(wm *WorkerManager, interval time.Duration) Worker
- func NewDeleteTableWorker(wm *WorkerManager, interval time.Duration) Worker
- func NewFailoverWorker(wm *WorkerManager, interval time.Duration) Worker
- func NewRangeHbCheckWorker(wm *WorkerManager, interval time.Duration) Worker
- func NewTrashReplicaGCWorker(wm *WorkerManager, interval time.Duration) Worker
- type WorkerManager
- type WriterOpsThresholdSelector
Constants ¶
const ( HTTP_OK = iota HTTP_ERROR HTTP_ERROR_PARAMETER_NOT_ENOUGH HTTP_ERROR_INVALID_PARAM HTTP_ERROR_DATABASE_FIND HTTP_ERROR_TABLE_FIND HTTP_ERROR_TABLE_DELETED HTTP_ERROR_RANGE_CREATE HTTP_ERROR_CLUSTER_HAS_NO_LEADER HTTP_ERROR_MASTER_IS_NOT_LEADER HTTP_ERROR_WRONG_SIGN HTTP_ERROR_SIGN_TIMEOUT HTTP_ERROR_INVALID_SIGNTIME HTTP_ERROR_RANGE_FIND HTTP_ERROR_RANGE_SPLIT HTTP_ERROR_DATABASE_EXISTED HTTP_ERROR_TASK_FIND HTTP_ERROR_CLUSTERID HTTP_ERROR_NODE_FIND HTTP_ERROR_RANGE_BUSY HTTP_ERROR_PEER_FIND )
const ( HTTP_DB_NAME = "dbName" HTTP_DB_ID = "dbId" HTTP_TABLE_NAME = "tableName" HTTP_TABLE_ID = "tableId" HTTP_CLUSTER_ID = "clusterId" HTTP_RANGE_ID = "rangeId" HTTP_NODE_ID = "nodeId" HTTP_NODE_IDS = "nodeIds" HTTP_PEER_ID = "peerId" HTTP_NAME = "name" HTTP_PROPERTIES = "properties" HTTP_PKDUPCHECK = "pkDupCheck" HTTP_RANGEKEYS_NUM = "rangeKeysNum" HTTP_RANGEKEYS_START = "rangeKeysStart" HTTP_RANGEKEYS_END = "rangeKeysEnd" HTTP_RANGEKEYS = "rangeKeys" HTTP_POLICY = "policy" HTTP_D = "d" HTTP_S = "s" HTTP_TOKEN = "token" HTTP_SQL = "sql" HTTP_SERVER_PORT = "serverPort" HTTP_RAFT_HEARTBEAT_PORT = "raftHeartbeatPort" HTTP_RAFT_REPLICA_PORT = "raftReplicaPort" HTTP_TASK_ID = "taskId" HTTP_TASK_IDS = "taskIds" HTTP_MACHINES = "machines" HTTP_CLUSTER_AUTO_SCHEDULE_INFO = "clusterAutoScheduleInfo" HTTP_AUTO_TRANSFER_UNABLE = "autoTransferUnable" HTTP_AUTO_FAILOVER_UNABLE = "autoFailoverUnable" HTTP_AUTO_SPLIT_UNABLE = "autoSplitUnable" HTTP_TABLE_AUTO_INFO = "tableAutoInfo" HTTP_FAST = "fast" HTTP_STARTKEY = "startKey" HTTP_ENDKEY = "endKey" )
const ( Min_leader_balance_num = 5 Min_leader_adjust_num = 50 )
const ( SUCCESS int32 = 0 ER_NOT_LEADER = 1 ER_SERVER_BUSY = 2 ER_SERVER_STOP = 3 ER_READ_ONLY = 4 ER_ENTITY_NOT_EXIT = 5 ER_UNKNOWN = 6 )
const ( KB uint64 = 1024 MB = 1024 * KB GB = 1024 * MB PB = 1024 * GB )
const CacheSize = 100
const DefaultConfig = `` /* 1623-byte string literal not displayed */
const DefaultFactor = 0.75
const (
ROUTE_SUBSCRIBE = "route_subscribe"
)
Variables ¶
var ( ERR_NO_SELECTED_NODE = errors.New("not selected node") ErrInternalError = errors.New("internal error") ErrGenID = errors.New("gen ID failed") ErrDupDatabase = errors.New("duplicate database") ErrDupTable = errors.New("duplicate table") ErrNotExistDatabase = errors.New("database not exist") ErrNotExistTable = errors.New("table not exist") ErrNotExistNode = errors.New("node not exist") ErrNotActiveNode = errors.New("node is not up") ErrNotExistRange = errors.New("range not exist") ErrExistsRange = errors.New("range exist") ErrNotExistPeer = errors.New("range peer not exist") ErrNotEnoughResources = errors.New("not enough resources") ErrInvalidParam = errors.New("invalid param") ErrInvalidColumn = errors.New("invalid column") ErrColumnNameTooLong = errors.New("column name is too long") ErrDupColumnName = errors.New("duplicate column name") ErrPkMustNotNull = errors.New("primary key must be not nullable") ErrMissingPk = errors.New("missing primary key") ErrPkMustNotSetDefaultValue = errors.New("primary key should not set defaultvalue") ErrNodeRejectNewPeer = errors.New("node reject new peer") ErrNodeBlocked = errors.New("node is blocked") ErrNodeStateConfused = errors.New("confused node state") ErrSchedulerExisted = errors.New("scheduler is existed") ErrSchedulerNotFound = errors.New("scheduler is not found") ErrWorkerExisted = errors.New("worker is existed") ErrWorkerNotFound = errors.New("worker is not found") ErrSqlReservedWord = errors.New("sql reserved word") ErrSQLSyntaxError = errors.New("Syntax error") ErrRangeMetaConflict = errors.New("range meta conflict") ErrNotFound = errors.New("entity not found") ErrNotAllowSplit = errors.New("not allow split") ErrNotCancel = errors.New("not allow cancel") ErrNotAllowDelete = errors.New("not allow delete") ErrRangeStatusErr = errors.New("range status is invalid") )
var ( DefaultMaxNodeDownTimeInterval time.Duration = 60 * time.Second DefaultMaxPeerDownTimeInterval time.Duration = 2 * 60 * time.Second // 大于一个调度周期+一个心跳周期,预留冗余 DefaultChangeLeaderTimeout time.Duration = time.Second * time.Duration(30) DefaultDelRangeTimeout time.Duration = time.Second * time.Duration(30) DefaultAddPeerTimeout time.Duration = time.Second * time.Duration(300) DefaultDelPeerTimeout time.Duration = time.Second * time.Duration(30) )
var ( DefaultFaultTimeout = time.Minute DefaultMaxBigTaskNum = 3 DefaultMaxTaskNum = 50 )
var ( Min_range_balance_num = 10 Min_range_adjust_num = 50 )
var ( // 单位是秒 DefaultDownTimeLimit = 60 * time.Second MaxDownReplicaTimeLimit = 5 * 60 * time.Second DefaultDsHearbeatInterval = 10 * time.Second DefaultDsRecoveryInterim = 5 * 60 * time.Second DefaultTimeFormat = "2006-01-02 15:04:05" // 大于一个调度周期+一个心跳周期,预留冗余 DefaultChangeLeaderTaskTimeout = time.Second * time.Duration(30) DefaultRangeDeleteTaskTimeout = time.Second * time.Duration(30) DefaultRangeAddPeerTaskTimeout = time.Second * time.Duration(300) DefaultRangeDelPeerTaskTimeout = time.Second * time.Duration(30) )
var AUTO_INCREMENT_ID string = fmt.Sprintf("$auto_increment_id")
var DefaultMaxSubmitTimeout time.Duration = time.Second * 60
var DefaultRaftLogCount uint64 = 10000
var DefaultRetentionTime = time.Hour * time.Duration(72)
var ErrUnknownCommandType = errors.New("unknown command type")
var (
MAX_COLUMN_NAME_LENGTH = 128
)
var PREFIX_AUTO_FAILOVER_TABLE string = fmt.Sprintf("$auto_failover_table_%d")
var PREFIX_AUTO_FAILOVER_UNABLE string = fmt.Sprintf("schema%sauto_failover_unable%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_AUTO_SPLIT_UNABLE string = fmt.Sprintf("schema%sauto_split_unable%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_AUTO_TRANSFER_TABLE string = fmt.Sprintf("$auto_transfer_table_%d")
var PREFIX_AUTO_TRANSFER_UNABLE string = fmt.Sprintf("schema%sauto_transfer_unable%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_DB string = fmt.Sprintf("schema%sdb%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_DELETED_RANGE string = fmt.Sprintf("schema%sdeleted_range%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_METRIC string = fmt.Sprintf("schema%smetric_send%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_NODE string = fmt.Sprintf("schema%snode%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_PRE_GC string = fmt.Sprintf("schema%spre_gc%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_RANGE string = fmt.Sprintf("schema%srange%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_REPLICA string = fmt.Sprintf("schema%sreplica%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_TABLE string = fmt.Sprintf("schema%stable%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var PREFIX_TASK string = fmt.Sprintf("schema%stask%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR)
var SCHEMA_SPLITOR string = " "
NOTE: prefix's first char must not be '\xff'
var SQLReservedWord = []string{}/* 424 elements not displayed */
Functions ¶
func GetTypeByName ¶
func NewBalanceNodeOpsWorker ¶
func NewBalanceNodeOpsWorker(wm *WorkerManager, interval time.Duration) *balanceNodeOpsWorker
func NewBalanceNodeRangeWorker ¶
func NewBalanceNodeRangeWorker(wm *WorkerManager, interval time.Duration) *balanceNodeRangeWorker
func NewHBRangeManager ¶
func NewHBRangeManager(cluster *Cluster) *hb_range_manager
func NewHandler ¶
func NewHandler(valid ValidHandler, handler HttpHandler) server.ServiceHttpHandler
func NewIDGenerator ¶
func ParseProperties ¶
func SelectMostAndLeastLeaderNode ¶
func SelectMostAndLeastLeaderNode(nodes []*Node, selectors []NodeSelector) (*Node, *Node)
* return:
the normal node of the most leader number the normal node of the least leader number
func SelectMostAndLeastRangeNode ¶
func SelectMostAndLeastRangeNode(opt *scheduleOption, nodes []*Node, selectors []NodeSelector) (*Node, *Node, bool)
* return:
the normal node of the most leader number or available ration low node the normal node of the least leader number
Types ¶
type AddPeerTask ¶ added in v0.6.3
type AddPeerTask struct { *BaseTask // contains filtered or unexported fields }
AddPeerTask add peer task
func NewAddPeerTask ¶ added in v0.6.3
func NewAddPeerTask() *AddPeerTask
NewAddPeerTask new add peer task
func (*AddPeerTask) String ¶ added in v0.6.3
func (t *AddPeerTask) String() string
type AlarmConfig ¶
type AlarmConfig struct { ServerAddress string `toml:"server-address" json:"server-address"` ServerPort int `toml:"server-port,omitempty" json:"port"` RemoteAlarmServerAddress string `toml:"remote-alarm-server-address,omitempty" json:"remote-alarm-server-address"` MessageGatewayAddress string `toml:"message-gateway-address,omitempty" json:"message-gateway-address"` Receivers []*AlarmReceiver `toml:"receivers,omitempty" json:"receivers"` }
type AlarmReceiver ¶
type BaseTask ¶ added in v0.6.3
type BaseTask struct {
// contains filtered or unexported fields
}
BaseTask include task's common attrs
func (*BaseTask) SetAllowFail ¶ added in v0.6.3
func (t *BaseTask) SetAllowFail()
SetAllowFail set allow to fail
type ByPrimaryKey ¶
func (ByPrimaryKey) Len ¶
func (s ByPrimaryKey) Len() int
func (ByPrimaryKey) Less ¶
func (s ByPrimaryKey) Less(i, j int) bool
func (ByPrimaryKey) Swap ¶
func (s ByPrimaryKey) Swap(i, j int)
type ChangeLeaderTask ¶ added in v0.6.3
type ChangeLeaderTask struct { *BaseTask // contains filtered or unexported fields }
ChangeLeaderTask change leader task
func NewChangeLeaderTask ¶ added in v0.6.3
func NewChangeLeaderTask(from, to uint64) *ChangeLeaderTask
NewChangeLeaderTask new change leader task
func (*ChangeLeaderTask) String ¶ added in v0.6.3
func (t *ChangeLeaderTask) String() string
type Cluster ¶
type Cluster struct {
// contains filtered or unexported fields
}
func NewCluster ¶
func (*Cluster) AddBalanceLeaderWorker ¶
func (c *Cluster) AddBalanceLeaderWorker()
func (*Cluster) AddBalanceNodeOpsWorker ¶
func (c *Cluster) AddBalanceNodeOpsWorker()
func (*Cluster) AddBalanceRangeWorker ¶
func (c *Cluster) AddBalanceRangeWorker()
func (*Cluster) AddCreateTableWorker ¶
func (c *Cluster) AddCreateTableWorker()
func (*Cluster) AddDeleteTableWorker ¶
func (c *Cluster) AddDeleteTableWorker()
func (*Cluster) AddFailoverWorker ¶
func (c *Cluster) AddFailoverWorker()
func (*Cluster) AddRangeHbCheckWorker ¶
func (c *Cluster) AddRangeHbCheckWorker()
func (*Cluster) AddTrashReplicaGCWorker ¶
func (c *Cluster) AddTrashReplicaGCWorker()
func (*Cluster) CancelTable ¶
func (*Cluster) CreateDatabase ¶
func (*Cluster) CreateTable ¶
func (c *Cluster) CreateTable(dbName, tableName string, columns, regxs []*metapb.Column, pkDupCheck bool, sliceKeys [][]byte) (*Table, error)
step 1. create table step 2. create range in remote step 3. add range in cache and disk
func (*Cluster) DeleteDatabase ¶
func (*Cluster) DeleteNodeByAddr ¶
func (*Cluster) DeleteRange ¶
func (*Cluster) DeleteTable ¶
func (*Cluster) FindDeleteTableById ¶
func (*Cluster) FindNodeByAddr ¶
func (*Cluster) FindNodeById ¶
func (*Cluster) FindPreGCRangeById ¶
func (*Cluster) GetAllActiveNode ¶
func (*Cluster) GetAllDatabase ¶
func (*Cluster) GetAllNode ¶
func (*Cluster) GetAllRanges ¶
func (*Cluster) GetAllTasks ¶ added in v0.6.3
GetAllTasks return all tasks
func (*Cluster) GetAllUnhealthyRanges ¶
func (*Cluster) GetAllUnstableRanges ¶
func (*Cluster) GetAllWorker ¶
func (*Cluster) GetClusterId ¶
func (*Cluster) GetNodeRangeStatByTable ¶
func (*Cluster) GetTableAllRanges ¶
func (*Cluster) GetWorkerInfo ¶
func (*Cluster) LogoutNode ¶
func (*Cluster) MultipleSearchRanges ¶
func (*Cluster) NodeUpgrade ¶
func (*Cluster) RemoveWorker ¶
func (*Cluster) ReplaceRange ¶
func (*Cluster) ReplaceRangeRemote ¶
func (*Cluster) SearchRange ¶
func (*Cluster) StoreMetricConfig ¶ added in v0.6.3
func (c *Cluster) StoreMetricConfig(m *MetricConfig) error
func (*Cluster) UpdateAutoScheduleInfo ¶
func (*Cluster) UpdateLeader ¶
func (*Cluster) UpdateNode ¶
func (*Cluster) UpdateNodeState ¶
func (*Cluster) UpdateRangeEpochRemote ¶
func (c *Cluster) UpdateRangeEpochRemote(r *Range, epoch *metapb.RangeEpoch) error
func (*Cluster) UpdateRangeRemote ¶
func (*Cluster) UpgradeNode ¶
type ClusterConfig ¶
type ClusterConfig struct { ClusterID uint64 `toml:"cluster-id,omitempty" json:"cluster-id"` Peers []*ClusterPeer `toml:"peer,omitempty" json:"peer"` }
type ClusterIDGenerator ¶
type ClusterIDGenerator struct {
// contains filtered or unexported fields
}
type ClusterPeer ¶
type Config ¶
type Config struct { Name string `toml:"name,omitempty" json:"name"` NodeId uint64 `toml:"node-id,omitempty" json:"node-id"` Role string `toml:"role,omitempty" json:"role"` Version string `toml:"version,omitempty" json:"version"` SecretKey string `toml:"secret-key,omitempty" json:"secret-key"` DataPath string `toml:"data-dir,omitempty" json:"data-dir"` Cluster ClusterConfig `toml:"cluster,omitempty" json:"cluster"` Raft RaftConfig `toml:"raft,omitempty" json:"raft"` Schedule ScheduleConfig `toml:"schedule,omitempty" json:"schedule"` Replication ReplicationConfig `toml:"replication,omitempty" json:"replication"` Log LogConfig `toml:"log,omitempty" json:"log"` Metric MetricConfig `toml:"metric,omitempty" json:"metric"` Threshold metric.ThresholdConfig `toml:"threshold,omitempty" json:"threshold"` Alarm AlarmConfig `toml:"alarm,omitempty" json:"alarm"` // contains filtered or unexported fields }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
func (*Config) LoadFromFile ¶
type CreateTable ¶
func NewCreateTable ¶
func NewCreateTable(t *Table, n uint64) *CreateTable
func (*CreateTable) AddRange ¶
func (t *CreateTable) AddRange(r *Range)
func (*CreateTable) DeleteRange ¶
func (t *CreateTable) DeleteRange(rangeID uint64)
func (*CreateTable) GetAllRanges ¶
func (t *CreateTable) GetAllRanges() []*Range
type CreateTableCache ¶
type CreateTableCache struct {
// contains filtered or unexported fields
}
func NewCreateTableCache ¶
func NewCreateTableCache() *CreateTableCache
func (*CreateTableCache) Add ¶
func (tc *CreateTableCache) Add(t *CreateTable)
func (*CreateTableCache) Delete ¶
func (tc *CreateTableCache) Delete(id uint64)
func (*CreateTableCache) FindTable ¶
func (tc *CreateTableCache) FindTable(id uint64) (*CreateTable, bool)
func (*CreateTableCache) GetAllTable ¶
func (tc *CreateTableCache) GetAllTable() []*CreateTable
func (*CreateTableCache) Size ¶
func (tc *CreateTableCache) Size() int
type CreateTableWorker ¶
type CreateTableWorker struct {
// contains filtered or unexported fields
}
func (*CreateTableWorker) AllowWork ¶
func (dt *CreateTableWorker) AllowWork(cluster *Cluster) bool
func (*CreateTableWorker) GetInterval ¶
func (dt *CreateTableWorker) GetInterval() time.Duration
func (*CreateTableWorker) GetName ¶
func (dt *CreateTableWorker) GetName() string
func (*CreateTableWorker) Stop ¶
func (dt *CreateTableWorker) Stop()
func (*CreateTableWorker) Work ¶
func (dt *CreateTableWorker) Work(c *Cluster)
type Database ¶
func NewDatabase ¶
func (*Database) DeleteTableByName ¶
仅仅从当前table列表中删除
func (*Database) FindTableById ¶
查找存在的table
func (*Database) GetAllTable ¶
type DbCache ¶
type DbCache struct {
// contains filtered or unexported fields
}
func NewDbCache ¶
func NewDbCache() *DbCache
func (*DbCache) GetAllDatabase ¶
type DeletePeerTask ¶ added in v0.6.3
type DeletePeerTask struct { *BaseTask // contains filtered or unexported fields }
DeletePeerTask delete peer task
func NewDeletePeerTask ¶ added in v0.6.3
func NewDeletePeerTask(peer *metapb.Peer) *DeletePeerTask
NewDeletePeerTask new delete peer task
func (*DeletePeerTask) String ¶ added in v0.6.3
func (t *DeletePeerTask) String() string
type DeleteRangeTask ¶ added in v0.6.3
type DeleteRangeTask struct {
*BaseTask
}
DeleteRangeTask delete range task
func NewDeleteRangeTask ¶ added in v0.6.3
func NewDeleteRangeTask() *DeleteRangeTask
NewDeleteRangeTask new delete range task
func (*DeleteRangeTask) String ¶ added in v0.6.3
func (t *DeleteRangeTask) String() string
type DeleteTableWorker ¶
type DeleteTableWorker struct {
// contains filtered or unexported fields
}
func (*DeleteTableWorker) AllowWork ¶
func (dt *DeleteTableWorker) AllowWork(cluster *Cluster) bool
func (*DeleteTableWorker) GetInterval ¶
func (dt *DeleteTableWorker) GetInterval() time.Duration
func (*DeleteTableWorker) GetName ¶
func (dt *DeleteTableWorker) GetName() string
func (*DeleteTableWorker) Stop ¶
func (dt *DeleteTableWorker) Stop()
func (*DeleteTableWorker) Work ¶
func (dt *DeleteTableWorker) Work(cluster *Cluster)
type DifferCacheNodeSelector ¶
type DifferCacheNodeSelector struct {
// contains filtered or unexported fields
}
func NewDifferCacheNodeSelector ¶
func NewDifferCacheNodeSelector(cache *idCache) *DifferCacheNodeSelector
func (*DifferCacheNodeSelector) CanSelect ¶
func (sel *DifferCacheNodeSelector) CanSelect(node *Node) bool
func (*DifferCacheNodeSelector) Name ¶
func (sel *DifferCacheNodeSelector) Name() string
type DifferIPSelector ¶
type DifferIPSelector struct {
// contains filtered or unexported fields
}
func NewDifferIPSelector ¶
func NewDifferIPSelector(excludeNodes []*Node) *DifferIPSelector
func (*DifferIPSelector) CanSelect ¶
func (sel *DifferIPSelector) CanSelect(node *Node) bool
func (*DifferIPSelector) Name ¶
func (sel *DifferIPSelector) Name() string
type DifferNodeSelector ¶
type DifferNodeSelector struct {
// contains filtered or unexported fields
}
func (*DifferNodeSelector) CanSelect ¶
func (sel *DifferNodeSelector) CanSelect(node *Node) bool
func (*DifferNodeSelector) Name ¶
func (sel *DifferNodeSelector) Name() string
type Distribution ¶
type Distribution struct {
// contains filtered or unexported fields
}
type Distributions ¶
type Distributions []Distribution
func (Distributions) Len ¶
func (d Distributions) Len() int
func (Distributions) Less ¶
func (d Distributions) Less(i, j int) bool
func (Distributions) Swap ¶
func (d Distributions) Swap(i, j int)
type FailoverWorker ¶
type FailoverWorker struct {
// contains filtered or unexported fields
}
根据上报的
func (*FailoverWorker) AllowWork ¶
func (f *FailoverWorker) AllowWork(cluster *Cluster) bool
func (*FailoverWorker) GetInterval ¶
func (f *FailoverWorker) GetInterval() time.Duration
func (*FailoverWorker) GetName ¶
func (f *FailoverWorker) GetName() string
func (*FailoverWorker) Stop ¶
func (f *FailoverWorker) Stop()
func (*FailoverWorker) Work ¶
func (f *FailoverWorker) Work(cluster *Cluster)
type GlobalDeletedRange ¶
type GlobalDeletedRange struct {
// contains filtered or unexported fields
}
func NewGlobalDeletedRange ¶
func NewGlobalDeletedRange() *GlobalDeletedRange
func (*GlobalDeletedRange) Add ¶
func (rc *GlobalDeletedRange) Add(rng *metapb.Range)
func (*GlobalDeletedRange) Delete ¶
func (rc *GlobalDeletedRange) Delete(id uint64)
type GlobalPreGCRange ¶
type GlobalPreGCRange struct {
// contains filtered or unexported fields
}
func NewGlobalPreGCRange ¶
func NewGlobalPreGCRange() *GlobalPreGCRange
func (*GlobalPreGCRange) Add ¶
func (rc *GlobalPreGCRange) Add(rng *metapb.Range)
func (*GlobalPreGCRange) Delete ¶
func (rc *GlobalPreGCRange) Delete(id uint64)
type GlobalTableCache ¶
type GlobalTableCache struct {
// contains filtered or unexported fields
}
func NewGlobalTableCache ¶
func NewGlobalTableCache() *GlobalTableCache
func (*GlobalTableCache) Add ¶
func (tc *GlobalTableCache) Add(t *Table)
func (*GlobalTableCache) DeleteById ¶
func (tc *GlobalTableCache) DeleteById(id uint64)
func (*GlobalTableCache) FindTableById ¶
func (tc *GlobalTableCache) FindTableById(id uint64) (*Table, bool)
func (*GlobalTableCache) GetAllTable ¶
func (tc *GlobalTableCache) GetAllTable() []*Table
func (*GlobalTableCache) Size ¶
func (tc *GlobalTableCache) Size() int
type HbRingBuf ¶
type HbRingBuf struct {
// contains filtered or unexported fields
}
func NewHbRingBuf ¶
func (*HbRingBuf) GetLastHbTime ¶
func (*HbRingBuf) ResetHbRingBuf ¶
func (rb *HbRingBuf) ResetHbRingBuf()
func (*HbRingBuf) SetCurHbTime ¶
func (rb *HbRingBuf) SetCurHbTime()
type HttpHandler ¶
type HttpHandler func(w http.ResponseWriter, r *http.Request)
type IDGenerator ¶
func NewClusterIDGenerator ¶
func NewClusterIDGenerator(store Store) IDGenerator
type LevelDBBatch ¶
type LevelDBBatch struct {
// contains filtered or unexported fields
}
func (*LevelDBBatch) Commit ¶
func (b *LevelDBBatch) Commit() error
func (*LevelDBBatch) Delete ¶
func (b *LevelDBBatch) Delete(key []byte)
func (*LevelDBBatch) Put ¶
func (b *LevelDBBatch) Put(key []byte, value []byte)
type LevelDBDriver ¶
type LevelDBDriver struct {
// contains filtered or unexported fields
}
local store, for case test
func (*LevelDBDriver) Close ¶
func (ld *LevelDBDriver) Close() error
func (*LevelDBDriver) Delete ¶
func (ld *LevelDBDriver) Delete(key []byte) error
func (*LevelDBDriver) NewBatch ¶
func (ld *LevelDBDriver) NewBatch() Batch
批量写入,提交时保证batch里的修改同时对外可见
func (*LevelDBDriver) Open ¶
func (ld *LevelDBDriver) Open() error
func (*LevelDBDriver) Scan ¶
func (ld *LevelDBDriver) Scan(startKey, endKey []byte) Iterator
type LevelDBIter ¶
type LevelDBIter struct {
// contains filtered or unexported fields
}
func (*LevelDBIter) Error ¶
func (i *LevelDBIter) Error() error
func (*LevelDBIter) Key ¶
func (i *LevelDBIter) Key() []byte
func (*LevelDBIter) Next ¶
func (i *LevelDBIter) Next() bool
func (*LevelDBIter) Value ¶
func (i *LevelDBIter) Value() []byte
type LocalDSClient ¶
type LocalDSClient struct { }
func (*LocalDSClient) CreateRange ¶
func (lc *LocalDSClient) CreateRange(addr string, r *metapb.Range) error
SendKVReq sends kv request.
func (*LocalDSClient) DeleteRange ¶
func (lc *LocalDSClient) DeleteRange(addr string, rangeId uint64) error
func (*LocalDSClient) GetPeerInfo ¶
func (lc *LocalDSClient) GetPeerInfo(addr string, rangeId uint64) (*schpb.GetPeerInfoResponse, error)
func (*LocalDSClient) OffLineRange ¶
func (lc *LocalDSClient) OffLineRange(addr string, rangeId uint64) error
func (*LocalDSClient) ReplaceRange ¶
func (*LocalDSClient) SetNodeLogLevel ¶
func (lc *LocalDSClient) SetNodeLogLevel(addr string, level string) error
func (*LocalDSClient) TransferLeader ¶
func (lc *LocalDSClient) TransferLeader(addr string, rangeId uint64) error
func (*LocalDSClient) UpdateRange ¶
func (lc *LocalDSClient) UpdateRange(addr string, r *metapb.Range) error
type Member ¶
type Member struct { Id uint64 `json:"id"` Ip string `json:"ip"` HttpPort uint16 `json:"http_port"` RpcPort uint16 `json:"rpc_port"` RaftPorts []uint16 `json:"raft_ports"` }
{"id":1,"ip":"127.0.165.52", "http_port":8887,"rpc_port":8888, "raft_ports":[8877,8867]}
type Metric ¶
type Metric struct {
// contains filtered or unexported fields
}
func (*Metric) CollectEvent ¶
func (*Metric) CollectScheduleCounter ¶
func (*Metric) GetMetricAddr ¶ added in v0.6.3
func (*Metric) GetMetricInterval ¶ added in v0.6.3
type MetricConfig ¶
type MetricConfig struct { Interval util.Duration `toml:"interval,omitempty" json:"interval"` Address string `toml:"address,omitempty" json:"address"` Server MetricServer `toml:"server,omitempty" json:"server"` }
type MetricServer ¶
type Node ¶
type Node struct { *metapb.Node LastHeartbeatTS time.Time Trace bool // contains filtered or unexported fields }
TODO 机器不同导致的分片数量
func SelectLeaderNode ¶
func SelectLeaderNode(nodes []*Node, selectors []NodeSelector, mostLeaderNum float64) *Node
func (*Node) AddTrashReplica ¶
func (*Node) DeleteRange ¶
func (*Node) DeleteTrashReplica ¶
func (*Node) GetAllRanges ¶
func (*Node) GetAllTrashRangeIds ¶
func (*Node) GetAllTrashReplicas ¶
func (*Node) GetApplyingSnapCount ¶
func (*Node) GetLeaderCount ¶
func (*Node) GetRangesCount ¶
func (*Node) GetRangesSize ¶
func (*Node) GetReceivingSnapCount ¶
func (*Node) GetSendingSnapCount ¶
func (*Node) GetStartTS ¶
GetStartTS returns the start timestamp.
func (*Node) UpdateState ¶
type NodeCache ¶
type NodeCache struct {
// contains filtered or unexported fields
}
func NewNodeCache ¶
func NewNodeCache() *NodeCache
func (*NodeCache) DeleteByAddr ¶
func (*NodeCache) DeleteById ¶
func (*NodeCache) GetAllActiveNode ¶
func (*NodeCache) GetAllNode ¶
type NodeLoginSelector ¶
type NodeLoginSelector struct {
// contains filtered or unexported fields
}
func NewNodeLoginSelector ¶
func NewNodeLoginSelector(opt *scheduleOption) *NodeLoginSelector
func (*NodeLoginSelector) CanSelect ¶
func (sel *NodeLoginSelector) CanSelect(node *Node) bool
func (*NodeLoginSelector) Name ¶
func (sel *NodeLoginSelector) Name() string
type NodeOpsStat ¶
type NodeOpsStat struct {
// contains filtered or unexported fields
}
func (*NodeOpsStat) Clear ¶
func (opsStat *NodeOpsStat) Clear() uint64
func (*NodeOpsStat) GetMax ¶
func (opsStat *NodeOpsStat) GetMax() uint64
func (*NodeOpsStat) Hit ¶
func (opsStat *NodeOpsStat) Hit(v uint64)
type NodeSelector ¶
* 挑选合适的node
type Peer ¶
type RaftConfig ¶
type RaftStore ¶
type RaftStore struct {
// contains filtered or unexported fields
}
func NewRaftStore ¶
func NewRaftStore(conf *StoreConfig) (*RaftStore, error)
func (*RaftStore) ApplySnapshot ¶
func (s *RaftStore) ApplySnapshot(iter *raftgroup.SnapshotKVIterator) error
func (*RaftStore) HandleApplySnapshot ¶
func (*RaftStore) HandleCmd ¶
func (s *RaftStore) HandleCmd(req *ms_raftcmdpb.Request, raftIndex uint64) (resp *ms_raftcmdpb.Response, err error)
func (*RaftStore) HandleGetSnapshot ¶
//TODO
func (*RaftStore) HandlePeerChange ¶
func (s *RaftStore) HandlePeerChange(confChange *raftproto.ConfChange) (res interface{}, err error)
type Range ¶
type Range struct { *metapb.Range Leader *metapb.Peer Term uint64 PeersStatus []*mspb.PeerStatus BytesWritten uint64 BytesRead uint64 KeysWritten uint64 KeysRead uint64 // Approximate range size. ApproximateSize uint64 State metapb.RangeState Trace bool LastHbTimeTS time.Time // contains filtered or unexported fields }
func (*Range) GetDownPeer ¶
GetDownPeer return the down peers with specified peer id
func (*Range) GetDownPeers ¶
func (*Range) GetFollowers ¶
GetFollowers return a map indicate the follow peers distributed
func (*Range) GetNodeIds ¶
GetNodeIds return a map indicate the region distributed
func (*Range) GetNodePeer ¶
GetNodePeer return the peer in specified Node
func (*Range) GetPendingPeer ¶
GetPendingPeer return the pending peer with specified peer id TODO: check learner
func (*Range) GetPendingPeers ¶
GetPendingPeers return pending peers
func (*Range) GetRandomFollower ¶
func (*Range) GetStatus ¶ added in v0.6.3
func (r *Range) GetStatus(peerID uint64) *mspb.PeerStatus
GetStatus return peer's status
func (*Range) RemoveNodePeer ¶
RemoveNodePeer remove the peer in specified Node
type RangeCache ¶
type RangeCache struct {
// contains filtered or unexported fields
}
func NewRangeCache ¶
func NewRangeCache() *RangeCache
func (*RangeCache) Add ¶
func (rc *RangeCache) Add(r *Range)
func (*RangeCache) Delete ¶
func (rc *RangeCache) Delete(id uint64) *Range
func (*RangeCache) FindRangeByID ¶
func (rc *RangeCache) FindRangeByID(id uint64) (*Range, bool)
func (*RangeCache) GetAllRange ¶
func (rc *RangeCache) GetAllRange() []*Range
func (*RangeCache) GetAllRangeFromTopology ¶
func (rc *RangeCache) GetAllRangeFromTopology() []*metapb.Range
func (*RangeCache) GetRandomRange ¶
func (rc *RangeCache) GetRandomRange() *Range
func (*RangeCache) GetTableAllRanges ¶
func (rc *RangeCache) GetTableAllRanges(tableId uint64) []*Range
func (*RangeCache) GetTableAllRangesFromTopology ¶
func (rc *RangeCache) GetTableAllRangesFromTopology(tableId uint64) []*metapb.Range
func (*RangeCache) GetTableRangeDuplicate ¶
func (rc *RangeCache) GetTableRangeDuplicate(tableId uint64) []*metapb.Range
func (*RangeCache) GetTableTopologyMissing ¶
func (rc *RangeCache) GetTableTopologyMissing(tableId uint64) []*metapb.Range
completeness check
func (*RangeCache) MultipleSearchRanges ¶
func (rc *RangeCache) MultipleSearchRanges(key []byte, num int) ([]*Range, bool)
func (*RangeCache) SearchRange ¶
func (rc *RangeCache) SearchRange(key []byte) (*Range, bool)
func (*RangeCache) Size ¶
func (rc *RangeCache) Size() int
type RangeDebug ¶
type RangeHbCheckWorker ¶ added in v0.6.3
type RangeHbCheckWorker struct {
// contains filtered or unexported fields
}
func (*RangeHbCheckWorker) AllowWork ¶ added in v0.6.3
func (hb *RangeHbCheckWorker) AllowWork(cluster *Cluster) bool
func (*RangeHbCheckWorker) GetInterval ¶ added in v0.6.3
func (hb *RangeHbCheckWorker) GetInterval() time.Duration
func (*RangeHbCheckWorker) GetName ¶ added in v0.6.3
func (hb *RangeHbCheckWorker) GetName() string
func (*RangeHbCheckWorker) Stop ¶ added in v0.6.3
func (hb *RangeHbCheckWorker) Stop()
func (*RangeHbCheckWorker) Work ¶ added in v0.6.3
func (hb *RangeHbCheckWorker) Work(cluster *Cluster)
type RangeOpsStat ¶
type RangeOpsStat struct {
// contains filtered or unexported fields
}
func (*RangeOpsStat) Clear ¶
func (opsStat *RangeOpsStat) Clear() uint64
func (*RangeOpsStat) GetMax ¶
func (opsStat *RangeOpsStat) GetMax() uint64
func (*RangeOpsStat) Hit ¶
func (opsStat *RangeOpsStat) Hit(v uint64)
type RegionCache ¶
type RegionCache struct {
// contains filtered or unexported fields
}
func NewRegionCache ¶
func NewRegionCache() *RegionCache
func (*RegionCache) Add ¶
func (rc *RegionCache) Add(r *Range)
func (*RegionCache) Delete ¶
func (rc *RegionCache) Delete(id uint64)
func (*RegionCache) FindRangeByID ¶
func (rc *RegionCache) FindRangeByID(id uint64) (*Range, bool)
func (*RegionCache) GetAllRange ¶
func (rc *RegionCache) GetAllRange() []*Range
func (*RegionCache) GetRandomRange ¶
func (rc *RegionCache) GetRandomRange() *Range
func (*RegionCache) Size ¶
func (rc *RegionCache) Size() int
type ReplicaCache ¶
type ReplicaCache struct {
// contains filtered or unexported fields
}
func NewReplicaCache ¶
func NewReplicaCache() *ReplicaCache
func (*ReplicaCache) Add ¶
func (rc *ReplicaCache) Add(peer *metapb.Replica)
func (*ReplicaCache) Delete ¶
func (rc *ReplicaCache) Delete(id uint64)
func (*ReplicaCache) FindReplica ¶
func (rc *ReplicaCache) FindReplica(id uint64) (*metapb.Replica, bool)
func (*ReplicaCache) GetAllRangIds ¶
func (rc *ReplicaCache) GetAllRangIds() []uint64
func (*ReplicaCache) GetAllReplica ¶
func (rc *ReplicaCache) GetAllReplica() []*metapb.Replica
func (*ReplicaCache) Size ¶
func (rc *ReplicaCache) Size() int
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 util.StringSlice `toml:"location-labels,omitempty" json:"location-labels"` }
ReplicationConfig is the replication configuration.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func NewResolver ¶
func (*Resolver) NodeAddress ¶
type SaveBatch ¶
type SaveBatch struct {
// contains filtered or unexported fields
}
func NewSaveBatch ¶
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. MaxNodeDownTime util.Duration `toml:"max-node-down-time,omitempty" json:"max-node-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"` MaxTaskTimeout util.Duration `toml:"max-task-timeout,omitempty" json:"max-task-timeout"` MaxRangeDownTime util.Duration `toml:"max-range-down-time,omitempty" json:"max-range-down-time"` NodeRangeBalanceTime util.Duration `toml:"node-range-balance-time,omitempty" json:"node-range-balance-time"` StorageAvailableThreshold uint64 `toml:"storage-available-threshold,omitempty" json:"storage-available-threshold"` WriteByteOpsThreshold uint64 `toml:"writeByte-ops-threshold,omitempty" json:"writeByte-ops-threshold"` }
ScheduleConfig is the schedule configuration.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) AddColumn ¶
func (service *Server) AddColumn(ctx context.Context, req *mspb.AddColumnRequest) (*mspb.AddColumnResponse, error)
func (*Server) AskSplit ¶
func (service *Server) AskSplit(ctx context.Context, req *mspb.AskSplitRequest) (*mspb.AskSplitResponse, error)
func (*Server) CreateDatabase ¶
func (service *Server) CreateDatabase(ctx context.Context, req *mspb.CreateDatabaseRequest) (*mspb.CreateDatabaseResponse, error)
func (*Server) CreateTable ¶
func (service *Server) CreateTable(ctx context.Context, req *mspb.CreateTableRequest) (*mspb.CreateTableResponse, error)
func (*Server) GetColumnById ¶
func (service *Server) GetColumnById(ctx context.Context, req *mspb.GetColumnByIdRequest) (*mspb.GetColumnByIdResponse, error)
func (*Server) GetColumnByName ¶
func (service *Server) GetColumnByName(ctx context.Context, req *mspb.GetColumnByNameRequest) (*mspb.GetColumnByNameResponse, error)
func (*Server) GetColumns ¶
func (service *Server) GetColumns(ctx context.Context, req *mspb.GetColumnsRequest) (*mspb.GetColumnsResponse, error)
func (*Server) GetDB ¶
func (service *Server) GetDB(ctx context.Context, req *mspb.GetDBRequest) (*mspb.GetDBResponse, error)
func (*Server) GetMSLeader ¶
func (service *Server) GetMSLeader(ctx context.Context, req *mspb.GetMSLeaderRequest) (*mspb.GetMSLeaderResponse, error)
func (*Server) GetNode ¶
func (service *Server) GetNode(ctx context.Context, req *mspb.GetNodeRequest) (*mspb.GetNodeResponse, error)
func (*Server) GetNodeId ¶
func (service *Server) GetNodeId(ctx context.Context, req *mspb.GetNodeIdRequest) (*mspb.GetNodeIdResponse, error)
func (*Server) GetRoute ¶
func (service *Server) GetRoute(ctx context.Context, req *mspb.GetRouteRequest) (*mspb.GetRouteResponse, error)
func (*Server) GetTable ¶
func (service *Server) GetTable(ctx context.Context, req *mspb.GetTableRequest) (*mspb.GetTableResponse, error)
func (*Server) GetTableById ¶
func (service *Server) GetTableById(ctx context.Context, req *mspb.GetTableByIdRequest) (*mspb.GetTableByIdResponse, error)
func (*Server) InitAlarmServer ¶
func (service *Server) InitAlarmServer(conf AlarmConfig) (err error)
func (*Server) InitMasterServer ¶
func (*Server) InitMetricServer ¶
func (*Server) InitServer ¶
func (*Server) MasterStart ¶
func (service *Server) MasterStart()
func (*Server) MetricStart ¶
func (service *Server) MetricStart()
func (*Server) NodeHeartbeat ¶
func (service *Server) NodeHeartbeat(ctx context.Context, req *mspb.NodeHeartbeatRequest) (*mspb.NodeHeartbeatResponse, error)
func (*Server) NodeLogin ¶
func (service *Server) NodeLogin(ctx context.Context, req *mspb.NodeLoginRequest) (*mspb.NodeLoginResponse, error)
func (*Server) ParseClusterInfo ¶
func (*Server) RaftLeaderChange ¶
func (*Server) RangeHeartbeat ¶
func (service *Server) RangeHeartbeat(ctx context.Context, req *mspb.RangeHeartbeatRequest) (*mspb.RangeHeartbeatResponse, error)
func (*Server) ReportSplit ¶
func (service *Server) ReportSplit(ctx context.Context, req *mspb.ReportSplitRequest) (*mspb.ReportSplitResponse, error)
func (*Server) TruncateTable ¶
func (service *Server) TruncateTable(context.Context, *mspb.TruncateTableRequest) (*mspb.TruncateTableResponse, error)
type SignHandler ¶
type SignHandler func(w http.ResponseWriter, r *http.Request) bool
type SnapshotCountLimitSelector ¶
type SnapshotCountLimitSelector struct {
// contains filtered or unexported fields
}
func NewSnapshotCountLimitSelector ¶
func NewSnapshotCountLimitSelector(opt *scheduleOption) *SnapshotCountLimitSelector
func (*SnapshotCountLimitSelector) CanSelect ¶
func (sel *SnapshotCountLimitSelector) CanSelect(node *Node) bool
func (*SnapshotCountLimitSelector) Name ¶
func (sel *SnapshotCountLimitSelector) Name() string
type StorageThresholdSelector ¶
type StorageThresholdSelector struct {
// contains filtered or unexported fields
}
storageThresholdFilter ensures that we will not use an almost full node as a target.
func NewStorageThresholdSelector ¶
func NewStorageThresholdSelector(opt *scheduleOption) *StorageThresholdSelector
func (*StorageThresholdSelector) CanSelect ¶
func (sel *StorageThresholdSelector) CanSelect(node *Node) bool
func (*StorageThresholdSelector) Name ¶
func (sel *StorageThresholdSelector) Name() string
type Store ¶
type Store interface { Open() error Put(key, value []byte) error Delete(key []byte) error Get(key []byte) ([]byte, error) Scan(startKey, limitKey []byte) Iterator NewBatch() Batch Close() error }
func NewLevelDBDriver ¶
type StoreConfig ¶
type TableCache ¶
type TableCache struct {
// contains filtered or unexported fields
}
func NewTableCache ¶
func NewTableCache() *TableCache
func (*TableCache) Add ¶
func (tc *TableCache) Add(t *Table)
func (*TableCache) DeleteById ¶
func (tc *TableCache) DeleteById(id uint64)
func (*TableCache) DeleteByName ¶
func (tc *TableCache) DeleteByName(name string)
func (*TableCache) FindTableById ¶
func (tc *TableCache) FindTableById(id uint64) (*Table, bool)
func (*TableCache) FindTableByName ¶
func (tc *TableCache) FindTableByName(name string) (*Table, bool)
func (*TableCache) GetAllTable ¶
func (tc *TableCache) GetAllTable() []*Table
func (*TableCache) Size ¶
func (tc *TableCache) Size() int
type TableProperty ¶
type Task ¶ added in v0.6.3
type Task interface { // SetBeginTime set begin time SetBegin() // SetLogID set a identifer to print log SetLogID(id string) // GetType return task type GetType() TaskType // Step next step Step(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) // CheckOver return true if check is over CheckOver() bool // AllowFail allow to fail and continue next task AllowFail() bool // GetState return current state GetState() TaskState // Elapsed time elapsed since task start Elapsed() time.Duration // String to string for print String() string }
Task range task interface
type TaskChain ¶ added in v0.6.3
type TaskChain struct {
// contains filtered or unexported fields
}
TaskChain is a list of associated tasks to achive the same goal
func NewDeletePeerTasks ¶ added in v0.6.3
NewDeletePeerTasks new delete peer tasks
func NewTaskChain ¶ added in v0.6.3
NewTaskChain new taskchain
func NewTransferPeerTasks ¶ added in v0.6.3
NewTransferPeerTasks new transfer peer tasks
func (*TaskChain) GetRangeID ¶ added in v0.6.3
GetRangeID return range id
type TaskManager ¶ added in v0.6.3
TaskManager task manager
func NewTaskManager ¶ added in v0.6.3
func NewTaskManager() *TaskManager
NewTaskManager create task manager
func (*TaskManager) Add ¶ added in v0.6.3
func (m *TaskManager) Add(tc *TaskChain) bool
Add add a taskchain
func (*TaskManager) Find ¶ added in v0.6.3
func (m *TaskManager) Find(rangeID uint64) *TaskChain
Find find
func (*TaskManager) GetAll ¶ added in v0.6.3
func (m *TaskManager) GetAll() []*TaskChain
GetAll return all tasks
type TaskState ¶ added in v0.6.3
type TaskState int
TaskState task running state
const ( // TaskStateStart start TaskStateStart TaskState = iota + 1 // TaskStateFinished finished TaskStateFinished // TaskStateFailed failed TaskStateFailed // TaskStateCanceled canceled TaskStateCanceled // TaskStateTimeout run timeout TaskStateTimeout )
common states, keep less than 100
const ( // WaitRaftConfReady wait raft conf ready WaitRaftConfReady TaskState = iota + 100 // WaitRangeCreated wait range created WaitRangeCreated // WaitDataSynced wait data synced WaitDataSynced // WaitRangeDeleted wait range deleted WaitRangeDeleted // WaitLeaderChanged wait leader moved WaitLeaderChanged )
type TrashReplicaGCWorker ¶
type TrashReplicaGCWorker struct {
// contains filtered or unexported fields
}
func (*TrashReplicaGCWorker) AllowWork ¶
func (tr *TrashReplicaGCWorker) AllowWork(cluster *Cluster) bool
func (*TrashReplicaGCWorker) GetInterval ¶
func (tr *TrashReplicaGCWorker) GetInterval() time.Duration
func (*TrashReplicaGCWorker) GetName ¶
func (tr *TrashReplicaGCWorker) GetName() string
func (*TrashReplicaGCWorker) Stop ¶
func (tr *TrashReplicaGCWorker) Stop()
func (*TrashReplicaGCWorker) Work ¶
func (tr *TrashReplicaGCWorker) Work(cluster *Cluster)
type ValidHandler ¶
type ValidHandler func(w http.ResponseWriter, r *http.Request) bool
type Worker ¶
type Worker interface { GetName() string GetInterval() time.Duration AllowWork(cluster *Cluster) bool Work(cluster *Cluster) Stop() }
func NewBalanceNodeLeaderWorker ¶
func NewBalanceNodeLeaderWorker(wm *WorkerManager, interval time.Duration) Worker
func NewCreateTableWorker ¶
func NewCreateTableWorker(wm *WorkerManager, interval time.Duration) Worker
func NewDeleteTableWorker ¶
func NewDeleteTableWorker(wm *WorkerManager, interval time.Duration) Worker
func NewFailoverWorker ¶
func NewFailoverWorker(wm *WorkerManager, interval time.Duration) Worker
func NewRangeHbCheckWorker ¶
func NewRangeHbCheckWorker(wm *WorkerManager, interval time.Duration) Worker
func NewTrashReplicaGCWorker ¶
func NewTrashReplicaGCWorker(wm *WorkerManager, interval time.Duration) Worker
type WorkerManager ¶
type WorkerManager struct {
// contains filtered or unexported fields
}
func NewWorkerManager ¶
func NewWorkerManager(cluster *Cluster, opt *scheduleOption) *WorkerManager
func (*WorkerManager) GetAllWorker ¶
func (wm *WorkerManager) GetAllWorker() []string
func (*WorkerManager) GetWorker ¶
func (wm *WorkerManager) GetWorker(workerName string) string
func (*WorkerManager) Run ¶
func (wm *WorkerManager) Run()
func (*WorkerManager) Stop ¶
func (wm *WorkerManager) Stop()
type WriterOpsThresholdSelector ¶
type WriterOpsThresholdSelector struct {
// contains filtered or unexported fields
}
WriterOpsThresholdSelector ensures that we will not use an almost busy node as a target.
func NewWriterOpsThresholdSelector ¶
func NewWriterOpsThresholdSelector(opt *scheduleOption) *WriterOpsThresholdSelector
func (*WriterOpsThresholdSelector) CanSelect ¶
func (sel *WriterOpsThresholdSelector) CanSelect(node *Node) bool
func (*WriterOpsThresholdSelector) Name ¶
func (sel *WriterOpsThresholdSelector) Name() string
Source Files ¶
- cluster.go
- cluster_node.go
- cluster_range.go
- config.go
- database.go
- debug.go
- errors.go
- failOver.go
- hb_range_manage.go
- httpHandle.go
- idgenerator.go
- metric.go
- msHandle.go
- node.go
- node_leader_balance_worker.go
- node_range_balance_worker.go
- node_selector.go
- node_storage_balance_worker.go
- node_writeops_balance_worker.go
- range.go
- range_cache.go
- range_hb_check.go
- rpcserver.go
- server.go
- store.go
- table.go
- task.go
- task_add_peer.go
- task_chain.go
- task_change_leader.go
- task_delete_peer.go
- task_delete_range.go
- task_manager.go
- test_env.go
- util.go
- worker.go
- worker_condition.go