use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method allocateIntentBandwidth.
private void allocateIntentBandwidth(PointToPointIntent intent, Path path) {
ConnectPoint ingressCP = intent.filteredIngressPoint().connectPoint();
ConnectPoint egressCP = intent.filteredEgressPoint().connectPoint();
List<ConnectPoint> pathCPs = path.links().stream().flatMap(l -> Stream.of(l.src(), l.dst())).collect(Collectors.toList());
pathCPs.add(ingressCP);
pathCPs.add(egressCP);
allocateBandwidth(intent, pathCPs);
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompiler method removeAndUpdateIntents.
/**
* Removes intents from installables list, depending on the values
* of instance variables erasePrimary and eraseBackup. Flow rule intents
* that contain the manufactured fast failover flow rules are never deleted.
* The contents are simply modified as necessary. If cleanUpIntents size
* is greater than 1 (failover intent), then one whole path from previous
* installables must be still viable.
*
* @param cleanUpIntents list of installable intents
*/
private void removeAndUpdateIntents(List<Intent> cleanUpIntents, PointToPointIntent pointIntent) {
ListIterator<Intent> iterator = cleanUpIntents.listIterator();
while (iterator.hasNext()) {
Intent cIntent = iterator.next();
if (cIntent instanceof FlowRuleIntent) {
FlowRuleIntent fIntent = (FlowRuleIntent) cIntent;
if (fIntent.type() == PathIntent.ProtectionType.PRIMARY && erasePrimary) {
// remove primary path's flow rule intents
iterator.remove();
} else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && eraseBackup) {
// remove backup path's flow rule intents
iterator.remove();
} else if (fIntent.type() == PathIntent.ProtectionType.BACKUP && erasePrimary) {
// promote backup path's flow rule intents to primary
iterator.set(new FlowRuleIntent(fIntent, PathIntent.ProtectionType.PRIMARY));
}
}
}
// remove buckets whose watchports are disabled if the failover group exists
Group group = groupService.getGroup(pointIntent.filteredIngressPoint().connectPoint().deviceId(), makeGroupKey(pointIntent.id()));
if (group != null) {
updateFailoverGroup(pointIntent);
}
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testBandwidthConstrainedIntentSuccess.
/**
* Tests that requests with sufficient available bandwidth succeed.
*/
@Test
public void testBandwidthConstrainedIntentSuccess() {
final double bpsTotal = 1000.0;
final double bpsToReserve = 100.0;
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(bpsToReserve)));
final PointToPointIntent intent = makeIntent(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), constraints);
String[] hops = { S1, S2, S3 };
final PointToPointIntentCompiler compiler = makeCompiler(hops, resourceService);
final List<Intent> compiledIntents = compiler.compile(intent, null);
assertThat(compiledIntents, Matchers.notNullValue());
assertThat(compiledIntents, hasSize(1));
assertThat("key is inherited", compiledIntents.stream().map(Intent::key).collect(Collectors.toList()), everyItem(is(intent.key())));
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testSuggestedPath.
/**
* Test if a suggested path is correctly applied.
*/
@Test
public void testSuggestedPath() {
String[] suggestedPathHops = { S1, S3, S4, S5, S6, S8 };
List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_8, PORT_2), suggestedPath);
String[][] paths = { { S1, S2, S8 }, suggestedPathHops };
PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(paths);
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(Matchers.notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent resultLinkIntent = (LinkCollectionIntent) resultIntent;
FilteredConnectPoint ingressPoint = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressPoint = new FilteredConnectPoint(new ConnectPoint(DID_8, PORT_2));
// 5 links for the hops, plus one default link on ingress and egress
assertThat(resultLinkIntent.links(), hasSize(suggestedPathHops.length - 1));
assertThat(resultLinkIntent.links(), linksHasPath(S1, S3));
assertThat(resultLinkIntent.links(), linksHasPath(S3, S4));
assertThat(resultLinkIntent.links(), linksHasPath(S4, S5));
assertThat(resultLinkIntent.links(), linksHasPath(S5, S6));
assertThat(resultLinkIntent.links(), linksHasPath(S6, S8));
assertThat(resultLinkIntent.filteredIngressPoints(), is(ImmutableSet.of(ingressPoint)));
assertThat(resultLinkIntent.filteredEgressPoints(), is(ImmutableSet.of(egressPoint)));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.intent.PointToPointIntent in project onos by opennetworkinglab.
the class PointToPointIntentCompilerTest method testSuggestedPathBandwidthConstrainedIntentFailure.
/**
* Tests that requests with insufficient available bandwidth fail.
*/
@Test
public void testSuggestedPathBandwidthConstrainedIntentFailure() {
final double bpsTotal = 10.0;
final ResourceService resourceService = MockResourceService.makeCustomBandwidthResourceService(bpsTotal);
final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(BPS_TO_RESERVE)));
String[] suggestedPathHops = { S1, S4, S5, S3 };
List<Link> suggestedPath = NetTestTools.createPath(suggestedPathHops).links();
try {
final PointToPointIntent intent = makeIntentSuggestedPath(new ConnectPoint(DID_1, PORT_1), new ConnectPoint(DID_3, PORT_2), suggestedPath, constraints);
String[][] paths = { { S1, S2, S3 }, suggestedPathHops };
final PointToPointIntentCompiler compiler = makeCompilerSuggestedPath(paths, resourceService);
compiler.compile(intent, null);
fail("Point to Point compilation with insufficient bandwidth does " + "not throw exception.");
} catch (PathNotFoundException noPath) {
assertThat(noPath.getMessage(), containsString("No path"));
}
}
Aggregations