Make merging of node children conditional in addToResults

Some operations won't want this.
This commit is contained in:
Bryan Boreham
2017-11-11 14:18:41 +00:00
committed by Matthias Radestock
parent e475c2af1d
commit db41cab0af
4 changed files with 11 additions and 9 deletions

View File

@@ -82,7 +82,7 @@ func (c connectionJoin) Render(rpt report.Report) Nodes {
// Nodes without a hostid may be pseudo nodes - if so, pass through to result
if _, ok := m.Latest.Lookup(report.HostNodeID); !ok {
if id, ok := externalNodeID(m, addr, local); ok {
ret.addToResults(m, id, newPseudoNode)
ret.addToResults(m, id, true, newPseudoNode)
continue
}
}
@@ -94,7 +94,7 @@ func (c connectionJoin) Render(rpt report.Report) Nodes {
id, found = ipNodes[report.MakeScopedEndpointNodeID(scope, addr, port)]
}
if found && id != "" { // not one we blanked out earlier
ret.addToResults(m, id, func(id string) report.Node {
ret.addToResults(m, id, true, func(id string) report.Node {
return inputNodes.Nodes[id]
})
}

View File

@@ -79,10 +79,10 @@ func (e endpoints2Hosts) Render(rpt report.Report) Nodes {
if !ok {
continue
}
ret.addToResults(n, id, newPseudoNode)
ret.addToResults(n, id, true, newPseudoNode)
} else {
id := report.MakeHostNodeID(report.ExtractHostID(n))
ret.addToResults(n, id, func(id string) report.Node {
ret.addToResults(n, id, true, func(id string) report.Node {
return report.MakeNode(id).WithTopology(report.Host).
WithLatest(report.HostNodeID, timestamp, hostNodeID)
})

View File

@@ -94,7 +94,7 @@ func (e endpoints2Processes) Render(rpt report.Report) Nodes {
// Nodes without a hostid are treated as pseudo nodes
if hostNodeID, ok := n.Latest.Lookup(report.HostNodeID); !ok {
if id, ok := pseudoNodeID(n, local); ok {
ret.addToResults(n, id, newPseudoNode)
ret.addToResults(n, id, true, newPseudoNode)
}
} else {
pid, timestamp, ok := n.Latest.LookupEntry(process.PID)
@@ -111,7 +111,7 @@ func (e endpoints2Processes) Render(rpt report.Report) Nodes {
hostID, _, _ := report.ParseNodeID(hostNodeID)
id := report.MakeProcessNodeID(hostID, pid)
ret.addToResults(n, id, func(id string) report.Node {
ret.addToResults(n, id, true, func(id string) report.Node {
if processNode, found := processes.Nodes[id]; found {
return processNode
}
@@ -137,7 +137,7 @@ func processes2Names(processes Nodes) Nodes {
} else {
name, timestamp, ok := n.Latest.LookupEntry(process.Name)
if ok {
ret.addToResults(n, name, func(id string) report.Node {
ret.addToResults(n, name, true, func(id string) report.Node {
return report.MakeNode(id).WithTopology(MakeGroupNodeTopology(n.Topology, process.Name)).
WithLatest(process.Name, timestamp, name)
}, n.Topology)

View File

@@ -160,13 +160,15 @@ func newJoinResults() joinResults {
// Add Node M under id, creating a new result node if not already there
// incrementing a counter if nonblank, and updating the mapping from old ID to new ID
func (ret *joinResults) addToResults(m report.Node, id string, create func(string) report.Node, counters ...string) {
func (ret *joinResults) addToResults(m report.Node, id string, addChildren bool, create func(string) report.Node, counters ...string) {
result, exists := ret.nodes[id]
if !exists {
result = create(id)
}
result.Children = result.Children.Add(m)
result.Children = result.Children.Merge(m.Children)
if addChildren {
result.Children = result.Children.Merge(m.Children)
}
for _, c := range counters {
result.Counters = result.Counters.Add(c, 1)
}