@Test public void testBandwidthConstrainedIntentFailure() { final ResourceService resourceService = IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0); final List<Constraint> constraints = Collections.singletonList(new BandwidthConstraint(Bandwidth.bps(100.0))); try { final PointToPointIntent intent = makeIntent("s1", "s3", constraints); String[] hops = {"s1", "s2", "s3"}; final PointToPointIntentCompiler compiler = makeCompiler(hops, 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")); } }
@Override public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }
PointToPointIntentCompiler extends ConnectivityIntentCompiler<PointToPointIntent> { @Override public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); } }
PointToPointIntentCompiler extends ConnectivityIntentCompiler<PointToPointIntent> { @Override public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  }
PointToPointIntentCompiler extends ConnectivityIntentCompiler<PointToPointIntent> { @Override public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(PointToPointIntent intent, List<Intent> installable); }
PointToPointIntentCompiler extends ConnectivityIntentCompiler<PointToPointIntent> { @Override public List<Intent> compile(PointToPointIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(PointToPointIntent intent, List<Intent> installable); static final int DEFAULT_COST; }