use of org.onosproject.net.resource.ContinuousResource in project onos by opennetworkinglab.
the class LinkPropsTopovMessageHandler method getBandwidth.
/**
* Gets the links connected to the highlighted device.
* Creates a ContinuousResource object for each link
* and gets the bandwidth of the link from the query
* and sets the label of the link as the bandwidth value.
*/
private Highlights getBandwidth(Set<Link> links, DeviceId devId) {
LpLinkMap linkMap = new LpLinkMap();
Highlights highlights = new Highlights();
if (links != null) {
log.debug("Processing {} links", links.size());
links.forEach(linkMap::add);
PortNumber portnum = PortNumber.portNumber((int) links.iterator().next().src().port().toLong());
for (LpLink dlink : linkMap.biLinks()) {
DiscreteResourceId parent = Resources.discrete(devId, portnum).id();
ContinuousResource continuousResource = (ContinuousResource) resourceQueryService.getAvailableResources(parent, Bandwidth.class).iterator().next();
double availBandwidth = continuousResource.value();
dlink.makeImportant().setLabel(Double.toString(availBandwidth) + " bytes/s");
highlights.add(dlink.highlight(null));
}
} else {
log.debug("No egress links found for device {}", devId);
}
return highlights;
}
Aggregations