Documentation ¶
Index ¶
- Constants
- Variables
- type ApiClient
- func (c *ApiClient) AddSentinel(addr string) error
- func (c *ApiClient) CreateGroup(gid int) error
- func (c *ApiClient) CreateProxy(addr string) error
- func (c *ApiClient) DelSentinel(addr string, force bool) error
- func (c *ApiClient) EnableReplicaGroups(gid int, addr string, value bool) error
- func (c *ApiClient) EnableReplicaGroupsAll(value bool) error
- func (c *ApiClient) GroupAddServer(gid int, dc, addr string) error
- func (c *ApiClient) GroupDelServer(gid int, addr string) error
- func (c *ApiClient) GroupPromoteServer(gid int, addr string) error
- func (c *ApiClient) LogLevel(level log.LogLevel) error
- func (c *ApiClient) Model() (*models.Topom, error)
- func (c *ApiClient) OnlineProxy(addr string) error
- func (c *ApiClient) Overview() (*Overview, error)
- func (c *ApiClient) ReinitProxy(token string) error
- func (c *ApiClient) Reload() error
- func (c *ApiClient) RemoveGroup(gid int) error
- func (c *ApiClient) RemoveProxy(token string, force bool) error
- func (c *ApiClient) ResyncGroup(gid int) error
- func (c *ApiClient) ResyncGroupAll() error
- func (c *ApiClient) ResyncSentinels() error
- func (c *ApiClient) SetSlotActionDisabled(disabled bool) error
- func (c *ApiClient) SetSlotActionInterval(usecs int) error
- func (c *ApiClient) SetXAuth(name string)
- func (c *ApiClient) Shutdown() error
- func (c *ApiClient) SlotCreateAction(sid int, gid int) error
- func (c *ApiClient) SlotCreateActionRange(beg, end int, gid int) error
- func (c *ApiClient) SlotCreateActionSome(groupFrom, groupTo int, numSlots int) error
- func (c *ApiClient) SlotRemoveAction(sid int) error
- func (c *ApiClient) Slots() ([]*models.Slot, error)
- func (c *ApiClient) SlotsAssignGroup(slots []*models.SlotMapping) error
- func (c *ApiClient) SlotsAssignOffline(slots []*models.SlotMapping) error
- func (c *ApiClient) SlotsRebalance(confirm bool) (map[int]int, error)
- func (c *ApiClient) Stats() (*Stats, error)
- func (c *ApiClient) SyncCreateAction(addr string) error
- func (c *ApiClient) SyncRemoveAction(addr string) error
- func (c *ApiClient) XPing() error
- type Config
- type Overview
- type ProxyStats
- type RedisStats
- type Stats
- type Topom
- func (s *Topom) AddSentinel(addr string) error
- func (s *Topom) Close() error
- func (s *Topom) Config() *Config
- func (s *Topom) CreateGroup(gid int) error
- func (s *Topom) CreateProxy(addr string) error
- func (s *Topom) DelSentinel(addr string, force bool) error
- func (s *Topom) EnableReplicaGroups(gid int, addr string, value bool) error
- func (s *Topom) EnableReplicaGroupsAll(value bool) error
- func (s *Topom) GetSlotActionDisabled() bool
- func (s *Topom) GetSlotActionInterval() int
- func (s *Topom) GroupAddServer(gid int, dc, addr string) error
- func (s *Topom) GroupDelServer(gid int, addr string) error
- func (s *Topom) GroupPromoteServer(gid int, addr string) error
- func (s *Topom) IsClosed() bool
- func (s *Topom) IsOnline() bool
- func (s *Topom) Model() *models.Topom
- func (s *Topom) OnlineProxy(addr string) error
- func (s *Topom) Overview() (*Overview, error)
- func (s *Topom) ProcessSlotAction() error
- func (s *Topom) ProcessSyncAction() error
- func (s *Topom) RefreshProxyStats(timeout time.Duration) (*sync2.Future, error)
- func (s *Topom) RefreshRedisStats(timeout time.Duration) (*sync2.Future, error)
- func (s *Topom) ReinitProxy(token string) error
- func (s *Topom) Reload() error
- func (s *Topom) RemoveGroup(gid int) error
- func (s *Topom) RemoveProxy(token string, force bool) error
- func (s *Topom) ResyncGroup(gid int) error
- func (s *Topom) ResyncGroupAll() error
- func (s *Topom) ResyncSentinels() error
- func (s *Topom) SetSlotActionDisabled(value bool)
- func (s *Topom) SetSlotActionInterval(us int)
- func (s *Topom) SlotActionComplete(sid int) error
- func (s *Topom) SlotActionPrepare() (int, bool, error)
- func (s *Topom) SlotActionPrepareFilter(accept, update func(m *models.SlotMapping) bool) (int, bool, error)
- func (s *Topom) SlotCreateAction(sid int, gid int) error
- func (s *Topom) SlotCreateActionRange(beg, end int, gid int, must bool) error
- func (s *Topom) SlotCreateActionSome(groupFrom, groupTo int, numSlots int) error
- func (s *Topom) SlotRemoveAction(sid int) error
- func (s *Topom) Slots() ([]*models.Slot, error)
- func (s *Topom) SlotsAssignGroup(slots []*models.SlotMapping) error
- func (s *Topom) SlotsAssignOffline(slots []*models.SlotMapping) error
- func (s *Topom) SlotsRebalance(confirm bool) (map[int]int, error)
- func (s *Topom) Start(routines bool) error
- func (s *Topom) Stats() (*Stats, error)
- func (s *Topom) SwitchMasters(masters map[int]string) error
- func (s *Topom) SyncActionComplete(addr string, failed bool) error
- func (s *Topom) SyncActionPrepare() (string, error)
- func (s *Topom) SyncCreateAction(addr string) error
- func (s *Topom) SyncRemoveAction(addr string) error
- func (s *Topom) XAuth() string
Constants ¶
const DefaultConfig = `` /* 1214-byte string literal not displayed */
const MaxSlotNum = models.MaxSlotNum
Variables ¶
var ErrClosedTopom = errors.New("use of closed topom")
var ErrNotOnline = errors.New("topom is not online")
Functions ¶
This section is empty.
Types ¶
type ApiClient ¶
type ApiClient struct {
// contains filtered or unexported fields
}
func NewApiClient ¶
func (*ApiClient) AddSentinel ¶
func (*ApiClient) CreateGroup ¶
func (*ApiClient) CreateProxy ¶
func (*ApiClient) EnableReplicaGroups ¶
func (*ApiClient) EnableReplicaGroupsAll ¶
func (*ApiClient) GroupAddServer ¶
func (*ApiClient) GroupPromoteServer ¶
func (*ApiClient) OnlineProxy ¶
func (*ApiClient) ReinitProxy ¶
func (*ApiClient) RemoveGroup ¶
func (*ApiClient) ResyncGroup ¶
func (*ApiClient) ResyncGroupAll ¶
func (*ApiClient) ResyncSentinels ¶
func (*ApiClient) SetSlotActionDisabled ¶
func (*ApiClient) SetSlotActionInterval ¶
func (*ApiClient) SlotCreateActionRange ¶
func (*ApiClient) SlotCreateActionSome ¶
func (*ApiClient) SlotRemoveAction ¶
func (*ApiClient) SlotsAssignGroup ¶
func (c *ApiClient) SlotsAssignGroup(slots []*models.SlotMapping) error
func (*ApiClient) SlotsAssignOffline ¶
func (c *ApiClient) SlotsAssignOffline(slots []*models.SlotMapping) error
func (*ApiClient) SlotsRebalance ¶
func (*ApiClient) SyncCreateAction ¶
func (*ApiClient) SyncRemoveAction ¶
type Config ¶
type Config struct { CoordinatorName string `toml:"coordinator_name" json:"coordinator_name"` CoordinatorAddr string `toml:"coordinator_addr" json:"coordinator_addr"` CoordinatorAuth string `toml:"coordinator_auth" json:"coordinator_auth"` AdminAddr string `toml:"admin_addr" json:"admin_addr"` HostAdmin string `toml:"-" json:"-"` ProductName string `toml:"product_name" json:"product_name"` ProductAuth string `toml:"product_auth" json:"-"` MigrationMethod string `toml:"migration_method" json:"migration_method"` MigrationParallelSlots int `toml:"migration_parallel_slots" json:"migration_parallel_slots"` MigrationAsyncMaxBulks int `toml:"migration_async_maxbulks" json:"migration_async_maxbulks"` MigrationAsyncMaxBytes bytesize.Int64 `toml:"migration_async_maxbytes" json:"migration_async_maxbytes"` MigrationAsyncNumKeys int `toml:"migration_async_numkeys" json:"migration_async_numkeys"` MigrationTimeout timesize.Duration `toml:"migration_timeout" json:"migration_timeout"` SentinelClientTimeout timesize.Duration `toml:"sentinel_client_timeout" json:"sentinel_client_timeout"` SentinelQuorum int `toml:"sentinel_quorum" json:"sentinel_quorum"` SentinelParallelSyncs int `toml:"sentinel_parallel_syncs" json:"sentinel_parallel_syncs"` SentinelDownAfter timesize.Duration `toml:"sentinel_down_after" json:"sentinel_down_after"` SentinelFailoverTimeout timesize.Duration `toml:"sentinel_failover_timeout" json:"sentinel_failover_timeout"` SentinelNotificationScript string `toml:"sentinel_notification_script" json:"sentinel_notification_script"` SentinelClientReconfigScript string `toml:"sentinel_client_reconfig_script" json:"sentinel_client_reconfig_script"` }
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
func (*Config) LoadFromFile ¶
type ProxyStats ¶
type RedisStats ¶
type RedisStats struct { //储存了集群中Redis服务器的各种信息和统计数值,详见redis的info命令 Stats map[string]string `json:"stats,omitempty"` Error *rpc.RemoteError `json:"error,omitempty"` Sentinel map[string]*redis.SentinelGroup `json:"sentinel,omitempty"` UnixTime int64 `json:"unixtime"` Timeout bool `json:"timeout,omitempty"` }
type Stats ¶
type Stats struct { Closed bool `json:"closed"` Slots []*models.SlotMapping `json:"slots"` Group struct { Models []*models.Group `json:"models"` Stats map[string]*RedisStats `json:"stats"` } `json:"group"` Proxy struct { Models []*models.Proxy `json:"models"` Stats map[string]*ProxyStats `json:"stats"` } `json:"proxy"` SlotAction struct { Interval int64 `json:"interval"` Disabled bool `json:"disabled"` Progress struct { Status string `json:"status"` } `json:"progress"` Executor int64 `json:"executor"` } `json:"slot_action"` HA struct { Model *models.Sentinel `json:"model"` Stats map[string]*RedisStats `json:"stats"` Masters map[string]string `json:"masters"` } `json:"sentinels"` }
type Topom ¶
type Topom struct {
// contains filtered or unexported fields
}
func New ¶
创建topom的方法如下所示,这里传入的client,是根据coordinator创建的zkClient 其中会构建出三个redis.Pool 分别在action/stats/ha结构中, 只是把基础的数据结构构建出来
func (*Topom) AddSentinel ¶
func (*Topom) CreateGroup ¶
func (*Topom) EnableReplicaGroups ¶
func (*Topom) EnableReplicaGroupsAll ¶
func (*Topom) GetSlotActionDisabled ¶
func (*Topom) GetSlotActionInterval ¶
func (*Topom) GroupAddServer ¶
将server挂在group下,传入的gid就是group id,addr是codis-server的地址,datacenter由于没有填写,所以dc是空字符串
func (*Topom) OnlineProxy ¶
func (*Topom) ProcessSlotAction ¶
func (*Topom) ProcessSyncAction ¶
func (*Topom) RefreshProxyStats ¶
刷新proxy状态,将每一个proxy.Token和ProxyStats的关系map对应起来,存入Topom.stats.proxies中
func (*Topom) RefreshRedisStats ¶
func (*Topom) ReinitProxy ¶
func (*Topom) RemoveGroup ¶
func (*Topom) ResyncGroup ¶
func (*Topom) ResyncGroupAll ¶
func (*Topom) ResyncSentinels ¶
func (*Topom) SetSlotActionDisabled ¶
func (*Topom) SetSlotActionInterval ¶
func (*Topom) SlotActionComplete ¶
func (*Topom) SlotActionPrepareFilter ¶
func (*Topom) SlotCreateActionRange ¶
func (*Topom) SlotCreateActionSome ¶
func (*Topom) SlotRemoveAction ¶
func (*Topom) SlotsAssignGroup ¶
func (s *Topom) SlotsAssignGroup(slots []*models.SlotMapping) error
func (*Topom) SlotsAssignOffline ¶
func (s *Topom) SlotsAssignOffline(slots []*models.SlotMapping) error
func (*Topom) SlotsRebalance ¶
第一次进入的时候传入的confirm是false,因为只是指定rebalance的plan 当页面上弹窗问是否迁移的时候,点了OK,又会进入这个方法,传入confirm为true
func (*Topom) SyncActionComplete ¶
func (*Topom) SyncActionPrepare ¶
使用s.newContext()获取上下文,从上下文中 遍历每个group中的每个codis-server,从Action.State为pending的codis-server中,选出Action.Index最小的那台服务器,并获取其所在的group 如果这个group的Promoting.State为nothing,这台服务器就可以从主服务器同步数据 将这个codis-server的Action.Index设为0,Action.State设为syncing 更新zk中存储的信息,并将cache中关于这台服务器的信息设为nil,这样下次就会从store中重新载入数据到cache。
func (*Topom) SyncCreateAction ¶
group中添加两个codis-server后 将一个设置为另一个的slave