Documentation ¶
Index ¶
- type HashRing
- func (r *HashRing) AddNode(node *Node)
- func (r *HashRing) GetNode(key string) (uint32, string)
- func (r *HashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
- func (r *HashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string, setOffline bool) (uint32, string)
- func (r *HashRing) GetNodeUpDownNodes(NodeID string) (string, string)
- func (r *HashRing) IsOnline(ID string) bool
- func (r *HashRing) Node(ID string) *Node
- func (r *HashRing) PrintNodes()
- func (r *HashRing) RandomGetNodes(num int) []*Node
- func (r *HashRing) RemoveNode(nodeID string) bool
- func (r *HashRing) SetOffline(ID string)
- func (r *HashRing) SetOnline(ID string)
- func (r *HashRing) TraversalNRing()
- func (r *HashRing) TraversalVRing()
- func (r *HashRing) UpdateNodeDiskUsage(ID string, diskSize, freeDisk uint64)
- type Node
- type VNode
- type VWeightedNode
- type WeightedHashRing
- func (r *WeightedHashRing) AddNode(node *WeightedNode)
- func (r *WeightedHashRing) GetNode(key string) (uint32, string)
- func (r *WeightedHashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
- func (r *WeightedHashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string, setOffline bool) (uint32, string)
- func (r *WeightedHashRing) GetNodeUpDownNodes(NodeID string) (string, string)
- func (r *WeightedHashRing) IsOnline(ID string) bool
- func (r *WeightedHashRing) Node(ID string) *WeightedNode
- func (r *WeightedHashRing) PrintNodes()
- func (r *WeightedHashRing) RandomGetNodes(num int) []*WeightedNode
- func (r *WeightedHashRing) RemoveNode(nodeID string) bool
- func (r *WeightedHashRing) SetOffline(ID string)
- func (r *WeightedHashRing) SetOnline(ID string)
- func (r *WeightedHashRing) TraversalNRing()
- func (r *WeightedHashRing) TraversalVRing()
- func (r *WeightedHashRing) UpdateCopies(nodeID string, updatedCopies uint32)
- type WeightedNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashRing ¶
type HashRing struct { VRing *rbtree.Rbtree NRing *rbtree.Rbtree Nodes *sync.Map // map(NodeID => *Node) NodeStatus *sync.Map // map(NodeID => status) NodeCount uint32 NodeOkCount uint32 NumberOfVirtual uint32 sync.Mutex }
func (*HashRing) GetNode ¶
GetNode calculates an index from the given key, and returns a node selected using this index
func (*HashRing) GetNodeByIndex ¶
func (*HashRing) GetNodeExcludedNodeIDs ¶
func (r *HashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string, setOffline bool) (uint32, string)
GetNodeExcludedNodeIDs calculates an index from the given key, and returns a node selected using this index. The nodes with IDs specified by NodeIDs will be excluded. If setOffline is true, the excluded nodes will become offline.
func (*HashRing) GetNodeUpDownNodes ¶
GetNodeUpDownNodes get upstream of downstream of node
func (*HashRing) PrintNodes ¶
func (r *HashRing) PrintNodes()
PrintNodes print all non-virtual nodes
func (*HashRing) RandomGetNodes ¶
RandomGetNodes return random nodes from the hashring
func (*HashRing) RemoveNode ¶
func (*HashRing) SetOffline ¶
func (*HashRing) TraversalNRing ¶
func (r *HashRing) TraversalNRing()
TraversalNRing traverse non-virtual rbtree
func (*HashRing) TraversalVRing ¶
func (r *HashRing) TraversalVRing()
TraversalVRing traverse virtual rbtree
func (*HashRing) UpdateNodeDiskUsage ¶ added in v0.9.0
type Node ¶
func (*Node) SetDiskUsage ¶ added in v0.9.0
type VWeightedNode ¶ added in v0.5.0
VWeightedNode virtual node
type WeightedHashRing ¶ added in v0.5.0
type WeightedHashRing struct { VRing *rbtree.Rbtree NRing *rbtree.Rbtree Nodes *sync.Map // map(NodeID => *WeightedNode) NodeStatus *sync.Map // map(NodeID => status) NodeCount uint32 NodeOkCount uint32 NumberOfVirtual uint32 sync.Mutex }
func NewWeightedHashRing ¶ added in v0.5.0
func NewWeightedHashRing() *WeightedHashRing
func (*WeightedHashRing) AddNode ¶ added in v0.5.0
func (r *WeightedHashRing) AddNode(node *WeightedNode)
func (*WeightedHashRing) GetNode ¶ added in v0.5.0
func (r *WeightedHashRing) GetNode(key string) (uint32, string)
GetNode calculates an index from the given key, and returns a node selected using this index
func (*WeightedHashRing) GetNodeByIndex ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeByIndex(keyIndex uint32) (uint32, string)
func (*WeightedHashRing) GetNodeExcludedNodeIDs ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeExcludedNodeIDs(key string, NodeIDs []string, setOffline bool) (uint32, string)
GetNodeExcludedNodeIDs calculates an index from the given key, and returns a node selected using this index. The nodes with IDs specified by NodeIDs will be excluded. If setOffline is true, the excluded nodes will become offline.
func (*WeightedHashRing) GetNodeUpDownNodes ¶ added in v0.5.0
func (r *WeightedHashRing) GetNodeUpDownNodes(NodeID string) (string, string)
GetNodeUpDownNodes get upstream of downstream of node
func (*WeightedHashRing) IsOnline ¶ added in v0.5.0
func (r *WeightedHashRing) IsOnline(ID string) bool
func (*WeightedHashRing) Node ¶ added in v0.5.0
func (r *WeightedHashRing) Node(ID string) *WeightedNode
func (*WeightedHashRing) PrintNodes ¶ added in v0.5.0
func (r *WeightedHashRing) PrintNodes()
PrintNodes print all non-virtual nodes
func (*WeightedHashRing) RandomGetNodes ¶ added in v0.5.0
func (r *WeightedHashRing) RandomGetNodes(num int) []*WeightedNode
RandomGetNodes return random nodes from the hashring
func (*WeightedHashRing) RemoveNode ¶ added in v0.5.0
func (r *WeightedHashRing) RemoveNode(nodeID string) bool
func (*WeightedHashRing) SetOffline ¶ added in v0.5.0
func (r *WeightedHashRing) SetOffline(ID string)
func (*WeightedHashRing) SetOnline ¶ added in v0.5.0
func (r *WeightedHashRing) SetOnline(ID string)
func (*WeightedHashRing) TraversalNRing ¶ added in v0.5.0
func (r *WeightedHashRing) TraversalNRing()
TraversalNRing traverse non-virtual rbtree
func (*WeightedHashRing) TraversalVRing ¶ added in v0.5.0
func (r *WeightedHashRing) TraversalVRing()
TraversalVRing traverse virtual rbtree
func (*WeightedHashRing) UpdateCopies ¶ added in v0.10.0
func (r *WeightedHashRing) UpdateCopies(nodeID string, updatedCopies uint32)