本文整理汇总了Golang中github.com/skydive-project/skydive/topology/graph.Graph.AddEventListener方法的典型用法代码示例。如果您正苦于以下问题:Golang Graph.AddEventListener方法的具体用法?Golang Graph.AddEventListener怎么用?Golang Graph.AddEventListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skydive-project/skydive/topology/graph.Graph
的用法示例。
在下文中一共展示了Graph.AddEventListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewOpenContrailMapper
func NewOpenContrailMapper(g *graph.Graph, r *graph.Node) *OpenContrailMapper {
host := config.GetConfig().GetString("opencontrail.host")
port := config.GetConfig().GetInt("opencontrail.port")
if host == "" {
host = "localhost"
}
if port == 0 {
port = 8085
}
mapper := &OpenContrailMapper{graph: g, root: r, agentHost: host, agentPort: port}
mapper.nodeUpdaterChan = make(chan graph.Identifier, 500)
g.AddEventListener(mapper)
return mapper
}
示例2: NewNeutronMapper
func NewNeutronMapper(g *graph.Graph, wsClient *shttp.WSAsyncClient, authURL, username, password, tenantName, regionName, domainName string, availability gophercloud.Availability) (*NeutronMapper, error) {
mapper := &NeutronMapper{graph: g, wsClient: wsClient}
opts := gophercloud.AuthOptions{
IdentityEndpoint: authURL,
Username: username,
Password: password,
TenantName: tenantName,
DomainName: domainName,
AllowReauth: true,
}
provider, err := openstack.AuthenticatedClient(opts)
if err != nil {
return nil, err
}
client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
Name: "neutron",
Region: regionName,
Availability: availability,
})
if err != nil {
return nil, err
}
mapper.client = client
// Create a cache with a default expiration time of 5 minutes, and which
// purges expired items every 30 seconds
expire := config.GetConfig().GetInt("cache.expire")
cleanup := config.GetConfig().GetInt("cache.cleanup")
mapper.cache = cache.New(time.Duration(expire)*time.Second, time.Duration(cleanup)*time.Second)
mapper.nodeUpdaterChan = make(chan graph.Identifier, 500)
g.AddEventListener(mapper)
return mapper, nil
}
示例3: NewFabricProbe
func NewFabricProbe(g *graph.Graph) *FabricProbe {
fb := &FabricProbe{
Graph: g,
links: make(map[*graph.Node]fabricLink),
}
g.AddEventListener(fb)
fb.Graph.Lock()
defer fb.Graph.Unlock()
list := config.GetConfig().GetStringSlice("agent.topology.fabric")
for _, link := range list {
pc := strings.Split(link, "->")
if len(pc) != 2 {
logging.GetLogger().Errorf("FabricProbe link definition should have two endpoint: %s", link)
continue
}
parentDef := strings.TrimSpace(pc[0])
childDef := strings.TrimSpace(pc[1])
if strings.HasPrefix(parentDef, "local/") {
logging.GetLogger().Error("FabricProbe doesn't support local node as parent node")
continue
}
if strings.HasPrefix(childDef, "local/") {
// Fabric Node to Local Node
childDef = strings.TrimPrefix(childDef, "local/")
parentNode, err := fb.addFabricNodeFromDef(parentDef)
if err != nil {
logging.GetLogger().Error(err.Error())
continue
}
_, childMetadata, err := nodeDefToMetadata(childDef)
if err != nil {
logging.GetLogger().Error(err.Error())
continue
}
// queue it as the local doesn't exist at start
fb.links[parentNode] = fabricLink{metadata: childMetadata}
} else {
// Fabric Node to Fabric Node
node1, err := fb.addFabricNodeFromDef(parentDef)
if err != nil {
logging.GetLogger().Error(err.Error())
continue
}
node2, err := fb.addFabricNodeFromDef(childDef)
if err != nil {
logging.GetLogger().Error(err.Error())
continue
}
if !fb.Graph.AreLinked(node1, node2) {
fb.Graph.Link(node1, node2, graph.Metadata{"RelationType": "layer2", "Type": "fabric"})
}
}
}
return fb
}