本文整理匯總了Golang中github.com/weaveworks/scope/probe/process.Tree類的典型用法代碼示例。如果您正苦於以下問題:Golang Tree類的具體用法?Golang Tree怎麽用?Golang Tree使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Tree類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: tag
func (t *Tagger) tag(tree process.Tree, topology *report.Topology) {
for nodeID, node := range topology.Nodes {
pidStr, ok := node.Latest.Lookup(process.PID)
if !ok {
continue
}
pid, err := strconv.ParseUint(pidStr, 10, 64)
if err != nil {
continue
}
var (
c Container
candidate = int(pid)
)
t.registry.LockedPIDLookup(func(lookup func(int) Container) {
for {
c = lookup(candidate)
if c != nil {
break
}
candidate, err = tree.GetParent(candidate)
if err != nil {
break
}
}
})
if c == nil || ContainerIsStopped(c) || c.PID() == 1 {
continue
}
node := report.MakeNodeWith(nodeID, map[string]string{
ContainerID: c.ID(),
}).WithParents(report.EmptySets.
Add(report.Container, report.MakeStringSet(report.MakeContainerNodeID(c.ID()))),
)
// If we can work out the image name, add a parent tag for it
image, ok := t.registry.GetContainerImage(c.Image())
if ok && len(image.RepoTags) > 0 {
imageName := ImageNameWithoutVersion(image.RepoTags[0])
node = node.WithParents(report.EmptySets.
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(imageName))),
)
}
topology.AddNode(node)
}
}
示例2: tag
func (t *Tagger) tag(tree process.Tree, topology *report.Topology) {
for nodeID, node := range topology.Nodes {
pidStr, ok := node.Latest.Lookup(process.PID)
if !ok {
continue
}
pid, err := strconv.ParseUint(pidStr, 10, 64)
if err != nil {
continue
}
var (
c Container
candidate = int(pid)
)
t.registry.LockedPIDLookup(func(lookup func(int) Container) {
for {
c = lookup(candidate)
if c != nil {
break
}
candidate, err = tree.GetParent(candidate)
if err != nil {
break
}
}
})
if c == nil || c.State() == StateStopped || c.PID() == 1 {
continue
}
topology.AddNode(nodeID, report.MakeNodeWith(map[string]string{
ContainerID: c.ID(),
}).WithParents(report.EmptySets.
Add(report.Container, report.MakeStringSet(report.MakeContainerNodeID(c.ID()))).
Add(report.ContainerImage, report.MakeStringSet(report.MakeContainerImageNodeID(c.Image()))),
))
}
}
示例3: tag
func (t *Tagger) tag(tree process.Tree, topology *report.Topology) {
for nodeID, nodeMetadata := range topology.NodeMetadatas {
pidStr, ok := nodeMetadata["pid"]
if !ok {
continue
}
pid, err := strconv.ParseUint(pidStr, 10, 64)
if err != nil {
continue
}
var (
c Container
candidate = int(pid)
)
t.registry.LockedPIDLookup(func(lookup func(int) Container) {
for {
c = lookup(candidate)
if c != nil {
break
}
candidate, err = tree.GetParent(candidate)
if err != nil {
break
}
}
})
if c == nil {
continue
}
md := report.NodeMetadata{
ContainerID: c.ID(),
}
topology.NodeMetadatas[nodeID].Merge(md)
}
}
示例4: tag
func (t *Tagger) tag(tree process.Tree, topology *report.Topology) {
for nodeID, node := range topology.Nodes {
pidStr, ok := node.Metadata[process.PID]
if !ok {
continue
}
pid, err := strconv.ParseUint(pidStr, 10, 64)
if err != nil {
continue
}
var (
c Container
candidate = int(pid)
)
t.registry.LockedPIDLookup(func(lookup func(int) Container) {
for {
c = lookup(candidate)
if c != nil {
break
}
candidate, err = tree.GetParent(candidate)
if err != nil {
break
}
}
})
if c == nil {
continue
}
topology.AddNode(nodeID, report.MakeNodeWith(map[string]string{
ContainerID: c.ID(),
}))
}
}