/** * Query bandwidth capacity on a port. * * @param did {@link DeviceId} * @param number {@link PortNumber} * @return bandwidth capacity */ private Optional<Bandwidth> queryBandwidth(DeviceId did, PortNumber number) { // Check and use netcfg first. ConnectPoint cp = new ConnectPoint(did, number); BandwidthCapacity config = netcfgService.getConfig(cp, BandwidthCapacity.class); if (config != null) { log.trace("Registering configured bandwidth {} for {}/{}", config.capacity(), did, number); return Optional.of(config.capacity()); } // populate bandwidth value, assuming portSpeed == bandwidth Port port = deviceService.getPort(did, number); if (port != null) { return Optional.of(Bandwidth.mbps(port.portSpeed())); } return Optional.empty(); }
/** * Returns free resources for a given link obtaining from topology * information. * * @param link the target link * @return free resources */ private synchronized Set<ResourceAllocation> readOriginalFreeResources(Link link) { Annotations annotations = link.annotations(); Set<ResourceAllocation> allocations = new HashSet<>(); try { int waves = Integer.parseInt(annotations.value(AnnotationKeys.OPTICAL_WAVES)); for (int i = 1; i <= waves; i++) { allocations.add(new LambdaResourceAllocation(LambdaResource.valueOf(i))); } } catch (NumberFormatException e) { log.debug("No optical.wave annotation on link %s", link); } BandwidthResource bandwidth = DEFAULT_BANDWIDTH; try { bandwidth = new BandwidthResource( Bandwidth.mbps((Double.parseDouble(annotations.value(AnnotationKeys.BANDWIDTH))))); } catch (NumberFormatException e) { log.debug("No bandwidth annotation on link %s", link); } allocations.add( new BandwidthResourceAllocation(bandwidth)); return allocations; }