Search in sources :

Example 16 with ContinuousResource

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;
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) Bandwidth(org.onlab.util.Bandwidth) DiscreteResourceId(org.onosproject.net.resource.DiscreteResourceId) PortNumber(org.onosproject.net.PortNumber) ContinuousResource(org.onosproject.net.resource.ContinuousResource)

Aggregations

ContinuousResource (org.onosproject.net.resource.ContinuousResource)16 Bandwidth (org.onlab.util.Bandwidth)12 ResourceAllocation (org.onosproject.net.resource.ResourceAllocation)12 Test (org.junit.Test)11 ResourceConsumer (org.onosproject.net.resource.ResourceConsumer)7 AbstractIntentTest (org.onosproject.net.intent.AbstractIntentTest)3 Constraint (org.onosproject.net.intent.Constraint)3 Key (org.onosproject.net.intent.Key)3 BandwidthConstraint (org.onosproject.net.intent.constraint.BandwidthConstraint)3 DiscreteResource (org.onosproject.net.resource.DiscreteResource)3 MockResourceService (org.onosproject.net.resource.MockResourceService)3 Resource (org.onosproject.net.resource.Resource)3 ResourceService (org.onosproject.net.resource.ResourceService)3 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 ConnectPoint (org.onosproject.net.ConnectPoint)2 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)2 PortNumber (org.onosproject.net.PortNumber)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2