Skip to content

Commit

Permalink
Use helper to add result nodes in endpoints2Hosts.Render
Browse files Browse the repository at this point in the history
This means we are no longer generating a Counter for the number of
endpoint sub-nodes, but it seems that data was not used.
  • Loading branch information
bboreham committed Nov 5, 2017
1 parent 7fd8660 commit fb9e05a
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions render/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,23 @@ func (e endpoints2Hosts) Render(rpt report.Report, dct Decorator) report.Nodes {
var ret = make(report.Nodes)
var mapped = map[string]string{} // input node ID -> output node ID
for _, n := range ns {
var result report.Node
var exists bool
// Nodes without a hostid are treated as pseudo nodes
hostNodeID, timestamp, ok := n.Latest.LookupEntry(report.HostNodeID)
if !ok {
id, ok := pseudoNodeID(n, local)
if !ok {
continue
}
result, exists = ret[id]
if !exists {
result = report.MakeNode(id).WithTopology(Pseudo)
}
addToResults(n, id, ret, mapped, func() report.Node {
return report.MakeNode(id).WithTopology(Pseudo)
})
} else {
id := report.MakeHostNodeID(report.ExtractHostID(n))
result, exists = ret[id]
if !exists {
result = report.MakeNode(id).WithTopology(report.Host)
result.Latest = result.Latest.Set(report.HostNodeID, timestamp, hostNodeID)
}
result.Children = result.Children.Merge(n.Children)
addToResults(n, id, ret, mapped, func() report.Node {
return report.MakeNode(id).WithTopology(report.Host).
WithLatest(report.HostNodeID, timestamp, hostNodeID)
})
}
result.Children = result.Children.Add(n)
result.Counters = result.Counters.Add(n.Topology, 1)
ret[result.ID] = result
mapped[n.ID] = result.ID
}
fixupAdjancencies(ns, ret, mapped)
return ret
Expand Down

0 comments on commit fb9e05a

Please sign in to comment.