本文整理汇总了Golang中github.com/redhat-cip/skydive/topology/graph.Graph类的典型用法代码示例。如果您正苦于以下问题:Golang Graph类的具体用法?Golang Graph怎么用?Golang Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Graph类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: startTopologyClient
func startTopologyClient(t *testing.T, g *graph.Graph, onReady func(*websocket.Conn), onChange func(*websocket.Conn)) error {
// ready when got a first ping
ws, err := connectToAgent(5, onReady)
if err != nil {
return err
}
for {
_, m, err := ws.ReadMessage()
if err != nil {
break
}
err = processGraphMessage(g, m)
if err != nil {
return err
}
logging.GetLogger().Debug("%s", string(m))
logging.GetLogger().Debug("%s", g.String())
onChange(ws)
}
return nil
}
开发者ID:mestery,项目名称:skydive,代码行数:26,代码来源:topology_test.go
示例2: LookupNodeFromNodePathString
func LookupNodeFromNodePathString(g *graph.Graph, s string) *graph.Node {
parts := strings.Split(s, "/")
m, err := nodePathPartToMetadata(parts[0])
if err != nil {
logging.GetLogger().Errorf("Unable to parse a part of node path string (%s): %s", parts[0], err.Error())
return nil
}
node := g.LookupFirstNode(m)
if node == nil {
return nil
}
for _, part := range parts[1:] {
m, err := nodePathPartToMetadata(part)
if err != nil {
return nil
}
node = g.LookupFirstChild(node, m)
if node == nil {
return nil
}
}
return node
}
开发者ID:fdebonneval,项目名称:skydive,代码行数:28,代码来源:topology.go
示例3: testCleanup
func testCleanup(t *testing.T, g *graph.Graph, cmds []string, ints []string) {
// cleanup side on the test
testPassed := false
onChange := func(ws *websocket.Conn) {
g.Lock()
defer g.Unlock()
if !testPassed {
clean := true
for _, intf := range ints {
n := g.LookupFirstNode(graph.Metadatas{"Name": intf})
if n != nil {
clean = false
break
}
}
if clean {
testPassed = true
ws.Close()
}
}
}
testTopology(t, g, cmds, onChange)
if !testPassed {
t.Error("test not executed or failed")
}
}
开发者ID:mestery,项目名称:skydive,代码行数:30,代码来源:topology_test.go
示例4: NewNeutronMapper
func NewNeutronMapper(g *graph.Graph, authURL string, username string, password string, tenantName string, regionName string) (*NeutronMapper, error) {
mapper := &NeutronMapper{graph: g}
opts := gophercloud.AuthOptions{
IdentityEndpoint: authURL,
Username: username,
Password: password,
TenantName: tenantName,
AllowReauth: true,
}
provider, err := openstack.AuthenticatedClient(opts)
if err != nil {
return nil, err
}
/* TODO(safchain) add config param for the Availability */
client, err := openstack.NewNetworkV2(provider, gophercloud.EndpointOpts{
Name: "neutron",
Region: regionName,
Availability: gophercloud.AvailabilityPublic,
})
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
}
开发者ID:fdebonneval,项目名称:skydive,代码行数:38,代码来源:neutron.go
示例5: processGraphMessage
func processGraphMessage(g *graph.Graph, m []byte) error {
g.Lock()
defer g.Unlock()
msg, err := graph.UnmarshalWSMessage(m)
if err != nil {
return err
}
switch msg.Type {
case "NodeUpdated":
n := msg.Obj.(*graph.Node)
node := g.GetNode(n.ID)
if node != nil {
g.SetMetadatas(node, n.Metadatas())
}
case "NodeDeleted":
g.DelNode(msg.Obj.(*graph.Node))
case "NodeAdded":
n := msg.Obj.(*graph.Node)
if g.GetNode(n.ID) == nil {
g.AddNode(n)
}
case "EdgeUpdated":
e := msg.Obj.(*graph.Edge)
edge := g.GetEdge(e.ID)
if edge != nil {
g.SetMetadatas(edge, e.Metadatas())
}
case "EdgeDeleted":
g.DelEdge(msg.Obj.(*graph.Edge))
case "EdgeAdded":
e := msg.Obj.(*graph.Edge)
if g.GetEdge(e.ID) == nil {
g.AddEdge(e)
}
}
return nil
}
开发者ID:mestery,项目名称:skydive,代码行数:40,代码来源:topology_test.go
注:本文中的github.com/redhat-cip/skydive/topology/graph.Graph类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论