Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActiveNode ¶
type ActiveNode struct {
// corresponding node model
Model *model.Node
// node status
Status *Status
// send check ping to the node and receive the node's information
// It SHOULD be buffered channel for non-blocking at the socket pool
Ping chan bool
// save shards on the node
Save chan []*model.ShardToSave
// load shards from the node
Load chan *LoadChan
// delete shards on the node
Delete chan []*model.ShardToDelete
// flush the deleted shard list to the node
Flush chan bool
// contains filtered or unexported fields
}
func NewActiveNode ¶
func NewActiveNode(conn *websocket.Conn, nodeModel *model.Node) *ActiveNode
func (*ActiveNode) Run ¶
func (node *ActiveNode) Run()
* Run the websocket operations using non-blocking channels.
type DataMsg ¶
type DataMsg struct {
Type string `json:"type"`
Contents interface{} `json:"contents"`
}
type SocketPool ¶
type SocketPool struct {
// mutex for all nodes' status
NodesStatusLock sync.Mutex
// registered nodes
Nodes map[*ActiveNode]bool
// register requests from the node
Register chan *ActiveNode
// unregister requests from the node
Unregister chan *ActiveNode
// contains filtered or unexported fields
}
func (*SocketPool) CheckAllNodes ¶
func (pool *SocketPool) CheckAllNodes()
* Send ping concurrently to nodes whose current status is old and wait for all pong response.
This function change nodes' status. So you SHOULD use this function with the `NodesStatusLock` which is mutex for all nodes' status.
func (*SocketPool) FindActiveNode ¶
func (pool *SocketPool) FindActiveNode(machineID string) *ActiveNode
* Find active node in the pool by machine id.
func (*SocketPool) SelectNodes ¶
func (pool *SocketPool) SelectNodes() (*ring.Ring, *ring.Ring)
* Select the nodes to save the files and sort them by node selection algorithm. Return type is ring, which is circular list, because select the nodes until all shards are scheduled.
The first return value is the safe nodes that have latest(reliable) status. The second return value is the unsafe nodes that have old(unreliable) status.
This function read nodes' status at specific time. So you SHOULD use this function with the `NodesStatusLock` which is mutex for all nodes' status.
func (*SocketPool) TotalCapacity ¶
func (pool *SocketPool) TotalCapacity() uint64