本文整理了Java中org.onlab.util.Bandwidth
类的一些代码示例,展示了Bandwidth
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bandwidth
类的具体详情如下:
包路径:org.onlab.util.Bandwidth
类名称:Bandwidth
[英]Representation of bandwidth. Use the static factory method corresponding to the unit (like Kbps) you desire on instantiation.
[中]带宽的表示。使用与实例化时所需的单元(如Kbps)对应的静态工厂方法。
代码示例来源:origin: org.onosproject/onlab-misc
/**
* Returns a Bandwidth whose value is (this + value).
*
* @param value value to be added to this Frequency
* @return this + value
*/
default Bandwidth add(Bandwidth value) {
return bps(this.bps() + value.bps());
}
代码示例来源:origin: org.onosproject/onos-apps-pce-app
@Override
public boolean isValid(Link link, ResourceContext context) {
changedBwValue = requestBwValue;
if (links.contains(link)) {
changedBwValue = requestBwValue.isGreaterThan(sharedBwValue) ? requestBwValue.subtract(sharedBwValue)
: Bandwidth.bps(0);
}
return Stream
.of(link.src(), link.dst())
.map(cp -> Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource(
changedBwValue.bps())).allMatch(context::isAvailable);
}
代码示例来源:origin: org.onosproject/onos-isis-provider-topology
/**
* Registers the bandwidth for source and destination points.
*
* @param linkDes link description instance
* @param isisLink ISIS link instance
*/
private void registerBandwidth(LinkDescription linkDes, IsisLink isisLink) {
if (isisLink == null) {
log.error("Could not able to register bandwidth ");
return;
}
IsisLinkTed isisLinkTed = isisLink.linkTed();
Bandwidth maxReservableBw = isisLinkTed.maximumReservableLinkBandwidth();
if (maxReservableBw != null) {
if (maxReservableBw.compareTo(Bandwidth.bps(0)) == 0) {
return;
}
//Configure bandwidth for src and dst port
BandwidthCapacity config = networkConfigService.addConfig(linkDes.src(), BandwidthCapacity.class);
config.capacity(maxReservableBw).apply();
config = networkConfigService.addConfig(linkDes.dst(), BandwidthCapacity.class);
config.capacity(maxReservableBw).apply();
}
}
}
代码示例来源: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;
}
代码示例来源: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/onlab-misc
/**
* Returns a Bandwidth whose value is (this - value).
*
* @param value value to be added to this Frequency
* @return this - value
*/
default Bandwidth subtract(Bandwidth value) {
return bps(this.bps() - value.bps());
}
代码示例来源:origin: org.onosproject/onos-app-pce
@Override
public boolean isValid(Link link, ResourceContext context) {
changedBwValue = requestBwValue;
if (links.contains(link)) {
changedBwValue = requestBwValue.isGreaterThan(sharedBwValue) ? requestBwValue.subtract(sharedBwValue)
: Bandwidth.bps(0);
}
return Stream
.of(link.src(), link.dst())
.map(cp -> Resources.continuous(cp.deviceId(), cp.port(), Bandwidth.class).resource(
changedBwValue.bps())).allMatch(context::isAvailable);
}
代码示例来源:origin: org.onosproject/onlab-misc
/**
* Returns a Bandwidth whose value is (this + value).
*
* @param value value to be added to this Frequency
* @return this + value
*/
public Bandwidth add(Bandwidth value) {
if (value instanceof LongBandwidth) {
return Bandwidth.bps(this.bps + ((LongBandwidth) value).bps);
}
return Bandwidth.bps(this.bps + value.bps());
}
代码示例来源:origin: org.onosproject/onlab-misc
/**
* Returns a Bandwidth whose value is (this - value).
*
* @param value value to be added to this Frequency
* @return this - value
*/
public Bandwidth subtract(Bandwidth value) {
if (value instanceof LongBandwidth) {
return Bandwidth.bps(this.bps - ((LongBandwidth) value).bps);
}
return Bandwidth.bps(this.bps - value.bps());
}
代码示例来源:origin: org.onosproject/onlab-misc
@Override
default int compareTo(Bandwidth other) {
return ComparisonChain.start()
.compare(this.bps(), other.bps())
.result();
}
}
代码示例来源:origin: org.onosproject/onlab-misc
@Override
public int compareTo(Bandwidth other) {
if (other instanceof LongBandwidth) {
return ComparisonChain.start()
.compare(this.bps, ((LongBandwidth) other).bps)
.result();
}
return ComparisonChain.start()
.compare(this.bps, other.bps())
.result();
}
代码示例来源:origin: org.onosproject/onos-core-common
/**
* Decodes a bandwidth constraint.
*
* @return bandwidth constraint object.
*/
private Constraint decodeBandwidthConstraint() {
double bandwidth = nullIsIllegal(json.get(ConstraintCodec.BANDWIDTH),
ConstraintCodec.BANDWIDTH + ConstraintCodec.MISSING_MEMBER_MESSAGE)
.asDouble();
return new BandwidthConstraint(Bandwidth.bps(bandwidth));
}
代码示例来源:origin: org.onosproject/onos-core-common
/**
* Encodes a bandwidth constraint.
*
* @return JSON ObjectNode representing the constraint
*/
private ObjectNode encodeBandwidthConstraint() {
checkNotNull(constraint, "Bandwidth constraint cannot be null");
final BandwidthConstraint bandwidthConstraint =
(BandwidthConstraint) constraint;
return context.mapper().createObjectNode()
.put("bandwidth", bandwidthConstraint.bandwidth().bps());
}
代码示例来源:origin: org.onosproject/onos-protocols-ovsdb-api
/**
* Constructs a builder with a given queue description.
*
* @param queueDescription queue description
*/
private Builder(QueueDescription queueDescription) {
if (queueDescription.maxRate().isPresent()) {
otherConfigs.put(MAX_RATE, String.valueOf((long) queueDescription.maxRate().get().bps()));
}
if (queueDescription.minRate().isPresent()) {
otherConfigs.put(MIN_RATE, String.valueOf((long) queueDescription.minRate().get().bps()));
}
if (queueDescription.burst().isPresent()) {
otherConfigs.put(BURST, queueDescription.burst().get().toString());
}
if (queueDescription.priority().isPresent()) {
otherConfigs.put(PRIORITY, queueDescription.priority().get().toString());
}
if (queueDescription.dscp().isPresent()) {
dscp = Optional.of(queueDescription.dscp().get().longValue());
}
externalIds.putAll(((DefaultAnnotations) queueDescription.annotations()).asMap());
externalIds.put(QUEUE_EXTERNAL_ID_KEY, queueDescription.queueId().name());
}
代码示例来源:origin: org.onosproject/onos-protocols-ovsdb-api
/**
* Constructs a builder with a given Qos description.
*
* @param qosDesc Qos description
*/
private Builder(QosDescription qosDesc) {
if (qosDesc.maxRate().isPresent()) {
otherConfigs.put(MAX_RATE, String.valueOf((long) qosDesc.maxRate().get().bps()));
}
if (qosDesc.cir().isPresent()) {
otherConfigs.put(CIR, qosDesc.cir().get().toString());
}
if (qosDesc.cbs().isPresent()) {
otherConfigs.put(CBS, qosDesc.cbs().get().toString());
}
if (qosDesc.queues().isPresent()) {
Map<Long, String> map = new HashMap<>();
qosDesc.queues().get().forEach((k, v) -> map.put(k, v.queueId().name()));
queues = Optional.ofNullable(map);
}
type = qosDesc.type() == QosDescription.Type.EGRESS_POLICER ?
QOS_EGRESS_POLICER :
QOS_TYPE_PREFIX.concat(qosDesc.type().name().toLowerCase());
externalIds.putAll(((DefaultAnnotations) qosDesc.annotations()).asMap());
externalIds.put(QOS_EXTERNAL_ID_KEY, qosDesc.qosId().name());
}
代码示例来源:origin: org.onosproject/onos-cli
Bandwidth bandwidth;
try {
bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
代码示例来源:origin: org.onosproject/onos-core-trivial
/**
* Finds and returns {@link BandwidthResourceAllocation} object from a given
* set.
*
* @param freeRes a set of ResourceAllocation object.
* @return {@link BandwidthResourceAllocation} object if found, otherwise
* {@link BandwidthResourceAllocation} object with 0 bandwidth
*
*/
private synchronized BandwidthResourceAllocation getBandwidth(
Set<ResourceAllocation> freeRes) {
for (ResourceAllocation res : freeRes) {
if (res.type() == ResourceType.BANDWIDTH) {
return (BandwidthResourceAllocation) res;
}
}
return new BandwidthResourceAllocation(new BandwidthResource(Bandwidth.bps(0)));
}
代码示例来源:origin: org.onosproject/onos-core-net
double bw = bwConstraint.bandwidth().bps();
代码示例来源:origin: org.onosproject/onos-isis-provider-topology
/**
* Builds the annotation details.
*
* @param annotationBuilder default annotation builder instance
* @param isisLink ISIS link instance
* @return annotation builder instance
*/
private DefaultAnnotations.Builder buildAnnotations(DefaultAnnotations.Builder annotationBuilder,
IsisLink isisLink) {
int administrativeGroup = 0;
long teMetric = 0;
Bandwidth maxReservableBandwidth = Bandwidth.bps(0);
String routerId = null;
String neighborId = null;
//TE Info
IsisLinkTed isisLinkTed = isisLink.linkTed();
log.info("Ted Information: {}", isisLinkTed.toString());
administrativeGroup = isisLinkTed.administrativeGroup();
teMetric = isisLinkTed.teDefaultMetric();
maxReservableBandwidth = isisLinkTed.maximumReservableLinkBandwidth();
routerId = isisLink.localSystemId();
neighborId = isisLink.remoteSystemId();
annotationBuilder.set(ADMINISTRATIVEGROUP, String.valueOf(administrativeGroup));
annotationBuilder.set(TE_METRIC, String.valueOf(teMetric));
annotationBuilder.set(MAXRESERVABLEBANDWIDTH, String.valueOf(maxReservableBandwidth));
annotationBuilder.set(ROUTERID, String.valueOf(routerId));
annotationBuilder.set(NEIGHBORID, String.valueOf(neighborId));
return annotationBuilder;
}
代码示例来源:origin: org.onosproject/onos-core-trivial
freeRes.remove(ba);
freeRes.add(new BandwidthResourceAllocation(
new BandwidthResource(Bandwidth.bps(newBandwidth))));
break;
case LAMBDA:
内容来源于网络,如有侵权,请联系作者删除!