Documentation ¶
Index ¶
- Constants
- Variables
- func ActionGC(zkConn zkhelper.Conn, productName string, gcType int, keep int) error
- func ActionPath(product string, seq string) string
- func CliDir(product string) string
- func CliPath(product string, name string) string
- func CreateActionRootPath(zkConn zkhelper.Conn, path string) error
- func ExtraSeqList(nodes []string) ([]string, error)
- func ForceRemoveLock(zkConn zkhelper.Conn, productName string) error
- func GetWatchActionDir(product string) string
- func GroupDir(product string) string
- func GroupPath(product string, gid int) string
- func LockPath(product string) string
- func NewClient(coordinator string, addrlist string, auth string, timeout time.Duration) (client.Client, error)
- func ProductDir(product string) string
- func ProxyDir(product string) string
- func ProxyPath(product string, id string) string
- func ServerDir(product string) string
- func ServerPath(product string, addr string) string
- func SlotDir(product string) string
- func SlotPath(product string, sid int) string
- func ValidateProduct(name string) error
- type Action
- type ActionType
- type Lock
- type ProxyInfo
- type Server
- type ServerGroup
- type ServerInfo
- type ServerType
- type Slot
- type SlotMigrateStatus
- type SlotMultiSetParam
- type SlotState
- type SlotStatus
- type Store
- func (s *Store) Acquire(topom *Topom) error
- func (s *Store) ActionPath(seq string) string
- func (s *Store) CheckAsOnlyMaster(sg *ServerGroup) (*Server, error)
- func (s *Store) CliDir() string
- func (s *Store) CliPath(name string) string
- func (s *Store) Client() client.Client
- func (s *Store) Close() error
- func (s *Store) CreateActoinInOrderer(a *Action) (p string, err error)
- func (s *Store) DeleteAction(id int) error
- func (s *Store) DeleteGroup(gid int) error
- func (s *Store) DeletePath(path string) error
- func (s *Store) DeleteProxy(id string) error
- func (s *Store) DeleteServer(addr string) error
- func (s *Store) DeleteSlot(sid int) error
- func (s *Store) Exists(path string) (bool, error)
- func (s *Store) GetActionObject(seq string, act interface{}) error
- func (s *Store) GetActionSeqList() ([]string, error)
- func (s *Store) GetActionWithSeq(seq string) (*Action, error)
- func (s *Store) GetMigratingSlots() ([]Slot, error)
- func (s *Store) GetServer(addr string, must bool) (*Server, error)
- func (s *Store) GetServerByPath(path string, must bool) (*Server, error)
- func (s *Store) GetServers(sg *ServerGroup) ([]Server, error)
- func (s *Store) GetSlot(sid int, must bool) (*Slot, error)
- func (s *Store) GroupDir() string
- func (s *Store) GroupExists(gid int) (bool, error)
- func (s *Store) GroupPath(gid int) string
- func (s *Store) InitSlotSet(productName string, totalSlotNum int) error
- func (s *Store) ListGroup() (map[int]*ServerGroup, error)
- func (s *Store) LoadGroup(gid int, must bool) (*ServerGroup, error)
- func (s *Store) LoadProxy(id string) (*ProxyInfo, error)
- func (s *Store) LoadTopom(must bool) (*Topom, error)
- func (s *Store) Lock() error
- func (s *Store) LockPath() string
- func (s *Store) Master(sg *ServerGroup) (*Server, error)
- func (s *Store) NewAction(actionType ActionType, target interface{}, desc string, needConfirm bool) (err error)
- func (s *Store) ProxyDir() string
- func (s *Store) ProxyPath(id string) string
- func (s *Store) RegisterActiveCli(l *Lock) error
- func (s *Store) Release() error
- func (s *Store) ServerDir() string
- func (s *Store) ServerPath(addr string) string
- func (s *Store) SetMigrateStatus(slot *Slot, fromGroup, toGroup int) error
- func (s *Store) SetSlotRange(productName string, fromSlot, toSlot, groupId int, status SlotStatus) error
- func (s *Store) SlotDir() string
- func (s *Store) SlotPath(sid int) string
- func (s *Store) Slots() ([]Slot, error)
- func (s *Store) UnLock() error
- func (s *Store) UnregisterActiveCli(name string) error
- func (s *Store) UpdateGroup(g *ServerGroup) error
- func (s *Store) UpdateProxy(proxyInfo *ProxyInfo) error
- func (s *Store) UpdateServer(server *Server) error
- func (s *Store) UpdateSlot(m *Slot) error
- func (s *Store) UpdateSlotWithoutAction(m *Slot) error
- func (s *Store) WatchActions() (<-chan client.Event, []string, error)
- type Topom
Constants ¶
View Source
const ( GC_TYPE_N = iota + 1 GC_TYPE_SEC )
View Source
const ( PROXY_STATE_ONLINE = "online" PROXY_STATE_OFFLINE = "offline" PROXY_STATE_MARK_OFFLINE = "mark_offline" )
View Source
const BaseDir = "/icefire"
View Source
const (
INVALID_ID = -1
)
Variables ¶
View Source
var ( ErrSlotAlreadyExists = errors.New("slots already exists") ErrUnknownSlotStatus = errors.New("unknown slot status, slot status should be (online, offline, migrate, pre_migrate)") )
View Source
var ErrGroupMasterNotFound = errors.New("group master not found")
View Source
var ErrReceiverTimeout = errors.New("receiver timeout")
Functions ¶
func ActionPath ¶
func ExtraSeqList ¶
func GetWatchActionDir ¶
func ProductDir ¶
func ServerPath ¶
func ValidateProduct ¶
Types ¶
type Action ¶
type Action struct { Type ActionType `json:"type"` Desc string `json:"desc"` Target interface{} `json:"target"` Ts string `json:"ts"` // timestamp Receivers []string `json:"receivers"` }
type ActionType ¶
type ActionType string
const ( ACTION_TYPE_SERVER_GROUP_CHANGED ActionType = "group_changed" ACTION_TYPE_SERVER_GROUP_REMOVE ActionType = "group_remove" ACTION_TYPE_SLOT_CHANGED ActionType = "slot_changed" ACTION_TYPE_MULTI_SLOT_CHANGED ActionType = "multi_slot_changed" ACTION_TYPE_SLOT_MIGRATE ActionType = "slot_migrate" ACTION_TYPE_SLOT_PREMIGRATE ActionType = "slot_premigrate" )
type ProxyInfo ¶
type Server ¶
type Server struct { ID int `json:"id"` GroupId int `json:"group_id"` Addr string `json:"addr"` Type ServerType `json:"type"` // todo remove }
func NewServer ¶
func NewServer(serverType ServerType, addr string) *Server
type ServerGroup ¶
type ServerGroup struct { Id int `json:"id"` ProductName string `json:"product_name"` Servers []Server `json:"servers"` }
func NewServerGroup ¶
func NewServerGroup(productName string, id int) *ServerGroup
func (*ServerGroup) Encode ¶
func (g *ServerGroup) Encode() []byte
func (*ServerGroup) ServerExists ¶
func (self *ServerGroup) ServerExists(addr string) (bool, error)
func (ServerGroup) String ¶
func (self ServerGroup) String() string
type ServerInfo ¶
type ServerInfo struct { Addr string `json:"addr"` Type ServerType `json:"type"` }
type ServerType ¶
type ServerType string
const ( ServerTypeLeader ServerType = "leader" ServerTypeFollower ServerType = "follower" ServerTypeCandidate ServerType = "candidate" ServerTypeOffline ServerType = "offline" )
type Slot ¶
type SlotMigrateStatus ¶
type SlotMultiSetParam ¶
type SlotMultiSetParam struct { From int `json:"from"` To int `json:"to"` Status SlotStatus `json:"status"` GroupId int `json:"group_id"` }
type SlotState ¶
type SlotState struct { Status SlotStatus `json:"status"` MigrateStatus SlotMigrateStatus `json:"migrate_status"` LastOpTs string `json:"last_op_ts"` // operation timestamp }
type SlotStatus ¶
type SlotStatus string
const ( SLOT_STATUS_ONLINE SlotStatus = "online" SLOT_STATUS_OFFLINE SlotStatus = "offline" SLOT_STATUS_MIGRATE SlotStatus = "migrate" SLOT_STATUS_PRE_MIGRATE SlotStatus = "pre_migrate" )
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) ActionPath ¶
func (*Store) CheckAsOnlyMaster ¶
func (s *Store) CheckAsOnlyMaster(sg *ServerGroup) (*Server, error)
func (*Store) CreateActoinInOrderer ¶
func (*Store) DeleteAction ¶
func (*Store) DeleteGroup ¶
func (*Store) DeletePath ¶
func (*Store) DeleteProxy ¶
func (*Store) DeleteServer ¶
func (*Store) DeleteSlot ¶
func (*Store) GetActionObject ¶
func (*Store) GetActionSeqList ¶
func (*Store) GetMigratingSlots ¶
func (*Store) GetServerByPath ¶
func (*Store) GetServers ¶
func (s *Store) GetServers(sg *ServerGroup) ([]Server, error)
todo only need sg id
func (*Store) NewAction ¶
func (s *Store) NewAction(actionType ActionType, target interface{}, desc string, needConfirm bool) (err error)
func (*Store) RegisterActiveCli ¶
func (*Store) ServerPath ¶
func (*Store) SetMigrateStatus ¶
func (*Store) SetSlotRange ¶
func (s *Store) SetSlotRange(productName string, fromSlot, toSlot, groupId int, status SlotStatus) error
func (*Store) UnregisterActiveCli ¶
func (*Store) UpdateGroup ¶
func (s *Store) UpdateGroup(g *ServerGroup) error
func (*Store) UpdateProxy ¶
func (*Store) UpdateServer ¶
func (*Store) UpdateSlot ¶
func (*Store) UpdateSlotWithoutAction ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.