Versions in this module Expand all Collapse all v0 v0.7.3 Aug 16, 2018 v0.7.2 Aug 2, 2018 v0.7.1 Aug 1, 2018 v0.6.4 Aug 1, 2018 v0.6.3 Jul 27, 2018 Changes in this version + 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_UNABLE string = fmt.Sprintf("schema%sauto_transfer_unable%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR) + var PREFIX_METRIC string = fmt.Sprintf("schema%smetric_send%s", SCHEMA_SPLITOR, SCHEMA_SPLITOR) + func UpdateMetric(cluster *Cluster, addr string, interval time.Duration) error + type AddPeerTask struct + func NewAddPeerTask() *AddPeerTask + func (t *AddPeerTask) Step(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) + func (t *AddPeerTask) String() string type AlarmConfig + RemoteAlarmServerAddress string + type BaseTask struct + 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 ChangeLeaderTask struct + func NewChangeLeaderTask(from, to uint64) *ChangeLeaderTask + func (t *ChangeLeaderTask) Step(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) + func (t *ChangeLeaderTask) String() string type Cluster + func (c *Cluster) Dispatch(r *Range) *taskpb.Task + func (c *Cluster) GetAllTasks() []*TaskChain + func (c *Cluster) StoreMetricConfig(m *MetricConfig) error + type DeletePeerTask struct + func NewDeletePeerTask(peer *metapb.Peer) *DeletePeerTask + func (t *DeletePeerTask) Step(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) + func (t *DeletePeerTask) String() string + type DeleteRangeTask struct + func NewDeleteRangeTask() *DeleteRangeTask + func (t *DeleteRangeTask) Step(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) + func (t *DeleteRangeTask) String() string + type DownPeer struct + DownSeconds uint64 + Peer *metapb.Peer type Metric + func (m *Metric) GetMetricAddr() string + func (m *Metric) GetMetricInterval() time.Duration type Range + PeersStatus []*mspb.PeerStatus + Term uint64 + func (r *Range) GetStatus(peerID uint64) *mspb.PeerStatus type RangeDebug + PeersStatus []*mspb.PeerStatus + type RangeHbCheckWorker struct + func (hb *RangeHbCheckWorker) AllowWork(cluster *Cluster) bool + func (hb *RangeHbCheckWorker) GetInterval() time.Duration + func (hb *RangeHbCheckWorker) GetName() string + func (hb *RangeHbCheckWorker) Stop() + func (hb *RangeHbCheckWorker) Work(cluster *Cluster) + type Task interface + AllowFail func() bool + CheckOver func() bool + Elapsed func() time.Duration + GetState func() TaskState + GetType func() TaskType + SetBegin func() + SetLogID func(id string) + Step func(cluster *Cluster, r *Range) (over bool, task *taskpb.Task) + String func() string + type TaskChain struct + func NewDeletePeerTasks(id uint64, r *Range, name string, peer *metapb.Peer) *TaskChain + func NewTaskChain(id uint64, rangeID uint64, name string, tasks ...Task) *TaskChain + func NewTransferPeerTasks(id uint64, r *Range, name string, from *metapb.Peer) *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 struct + func NewTaskManager() *TaskManager + func (m *TaskManager) Add(tc *TaskChain) bool + func (m *TaskManager) Find(rangeID uint64) *TaskChain + func (m *TaskManager) GetAll() []*TaskChain + func (m *TaskManager) Remove(tc *TaskChain, cluster *Cluster) bool + type TaskState int + const TaskStateCanceled + const TaskStateFailed + const TaskStateFinished + const TaskStateStart + const TaskStateTimeout + const WaitDataSynced + const WaitLeaderChanged + const WaitRaftConfReady + const WaitRangeCreated + const WaitRangeDeleted + func (ts TaskState) String() string + type TaskType int + const TaskTypeAddPeer + const TaskTypeChangeLeader + const TaskTypeDeletePeer + const TaskTypeDeleteRange + func (t TaskType) String() string v0.6.2 Jun 18, 2018 v0.6.1 Jun 17, 2018 Changes in this version + const CacheSize + const DefaultConfig + const DefaultFactor + const ER_ENTITY_NOT_EXIT + const ER_NOT_LEADER + const ER_READ_ONLY + const ER_SERVER_BUSY + const ER_SERVER_STOP + const ER_UNKNOWN + const EVENT_TYPE_ADD_PEER + const EVENT_TYPE_CHANGE_LEADER + const EVENT_TYPE_DEL_PEER + const EVENT_TYPE_DEL_RANGE + const EVENT_TYPE_INIT + const GB + const HTTP_AUTO_FAILOVER_UNABLE + const HTTP_AUTO_SPLIT_UNABLE + const HTTP_AUTO_TRANSFER_UNABLE + const HTTP_CLUSTER_AUTO_SCHEDULE_INFO + const HTTP_CLUSTER_ID + const HTTP_D + const HTTP_DB_ID + const HTTP_DB_NAME + const HTTP_ENDKEY + const HTTP_ERROR + const HTTP_ERROR_CLUSTERID + const HTTP_ERROR_CLUSTER_HAS_NO_LEADER + const HTTP_ERROR_DATABASE_EXISTED + const HTTP_ERROR_DATABASE_FIND + const HTTP_ERROR_INVALID_PARAM + const HTTP_ERROR_INVALID_SIGNTIME + const HTTP_ERROR_MASTER_IS_NOT_LEADER + const HTTP_ERROR_NODE_FIND + const HTTP_ERROR_PARAMETER_NOT_ENOUGH + const HTTP_ERROR_PEER_FIND + const HTTP_ERROR_RANGE_BUSY + const HTTP_ERROR_RANGE_CREATE + const HTTP_ERROR_RANGE_FIND + const HTTP_ERROR_RANGE_SPLIT + const HTTP_ERROR_SIGN_TIMEOUT + const HTTP_ERROR_TABLE_DELETED + const HTTP_ERROR_TABLE_FIND + const HTTP_ERROR_TASK_FIND + const HTTP_ERROR_WRONG_SIGN + const HTTP_FAST + const HTTP_MACHINES + const HTTP_NAME + const HTTP_NODE_ID + const HTTP_NODE_IDS + const HTTP_OK + const HTTP_PEER_ID + const HTTP_PKDUPCHECK + const HTTP_POLICY + const HTTP_PROPERTIES + const HTTP_RAFT_HEARTBEAT_PORT + const HTTP_RAFT_REPLICA_PORT + const HTTP_RANGEKEYS + const HTTP_RANGEKEYS_END + const HTTP_RANGEKEYS_NUM + const HTTP_RANGEKEYS_START + const HTTP_RANGE_ID + const HTTP_S + const HTTP_SERVER_PORT + const HTTP_SQL + const HTTP_STARTKEY + const HTTP_TABLE_AUTO_INFO + const HTTP_TABLE_ID + const HTTP_TABLE_NAME + const HTTP_TASK_ID + const HTTP_TASK_IDS + const HTTP_TOKEN + const KB + const MB + const Min_leader_adjust_num + const Min_leader_balance_num + const PB + const ROUTE_SUBSCRIBE + const SUCCESS + var AUTO_INCREMENT_ID string = fmt.Sprintf("$auto_increment_id") + var DefaultAddPeerTimeout time.Duration = time.Second * time.Duration(300) + var DefaultChangeLeaderTaskTimeout = time.Second * time.Duration(30) + var DefaultChangeLeaderTimeout time.Duration = time.Second * time.Duration(30) + var DefaultDelPeerTimeout time.Duration = time.Second * time.Duration(30) + var DefaultDelRangeTimeout time.Duration = time.Second * time.Duration(30) + var DefaultDownTimeLimit = 60 * time.Second + var DefaultDsHearbeatInterval = 10 * time.Second + var DefaultDsRecoveryInterim = 5 * 60 * time.Second + var DefaultFaultTimeout = time.Minute + var DefaultMaxBigTaskNum = 3 + var DefaultMaxNodeDownTimeInterval time.Duration = 60 * time.Second + var DefaultMaxPeerDownTimeInterval time.Duration = 2 * 60 * time.Second + var DefaultMaxSubmitTimeout time.Duration = time.Second * 60 + var DefaultMaxTaskNum = 50 + var DefaultRaftLogCount uint64 = 10000 + var DefaultRangeAddPeerTaskTimeout = time.Second * time.Duration(300) + var DefaultRangeDelPeerTaskTimeout = time.Second * time.Duration(30) + var DefaultRangeDeleteTaskTimeout = time.Second * time.Duration(30) + var DefaultRetentionTime = time.Hour * time.Duration(72) + var DefaultTimeFormat = "2006-01-02 15:04:05" + var ERR_NO_SELECTED_NODE = errors.New("not selected node") + var ErrColumnNameTooLong = errors.New("column name is too long") + var ErrDupColumnName = errors.New("duplicate column name") + var ErrDupDatabase = errors.New("duplicate database") + var ErrDupTable = errors.New("duplicate table") + var ErrExistsRange = errors.New("range exist") + var ErrGenID = errors.New("gen ID failed") + var ErrInternalError = errors.New("internal error") + var ErrInvalidColumn = errors.New("invalid column") + var ErrInvalidParam = errors.New("invalid param") + var ErrMissingPk = errors.New("missing primary key") + var ErrNodeBlocked = errors.New("node is blocked") + var ErrNodeRejectNewPeer = errors.New("node reject new peer") + var ErrNodeStateConfused = errors.New("confused node state") + var ErrNotActiveNode = errors.New("node is not up") + var ErrNotAllowDelete = errors.New("not allow delete") + var ErrNotAllowSplit = errors.New("not allow split") + var ErrNotCancel = errors.New("not allow cancel") + var ErrNotEnoughResources = errors.New("not enough resources") + var ErrNotExistDatabase = errors.New("database not exist") + var ErrNotExistNode = errors.New("node not exist") + var ErrNotExistPeer = errors.New("range peer not exist") + var ErrNotExistRange = errors.New("range not exist") + var ErrNotExistTable = errors.New("table not exist") + var ErrNotFound = errors.New("entity not found") + var ErrPkMustNotNull = errors.New("primary key must be not nullable") + var ErrPkMustNotSetDefaultValue = errors.New("primary key should not set defaultvalue") + var ErrRangeMetaConflict = errors.New("range meta conflict") + var ErrRangeStatusErr = errors.New("range status is invalid") + var ErrSQLSyntaxError = errors.New("Syntax error") + var ErrSchedulerExisted = errors.New("scheduler is existed") + var ErrSchedulerNotFound = errors.New("scheduler is not found") + var ErrSqlReservedWord = errors.New("sql reserved word") + var ErrUnknownCommandType = errors.New("unknown command type") + var ErrWorkerExisted = errors.New("worker is existed") + var ErrWorkerNotFound = errors.New("worker is not found") + var MAX_COLUMN_NAME_LENGTH = 128 + var MaxDownReplicaTimeLimit = 5 * 60 * time.Second + var Min_range_adjust_num = 50 + var Min_range_balance_num = 10 + var PREFIX_AUTO_FAILOVER string = fmt.Sprintf("$auto_failover_%d") + var PREFIX_AUTO_FAILOVER_TABLE string = fmt.Sprintf("$auto_failover_table_%d") + var PREFIX_AUTO_SPLIT string = fmt.Sprintf("$auto_split_%d") + var PREFIX_AUTO_TRANSFER string = fmt.Sprintf("$auto_transfer_%d") + var PREFIX_AUTO_TRANSFER_TABLE string = fmt.Sprintf("$auto_transfer_table_%d") + 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_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 = " " + var SQLReservedWord = []string + 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 ToEventStatusName(status EventStatus) string + func ToEventTypeName(eventType EventType) string + func ToTableProperty(cols []*metapb.Column) (string, error) + type AddPeerEvent struct + func NewAddPeerEvent(id, rangeId uint64, p *metapb.Peer, creator string) *AddPeerEvent + func (e *AddPeerEvent) Execute(cluster *Cluster, r *Range) (ExecNextEvent, *taskpb.Task, error) + type AlarmConfig struct + MessageGatewayAddress string + Receivers []*AlarmReceiver + ServerAddress string + ServerPort int + type AlarmReceiver struct + Mail string + Sms string + type Batch interface + Commit func() error + Delete func(key []byte) + Put func(key []byte, value []byte) + type ByLetter [][]byte + func (s ByLetter) Len() int + func (s ByLetter) Less(i, j int) bool + func (s ByLetter) Swap(i, j int) + type ByPrimaryKey []*metapb.Column + func (s ByPrimaryKey) Len() int + func (s ByPrimaryKey) Less(i, j int) bool + func (s ByPrimaryKey) Swap(i, j int) + type Cluster struct + func NewCluster(clusterId, nodeId uint64, store Store, opt *scheduleOption) *Cluster + func (c *Cluster) AddBalanceLeaderWorker() + func (c *Cluster) AddBalanceNodeOpsWorker() + func (c *Cluster) AddBalanceRangeWorker() + func (c *Cluster) AddCreateTableWorker() + func (c *Cluster) AddDeleteTableWorker() + func (c *Cluster) AddEvent(event RangeEvent) bool + 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) 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) GetAllEvent() []RangeEvent + func (c *Cluster) GetAllNode() []*Node + func (c *Cluster) GetAllRanges() []*Range + 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) GetEvent(rangeID uint64) RangeEvent + 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) RemoveEvent(event RangeEvent) + 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) 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 struct + ClusterID uint64 + Peers []*ClusterPeer + type ClusterIDGenerator struct + func (id ClusterIDGenerator) GenID() (uint64, error) + type ClusterPeer struct + Host string + HttpPort int + ID uint64 + RaftPorts []int + RpcPort int + type Config struct + Alarm AlarmConfig + Cluster ClusterConfig + DataPath string + Log LogConfig + Metric MetricConfig + Name string + NodeId uint64 + Raft RaftConfig + Replication ReplicationConfig + Role string + Schedule ScheduleConfig + SecretKey string + Threshold metric.ThresholdConfig + Version string + func NewDefaultConfig() *Config + func (c *Config) LoadFromFile(path string) error + type CreateTable struct + func NewCreateTable(t *Table, n uint64) *CreateTable + func (t *CreateTable) AddRange(r *Range) + func (t *CreateTable) DeleteRange(rangeID uint64) + func (t *CreateTable) GetAllRanges() []*Range + type CreateTableCache struct + func NewCreateTableCache() *CreateTableCache + func (tc *CreateTableCache) Add(t *CreateTable) + func (tc *CreateTableCache) Delete(id uint64) + func (tc *CreateTableCache) FindTable(id uint64) (*CreateTable, bool) + func (tc *CreateTableCache) GetAllTable() []*CreateTable + func (tc *CreateTableCache) Size() int + type CreateTableWorker struct + func (dt *CreateTableWorker) AllowWork(cluster *Cluster) bool + func (dt *CreateTableWorker) GetInterval() time.Duration + func (dt *CreateTableWorker) GetName() string + func (dt *CreateTableWorker) Stop() + func (dt *CreateTableWorker) Work(c *Cluster) + type Database struct + func NewDatabase(db *metapb.DataBase) *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 struct + func NewDbCache() *DbCache + func (dc *DbCache) Add(d *Database) + func (dc *DbCache) Delete(name string) + func (dc *DbCache) FindDb(name string) (*Database, bool) + func (dc *DbCache) FindDbById(id uint64) (*Database, bool) + func (dc *DbCache) GetAllDatabase() []*Database + func (dc *DbCache) Size() int + type DelPeerEvent struct + func NewDelPeerEvent(id, rangeId uint64, p *metapb.Peer, creator string) *DelPeerEvent + func (e *DelPeerEvent) Execute(cluster *Cluster, r *Range) (ExecNextEvent, *taskpb.Task, error) + type DelRangeEvent struct + func NewDelRangeEvent(id, rangeId uint64, creator string) *DelRangeEvent + func (e *DelRangeEvent) Execute(cluster *Cluster, r *Range) (ExecNextEvent, *taskpb.Task, error) + type DeleteTableWorker struct + func (dt *DeleteTableWorker) AllowWork(cluster *Cluster) bool + func (dt *DeleteTableWorker) GetInterval() time.Duration + func (dt *DeleteTableWorker) GetName() string + func (dt *DeleteTableWorker) Stop() + func (dt *DeleteTableWorker) Work(cluster *Cluster) + type DifferCacheNodeSelector struct + func NewDifferCacheNodeSelector(cache *idCache) *DifferCacheNodeSelector + func (sel *DifferCacheNodeSelector) CanSelect(node *Node) bool + func (sel *DifferCacheNodeSelector) Name() string + type DifferIPSelector struct + func NewDifferIPSelector(excludeNodes []*Node) *DifferIPSelector + func (sel *DifferIPSelector) CanSelect(node *Node) bool + func (sel *DifferIPSelector) Name() string + type DifferNodeSelector struct + func (sel *DifferNodeSelector) CanSelect(node *Node) bool + func (sel *DifferNodeSelector) Name() string + type Distribution struct + type Distributions []Distribution + func (d Distributions) Len() int + func (d Distributions) Less(i, j int) bool + func (d Distributions) Swap(i, j int) + type EventDispatcher struct + func NewEventDispatcher(cluster *Cluster, opt *scheduleOption) *EventDispatcher + func (c *EventDispatcher) Run() + func (c *EventDispatcher) Stop() + func (dispatcher *EventDispatcher) Dispatch(r *Range) *taskpb.Task + type EventStatus int + const EVENT_STATUS_CANCEL + const EVENT_STATUS_CREATE + const EVENT_STATUS_DEALING + const EVENT_STATUS_FAILURE + const EVENT_STATUS_FINISH + const EVENT_STATUS_INIT + const EVENT_STATUS_TIMEOUT + type EventType int + type ExecNextEvent bool + type FailoverWorker struct + func (f *FailoverWorker) AllowWork(cluster *Cluster) bool + func (f *FailoverWorker) GetInterval() time.Duration + func (f *FailoverWorker) GetName() string + func (f *FailoverWorker) Stop() + func (f *FailoverWorker) Work(cluster *Cluster) + type GlobalDeletedRange struct + func NewGlobalDeletedRange() *GlobalDeletedRange + func (rc *GlobalDeletedRange) Add(rng *metapb.Range) + func (rc *GlobalDeletedRange) Delete(id uint64) + func (rc *GlobalDeletedRange) FindRange(id uint64) (*metapb.Range, bool) + type GlobalPreGCRange struct + func NewGlobalPreGCRange() *GlobalPreGCRange + func (rc *GlobalPreGCRange) Add(rng *metapb.Range) + func (rc *GlobalPreGCRange) Delete(id uint64) + func (rc *GlobalPreGCRange) FindRange(id uint64) (*metapb.Range, bool) + type GlobalTableCache struct + func NewGlobalTableCache() *GlobalTableCache + func (tc *GlobalTableCache) Add(t *Table) + func (tc *GlobalTableCache) DeleteById(id uint64) + func (tc *GlobalTableCache) FindTableById(id uint64) (*Table, bool) + func (tc *GlobalTableCache) GetAllTable() []*Table + func (tc *GlobalTableCache) Size() int + type HbRingBuf struct + func NewHbRingBuf(cap uint32) *HbRingBuf + func (rb *HbRingBuf) CalcMaxHbDiff() (time.Duration, error) + func (rb *HbRingBuf) GetLastHbTime() time.Time + func (rb *HbRingBuf) ResetHbRingBuf() + func (rb *HbRingBuf) SetCurHbTime() + type HttpHandler func(w http.ResponseWriter, r *http.Request) + type HttpReply httpReply + type IDGenerator interface + GenID func() (uint64, error) + func NewClusterIDGenerator(store Store) IDGenerator + type Iterator interface + Error func() error + Key func() []byte + Next func() bool + Release func() + Value func() []byte + type LevelDBBatch struct + func (b *LevelDBBatch) Commit() error + func (b *LevelDBBatch) Delete(key []byte) + func (b *LevelDBBatch) Put(key []byte, value []byte) + type LevelDBDriver struct + 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 struct + func (i *LevelDBIter) Error() error + func (i *LevelDBIter) Key() []byte + func (i *LevelDBIter) Next() bool + func (i *LevelDBIter) Release() + func (i *LevelDBIter) Value() []byte + type LocalDSClient struct + 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 struct + Dir string + Level string + Module string + type Member struct + HttpPort uint16 + Id uint64 + Ip string + RaftPorts []uint16 + RpcPort uint16 + type Metric struct + func NewMetric(cluster *Cluster, addr string, interval time.Duration) *Metric + func (m *Metric) CollectEvent(event RangeEvent) + func (m *Metric) CollectScheduleCounter(name, label string) + func (m *Metric) Run() + func (m *Metric) Stop() + type MetricConfig struct + Address string + Interval util.Duration + Server MetricServer + type MetricServer struct + Address string + QueueNum uint64 + StoreType string + StoreUrl []string + type MockDs struct + NodeId uint64 + RpcAddr string + func NewMockDs(rpcAddr string) *MockDs + func (ds *MockDs) SetNodeId(id uint64) + type Node struct + LastHeartbeatTS time.Time + Trace bool + func NewNode(node *metapb.Node) *Node + func SelectLeaderNode(nodes []*Node, selectors []NodeSelector, mostLeaderNum float64) *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 struct + func NewNodeCache() *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 struct + LastHbTime time.Time + LastOpt *taskpb.Task + LastSchTime time.Time + Ranges []*Range + type NodeLoginSelector struct + func NewNodeLoginSelector(opt *scheduleOption) *NodeLoginSelector + func (sel *NodeLoginSelector) CanSelect(node *Node) bool + func (sel *NodeLoginSelector) Name() string + type NodeOpsStat struct + func (opsStat *NodeOpsStat) Clear() uint64 + func (opsStat *NodeOpsStat) GetMax() uint64 + func (opsStat *NodeOpsStat) Hit(v uint64) + type NodeSelector interface + CanSelect func(node *Node) bool + Name func() string + type Peer struct + ID uint64 + RaftHeartbeatAddr string + RaftReplicateAddr string + RpcServerAddr string + WebManageAddr string + func (p *Peer) GetId() uint64 + type Proxy struct + type RaftConfig struct + HeartbeatInterval util.Duration + RetainLogsCount uint64 + type RaftStore struct + func NewRaftStore(conf *StoreConfig) (*RaftStore, error) + 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 struct + ApproximateSize uint64 + BytesRead uint64 + BytesWritten uint64 + DownPeers []*mspb.PeerStats + KeysRead uint64 + KeysWritten uint64 + LastHbTimeTS time.Time + Leader *metapb.Peer + PendingPeers []*metapb.Peer + State metapb.RangeState + Trace bool + func NewRange(r *metapb.Range, leader *metapb.Peer) *Range + func (r *Range) GetDownPeer(peerID uint64) *metapb.Peer + func (r *Range) GetDownPeers() []*metapb.Peer + 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) ID() uint64 + func (r *Range) IsHealthy() bool + func (r *Range) RemoveNodePeer(NodeID uint64) + func (r *Range) SString() string + type RangeCache struct + func NewRangeCache() *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 struct + DownPeers []*mspb.PeerStats + LastHbTime time.Time + Leader *metapb.Peer + PendingPeers []*metapb.Peer + Task *taskpb.Task + type RangeEvent interface + ExecTime func() time.Duration + Execute func(cluster *Cluster, r *Range) (ExecNextEvent, *taskpb.Task, error) + GetId func() uint64 + GetRangeID func() uint64 + GetStatus func() EventStatus + GetType func() EventType + IsClosed func() bool + IsTimeout func() bool + Next func() RangeEvent + String func() string + func NewChangePeerEvent(id uint64, rng *Range, oldPeer, newPeer *metapb.Peer, creator string) RangeEvent + type RangeEventMeta struct + func NewRangeEvent(id, rangeId uint64, eventType EventType, timeout time.Duration, creator string, ...) RangeEventMeta + func (m *RangeEventMeta) ExecTime() time.Duration + func (m *RangeEventMeta) GetId() uint64 + func (m *RangeEventMeta) GetRangeID() uint64 + func (m *RangeEventMeta) GetStatus() EventStatus + func (m *RangeEventMeta) GetType() EventType + func (m *RangeEventMeta) IsClosed() bool + func (m *RangeEventMeta) IsTimeout() bool + func (m *RangeEventMeta) Next() RangeEvent + func (m *RangeEventMeta) String() string + type RangeOpsStat struct + func (opsStat *RangeOpsStat) Clear() uint64 + func (opsStat *RangeOpsStat) GetMax() uint64 + func (opsStat *RangeOpsStat) Hit(v uint64) + type RegionCache struct + func NewRegionCache() *RegionCache + func (rc *RegionCache) Add(r *Range) + func (rc *RegionCache) Delete(id uint64) + func (rc *RegionCache) FindRangeByID(id uint64) (*Range, bool) + func (rc *RegionCache) GetAllRange() []*Range + func (rc *RegionCache) GetRandomRange() *Range + func (rc *RegionCache) Size() int + type RegionHbCheckWorker struct + func (hb *RegionHbCheckWorker) AllowWork(cluster *Cluster) bool + func (hb *RegionHbCheckWorker) GetInterval() time.Duration + func (hb *RegionHbCheckWorker) GetName() string + func (hb *RegionHbCheckWorker) Stop() + func (hb *RegionHbCheckWorker) Work(cluster *Cluster) + type ReplicaCache struct + func NewReplicaCache() *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 struct + LocationLabels util.StringSlice + MaxReplicas uint64 + type Resolver struct + func NewResolver(nodes map[uint64]*Peer) *Resolver + func (r *Resolver) NodeAddress(nodeID uint64, stype raft.SocketType) (addr string, err error) + type RunMode int + const RUN_MODE_INIT + const RUN_MODE_LOCAL + const RUN_MODE_REMOTE + type SaveBatch struct + func NewSaveBatch(raft *raftgroup.RaftGroup) *SaveBatch + func (b *SaveBatch) Commit() error + func (b *SaveBatch) Delete(key []byte) + func (b *SaveBatch) Put(key, value []byte) + type ScheduleConfig struct + LeaderScheduleLimit uint64 + MaxNodeDownTime util.Duration + MaxRangeDownTime util.Duration + MaxSnapshotCount uint64 + MaxTaskTimeout util.Duration + NodeRangeBalanceTime util.Duration + RegionScheduleLimit uint64 + ReplicaScheduleLimit uint64 + StorageAvailableThreshold uint64 + WriteByteOpsThreshold uint64 + type Server struct + 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 func(w http.ResponseWriter, r *http.Request) bool + type SnapshotCountLimitSelector struct + func NewSnapshotCountLimitSelector(opt *scheduleOption) *SnapshotCountLimitSelector + func (sel *SnapshotCountLimitSelector) CanSelect(node *Node) bool + func (sel *SnapshotCountLimitSelector) Name() string + type StorageThresholdSelector struct + func NewStorageThresholdSelector(opt *scheduleOption) *StorageThresholdSelector + func (sel *StorageThresholdSelector) CanSelect(node *Node) bool + func (sel *StorageThresholdSelector) Name() string + type Store interface + Close func() error + Delete func(key []byte) error + Get func(key []byte) ([]byte, error) + NewBatch func() Batch + Open func() error + Put func(key, value []byte) error + Scan func(startKey, limitKey []byte) Iterator + func NewLevelDBDriver(path string) (Store, error) + type StoreConfig struct + DataPath string + FatalHandler raftgroup.RaftFatalEventHandler + LeaderChangeHandler raftgroup.RaftLeaderChangeHandler + NodeID uint64 + RaftHeartbeatAddr string + RaftHeartbeatInterval time.Duration + RaftPeers []*Peer + RaftReplicateAddr string + RaftRetainLogs int64 + type Table struct + func NewTable(t *metapb.Table) *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 struct + func NewTableCache() *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 struct + Columns []*metapb.Column + Regxs []*metapb.Column + type TrashReplicaGCWorker struct + func (tr *TrashReplicaGCWorker) AllowWork(cluster *Cluster) bool + func (tr *TrashReplicaGCWorker) GetInterval() time.Duration + func (tr *TrashReplicaGCWorker) GetName() string + func (tr *TrashReplicaGCWorker) Stop() + func (tr *TrashReplicaGCWorker) Work(cluster *Cluster) + type TryChangeLeaderEvent struct + func NewTryChangeLeaderEvent(id, rangeId uint64, preLeader, expLeader *metapb.Peer, creator string) *TryChangeLeaderEvent + func (e *TryChangeLeaderEvent) Execute(cluster *Cluster, r *Range) (ExecNextEvent, *taskpb.Task, error) + type ValidHandler func(w http.ResponseWriter, r *http.Request) bool + type Worker interface + AllowWork func(cluster *Cluster) bool + GetInterval func() time.Duration + GetName func() string + Stop func() + Work func(cluster *Cluster) + 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 struct + func NewWorkerManager(cluster *Cluster, opt *scheduleOption) *WorkerManager + func (wm *WorkerManager) GetAllWorker() []string + func (wm *WorkerManager) GetWorker(workerName string) string + func (wm *WorkerManager) Run() + func (wm *WorkerManager) Stop() + type WriterOpsThresholdSelector struct + func NewWriterOpsThresholdSelector(opt *scheduleOption) *WriterOpsThresholdSelector + func (sel *WriterOpsThresholdSelector) CanSelect(node *Node) bool + func (sel *WriterOpsThresholdSelector) Name() string