org.onlab.util.Bandwidth.mbps()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(96)

本文整理了Java中org.onlab.util.Bandwidth.mbps()方法的一些代码示例,展示了Bandwidth.mbps()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bandwidth.mbps()方法的具体详情如下:
包路径:org.onlab.util.Bandwidth
类名称:Bandwidth
方法名:mbps

Bandwidth.mbps介绍

[英]Creates a new instance with given bandwidth in Mbps.
[中]创建具有给定带宽(以Mbps为单位)的新实例。

代码示例

代码示例来源:origin: org.onosproject/onos-core-net

/**
 * 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();
}

代码示例来源:origin: org.onosproject/onos-core-trivial

/**
 * 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;
}

相关文章