本文整理汇总了Golang中github.com/contiv/netplugin/plugin.NetPlugin.DeleteMaster方法的典型用法代码示例。如果您正苦于以下问题:Golang NetPlugin.DeleteMaster方法的具体用法?Golang NetPlugin.DeleteMaster怎么用?Golang NetPlugin.DeleteMaster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/contiv/netplugin/plugin.NetPlugin
的用法示例。
在下文中一共展示了NetPlugin.DeleteMaster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deleteMaster
// delete master node
func deleteMaster(netplugin *plugin.NetPlugin, srvInfo core.ServiceInfo) error {
// delete from the db
delete(masterDB, masterKey(srvInfo))
// tel plugin about it
return netplugin.DeleteMaster(srvInfo)
}
示例2: peerDiscoveryLoop
//.........这里部分代码省略.........
// add the node
err := netplugin.AddPeerHost(core.ServiceInfo{
HostAddr: node.HostAddr,
Port: ofnet.OFNET_AGENT_PORT,
})
if err != nil {
log.Errorf("Error adding node {%+v}. Err: %v", node, err)
}
}
// Get a list of all existing netmasters
masterList, err := objdbClient.GetService("netmaster")
if err != nil {
log.Errorf("Error getting master list from objdb. Err: %v", err)
}
log.Infof("Got netmaster service list: %+v", masterList)
// Walk each master and add it
for _, master := range masterList {
// Add the master
err := netplugin.AddMaster(core.ServiceInfo{
HostAddr: master.HostAddr,
Port: ofnet.OFNET_MASTER_PORT,
})
if err != nil {
log.Errorf("Error adding master {%+v}. Err: %v", master, err)
}
}
for {
select {
case srvEvent := <-nodeEventCh:
log.Infof("Received netplugin service watch event: %+v", srvEvent)
// collect the info about the node
nodeInfo := srvEvent.ServiceInfo
// check if its our on info coming back to us
if nodeInfo.HostAddr == localIP {
break
}
// Handle based on event type
if srvEvent.EventType == objdb.WatchServiceEventAdd {
log.Infof("Node add event for {%+v}", nodeInfo)
// add the node
err := netplugin.AddPeerHost(core.ServiceInfo{
HostAddr: nodeInfo.HostAddr,
Port: ofnet.OFNET_AGENT_PORT,
})
if err != nil {
log.Errorf("Error adding node {%+v}. Err: %v", nodeInfo, err)
}
} else if srvEvent.EventType == objdb.WatchServiceEventDel {
log.Infof("Node delete event for {%+v}", nodeInfo)
// remove the node
err := netplugin.DeletePeerHost(core.ServiceInfo{
HostAddr: nodeInfo.HostAddr,
Port: ofnet.OFNET_AGENT_PORT,
})
if err != nil {
log.Errorf("Error adding node {%+v}. Err: %v", nodeInfo, err)
}
}
case srvEvent := <-masterEventCh:
log.Infof("Received netmaster service watch event: %+v", srvEvent)
// collect the info about the node
nodeInfo := srvEvent.ServiceInfo
// Handle based on event type
if srvEvent.EventType == objdb.WatchServiceEventAdd {
log.Infof("Master add event for {%+v}", nodeInfo)
// Add the master
err := netplugin.AddMaster(core.ServiceInfo{
HostAddr: nodeInfo.HostAddr,
Port: ofnet.OFNET_MASTER_PORT,
})
if err != nil {
log.Errorf("Error adding master {%+v}. Err: %v", nodeInfo, err)
}
} else if srvEvent.EventType == objdb.WatchServiceEventDel {
log.Infof("Master delete event for {%+v}", nodeInfo)
// Delete the master
err := netplugin.DeleteMaster(core.ServiceInfo{
HostAddr: nodeInfo.HostAddr,
Port: nodeInfo.Port,
})
if err != nil {
log.Errorf("Error deletin master {%+v}. Err: %v", nodeInfo, err)
}
}
}
}
}