本文整理匯總了Java中org.onlab.util.Bandwidth.bps方法的典型用法代碼示例。如果您正苦於以下問題:Java Bandwidth.bps方法的具體用法?Java Bandwidth.bps怎麽用?Java Bandwidth.bps使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.onlab.util.Bandwidth
的用法示例。
在下文中一共展示了Bandwidth.bps方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildAnnotations
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* 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;
}
示例2: execute
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
@Override
protected void execute() {
OpticalPathService opticalPathService = get(OpticalPathService.class);
ConnectPoint ingress = readConnectPoint(ingressStr);
ConnectPoint egress = readConnectPoint(egressStr);
if (ingress == null || egress == null) {
print("Invalid connect points: %s, %s", ingressStr, egressStr);
return;
}
Bandwidth bandwidth = (bandwidthStr == null || bandwidthStr.isEmpty()) ? null :
Bandwidth.bps(Long.valueOf(bandwidthStr));
print("Trying to setup connectivity between %s and %s.", ingress, egress);
OpticalConnectivityId id = opticalPathService.setupConnectivity(ingress, egress, bandwidth, null);
if (id == null) {
print("Failed.");
return;
}
print("Optical path ID : %s", id.id());
}
示例3: setupPathTest11
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Tests path setup without failure for LSP with signalling and with bandwidth reservation.
*/
@Test
public void setupPathTest11() {
build4RouterTopo(false, true, true, true, 15);
List<Constraint> constraints = new LinkedList<Constraint>();
BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
CostConstraint costConstraint = new CostConstraint(TE_COST);
constraints.add(costConstraint);
constraints.add(bwConstraint);
LabelResourceId node1Label = LabelResourceId.labelResourceId(5200);
LabelResourceId node2Label = LabelResourceId.labelResourceId(5201);
pceManager.pceStore.addGlobalNodeLabel(D1.deviceId(), node1Label);
pceManager.pceStore.addGlobalNodeLabel(D2.deviceId(), node2Label);
boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, SR_WITHOUT_SIGNALLING);
assertThat(result, is(false));
}
示例4: buildConstraints
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Builds the constraint list for this command based on the command line
* parameters.
*
* @return List of constraint objects describing the constraints requested
*/
protected List<Constraint> buildConstraints() {
final List<Constraint> constraints = new LinkedList<>();
// Check for a bandwidth specification
if (!isNullOrEmpty(bandwidthString)) {
Bandwidth bandwidth;
try {
bandwidth = Bandwidth.bps(Long.parseLong(bandwidthString));
// when the string can't be parsed as long, then try to parse as double
} catch (NumberFormatException e) {
bandwidth = Bandwidth.bps(Double.parseDouble(bandwidthString));
}
constraints.add(new BandwidthConstraint(bandwidth));
}
// Check for partial failure specification
if (partial) {
constraints.add(new PartialFailureConstraint());
}
// Check for encapsulation specification
if (!isNullOrEmpty(encapsulationString)) {
final EncapsulationType encapType = EncapsulationType.valueOf(encapsulationString);
constraints.add(new EncapsulationConstraint(encapType));
}
return constraints;
}
示例5: create
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Creates PacketLinkRealizedByOptical instance with specified connect points and OpticalCircuitIntent.
* Assigned bandwidth is taken from physical limit of optical link.
*
* @param src source connect point
* @param dst destination connect point
* @param intent OpticalCircuitIntent that realizes packet link between src and dst
* @return
*/
public static PacketLinkRealizedByOptical create(ConnectPoint src, ConnectPoint dst,
OpticalCircuitIntent intent) {
checkNotNull(src);
checkNotNull(dst);
checkNotNull(intent);
long rate = intent.getSignalType().bitRate();
return new PacketLinkRealizedByOptical(src, dst, intent.key(), Bandwidth.bps(rate));
}
示例6: setupConnectivity
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
@Override
public OpticalConnectivityId setupConnectivity(ConnectPoint ingress, ConnectPoint egress,
Bandwidth bandwidth, Duration latency) {
checkNotNull(ingress);
checkNotNull(egress);
log.info("setupConnectivity({}, {}, {}, {})", ingress, egress, bandwidth, latency);
bandwidth = (bandwidth == null) ? Bandwidth.bps(0) : bandwidth;
Set<Path> paths = pathService.getPaths(ingress.deviceId(), egress.deviceId(),
new BandwidthLinkWeight(bandwidth));
if (paths.isEmpty()) {
log.warn("Unable to find multi-layer path.");
return null;
}
// Search path with available cross connect points
for (Path path : paths) {
OpticalConnectivityId id = setupPath(path, bandwidth, latency);
if (id != null) {
log.info("Assigned OpticalConnectivityId: {}", id);
return id;
}
}
log.info("setupConnectivity({}, {}, {}, {}) failed.", ingress, egress, bandwidth, latency);
return null;
}
示例7: removeCrossConnectLinks
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
private void removeCrossConnectLinks(Intent intent) {
ConnectPoint src, dst;
if (intent instanceof OpticalCircuitIntent) {
OpticalCircuitIntent circuit = (OpticalCircuitIntent) intent;
src = circuit.getSrc();
dst = circuit.getDst();
} else if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent conn = (OpticalConnectivityIntent) intent;
src = conn.getSrc();
dst = conn.getDst();
} else {
return;
}
removeXcLinkUsage(src);
removeXcLinkUsage(dst);
// Set bandwidth of 0 to cross connect ports
Bandwidth bw = Bandwidth.bps(0);
linkPathMap.entrySet().stream()
.filter(e -> e.getKey().realizingIntentKey().equals(intent.key()))
.forEach(e -> {
ConnectPoint packetSrc = e.getKey().src();
ConnectPoint packetDst = e.getKey().dst();
// Updates bandwidth of packet ports
updatePortBandwidth(packetSrc, bw);
updatePortBandwidth(packetDst, bw);
OpticalConnectivity connectivity = e.getValue();
connectivity.setLinkRemoved(packetSrc, packetDst);
// Notifies listeners if all links are gone
if (e.getValue().isAllRealizingLinkNotEstablished()) {
releaseBandwidthUsage(connectivity);
post(new OpticalPathEvent(OpticalPathEvent.Type.PATH_REMOVED, e.getValue().id()));
}
});
}
示例8: isValid
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
@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);
}
示例9: checkForMasterAndUpdateTunnel
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
private boolean checkForMasterAndUpdateTunnel(DeviceId src, Tunnel tunnel) {
/**
* Master of ingress node will recompute and also delegation flag must be set.
*/
if (mastershipService.isLocalMaster(src)
&& Boolean.valueOf(tunnel.annotations().value(DELEGATE)) != null) {
LinkedList<Constraint> constraintList = new LinkedList<>();
if (tunnel.annotations().value(BANDWIDTH) != null) {
//Requested bandwidth will be same as previous allocated bandwidth for the tunnel
BandwidthConstraint localConst = new BandwidthConstraint(Bandwidth.bps(Double.parseDouble(tunnel
.annotations().value(BANDWIDTH))));
constraintList.add(localConst);
}
if (tunnel.annotations().value(COST_TYPE) != null) {
constraintList.add(CostConstraint.of(CostConstraint.Type.valueOf(tunnel.annotations().value(
COST_TYPE))));
}
/*
* If tunnel was UP after recomputation failed then store failed path in PCE store send PCIntiate(remove)
* and If tunnel is failed and computation fails nothing to do because tunnel status will be same[Failed]
*/
if (!updatePath(tunnel.tunnelId(), constraintList) && !tunnel.state().equals(Tunnel.State.FAILED)) {
// If updation fails store in PCE store as failed path
// then PCInitiate (Remove)
pceStore.addFailedPathInfo(new PcePathInfo(tunnel.path().src().deviceId(), tunnel
.path().dst().deviceId(), tunnel.tunnelName().value(), constraintList,
LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE))));
//Release that tunnel calling PCInitiate
releasePath(tunnel.tunnelId());
}
}
return false;
}
示例10: testpathComputationCase3
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Path which satisfy bandwidth as a constraint with 10bps.
*/
@Test
public void testpathComputationCase3() {
Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 50);
List<Resource> resources = new LinkedList<>();
resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class)
.resource(50));
resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class)
.resource(50));
resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class)
.resource(100));
resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class)
.resource(100));
resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class)
.resource(50));
resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class)
.resource(50));
resources.add(continuous(link3.dst().deviceId(), link3.src().port(), Bandwidth.class)
.resource(100));
resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class)
.resource(100));
resourceService.allocate(IntentId.valueOf(70), resources);
BandwidthConstraint bandwidthConst = new BandwidthConstraint(Bandwidth.bps(10.0));
List<Constraint> constraints = new LinkedList<>();
constraints.add(bandwidthConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
}
示例11: testpathComputationCase4
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Path which satisfy bandwidth as a constraint with 60bps.
*/
@Test
public void testpathComputationCase4() {
Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 50);
Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 100);
List<Resource> resources = new LinkedList<>();
resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100));
resourceService.allocate(IntentId.valueOf(70), resources);
BandwidthConstraint bandwidthConst = new BandwidthConstraint(Bandwidth.bps(60.0));
List<Constraint> constraints = new LinkedList<>();
constraints.add(bandwidthConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().cost(), is((double) 2));
}
示例12: testpathComputationCase5
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Shared bandwidth as L1, L2 with its value 10 bps and bandwidth constraint as 20 bps.
*/
@Test
public void testpathComputationCase5() {
Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
List<Resource> resources = new LinkedList<>();
resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100));
resourceService.allocate(IntentId.valueOf(70), resources);
List<Constraint> constraints = new LinkedList<>();
List<Link> sharedLinks = new LinkedList<>();
List<Link> links = new LinkedList<>();
links.add(link1);
links.add(link2);
CostConstraint costConst = CostConstraint.of(COST);
sharedLinks.addAll(links);
SharedBandwidthConstraint sharedBw = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(10),
Bandwidth.bps(20.0));
constraints.add(sharedBw);
constraints.add(costConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
}
示例13: testpathComputationCase6
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Shared bandwidth as L1, L2 with its value 20 bps and bandwidth constraint as 10 bps.
*/
@Test
public void testpathComputationCase6() {
Link link1 = addLink(DEVICE1, 10, DEVICE2, 20, true, 50);
Link link2 = addLink(DEVICE2, 30, DEVICE4, 40, true, 20);
Link link3 = addLink(DEVICE1, 80, DEVICE3, 70, true, 100);
Link link4 = addLink(DEVICE3, 60, DEVICE4, 50, true, 80);
List<Resource> resources = new LinkedList<>();
resources.add(continuous(link1.src().deviceId(), link1.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.src().deviceId(), link2.src().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.src().deviceId(), link3.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.src().deviceId(), link4.src().port(), Bandwidth.class).resource(100));
resources.add(continuous(link1.dst().deviceId(), link1.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link2.dst().deviceId(), link2.dst().port(), Bandwidth.class).resource(50));
resources.add(continuous(link3.dst().deviceId(), link3.dst().port(), Bandwidth.class).resource(100));
resources.add(continuous(link4.dst().deviceId(), link4.dst().port(), Bandwidth.class).resource(100));
resourceService.allocate(IntentId.valueOf(70), resources);
List<Constraint> constraints = new LinkedList<>();
List<Link> sharedLinks = new LinkedList<>();
List<Link> links = new LinkedList<>();
links.add(link1);
links.add(link2);
CostConstraint costConst = CostConstraint.of(COST);
sharedLinks.addAll(links);
SharedBandwidthConstraint sharedBwConst = new SharedBandwidthConstraint(sharedLinks, Bandwidth.bps(20),
Bandwidth.bps(10.0));
constraints.add(sharedBwConst);
constraints.add(costConst);
Set<Path> paths = computePath(link1, link2, link3, link4, constraints);
assertThat(paths.iterator().next().links(), is(links));
assertThat(paths.iterator().next().cost(), is((double) 70));
}
示例14: setupPathTest8
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Tests path failure as bandwidth is requested but is not registered.
*/
@Test
public void setupPathTest8() {
build4RouterTopo(true, false, false, false, 0);
List<Constraint> constraints = new LinkedList<Constraint>();
BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
CostConstraint costConstraint = new CostConstraint(TE_COST);
constraints.add(costConstraint);
constraints.add(bwConstraint);
boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING);
assertThat(result, is(false));
}
示例15: setupPathTest9
import org.onlab.util.Bandwidth; //導入方法依賴的package包/類
/**
* Tests path failure as bandwidth requested is more than registered.
*/
@Test
public void setupPathTest9() {
build4RouterTopo(false, false, false, false, 5);
List<Constraint> constraints = new LinkedList<Constraint>();
BandwidthConstraint bwConstraint = new BandwidthConstraint(Bandwidth.bps(10.0));
CostConstraint costConstraint = new CostConstraint(TE_COST);
constraints.add(costConstraint);
constraints.add(bwConstraint);
boolean result = pceManager.setupPath(D1.deviceId(), D2.deviceId(), "T123", constraints, WITH_SIGNALLING);
assertThat(result, is(false));
}