mirror of https://github.com/milvus-io/milvus.git
Add comment for indexcoord nodemanager (#8603)
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>pull/8609/head
parent
c4c89a639a
commit
ea1e2dd63f
|
@ -23,6 +23,7 @@ import (
|
|||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// NodeManager is used by IndexCoord to manage the client of IndexNode.
|
||||
type NodeManager struct {
|
||||
nodeClients map[UniqueID]types.IndexNode
|
||||
pq *PriorityQueue
|
||||
|
@ -30,6 +31,7 @@ type NodeManager struct {
|
|||
lock sync.RWMutex
|
||||
}
|
||||
|
||||
// NewNodeManager is used to create a new NodeManager.
|
||||
func NewNodeManager() *NodeManager {
|
||||
return &NodeManager{
|
||||
nodeClients: make(map[UniqueID]types.IndexNode),
|
||||
|
@ -52,6 +54,7 @@ func (nm *NodeManager) setClient(nodeID UniqueID, client types.IndexNode) {
|
|||
nm.pq.Push(item)
|
||||
}
|
||||
|
||||
// RemoveNode removes the unused client of IndexNode.
|
||||
func (nm *NodeManager) RemoveNode(nodeID UniqueID) {
|
||||
nm.lock.Lock()
|
||||
defer nm.lock.Unlock()
|
||||
|
@ -61,6 +64,7 @@ func (nm *NodeManager) RemoveNode(nodeID UniqueID) {
|
|||
nm.pq.Remove(nodeID)
|
||||
}
|
||||
|
||||
// AddNode adds the client of IndexNode.
|
||||
func (nm *NodeManager) AddNode(nodeID UniqueID, address string) error {
|
||||
log.Debug("IndexCoord addNode", zap.Any("nodeID", nodeID), zap.Any("node address", address))
|
||||
if nm.pq.CheckExist(nodeID) {
|
||||
|
@ -82,6 +86,7 @@ func (nm *NodeManager) AddNode(nodeID UniqueID, address string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// PeekClient peeks the client with the least load.
|
||||
func (nm *NodeManager) PeekClient() (UniqueID, types.IndexNode) {
|
||||
nm.lock.Lock()
|
||||
defer nm.lock.Unlock()
|
||||
|
|
Loading…
Reference in New Issue