@Test public void testSingleLongPathCompilation() { HostToHostIntent intent = makeIntent(HOST_ONE, HOST_TWO); assertThat(intent, is(notNullValue())); String[] hops = {HOST_ONE, "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", HOST_TWO}; HostToHostIntentCompiler compiler = makeCompiler(hops); assertThat(compiler, is(notNullValue())); List<Intent> result = compiler.compile(intent, null); assertThat(result, is(Matchers.notNullValue())); assertThat(result, hasSize(2)); Intent forwardResultIntent = result.get(0); assertThat(forwardResultIntent instanceof PathIntent, is(true)); Intent reverseResultIntent = result.get(1); assertThat(reverseResultIntent instanceof PathIntent, is(true)); if (forwardResultIntent instanceof PathIntent) { PathIntent forwardPathIntent = (PathIntent) forwardResultIntent; assertThat(forwardPathIntent.path().links(), hasSize(9)); assertThat(forwardPathIntent.path().links(), linksHasPath(HOST_ONE, "h1")); assertThat(forwardPathIntent.path().links(), linksHasPath("h1", "h2")); assertThat(forwardPathIntent.path().links(), linksHasPath("h2", "h3")); assertThat(forwardPathIntent.path().links(), linksHasPath("h3", "h4")); assertThat(forwardPathIntent.path().links(), linksHasPath("h4", "h5")); assertThat(forwardPathIntent.path().links(), linksHasPath("h5", "h6")); assertThat(forwardPathIntent.path().links(), linksHasPath("h6", "h7")); assertThat(forwardPathIntent.path().links(), linksHasPath("h7", "h8")); assertThat(forwardPathIntent.path().links(), linksHasPath("h8", HOST_TWO)); } if (reverseResultIntent instanceof PathIntent) { PathIntent reversePathIntent = (PathIntent) reverseResultIntent; assertThat(reversePathIntent.path().links(), hasSize(9)); assertThat(reversePathIntent.path().links(), linksHasPath("h1", HOST_ONE)); assertThat(reversePathIntent.path().links(), linksHasPath("h2", "h1")); assertThat(reversePathIntent.path().links(), linksHasPath("h3", "h2")); assertThat(reversePathIntent.path().links(), linksHasPath("h4", "h3")); assertThat(reversePathIntent.path().links(), linksHasPath("h5", "h4")); assertThat(reversePathIntent.path().links(), linksHasPath("h6", "h5")); assertThat(reversePathIntent.path().links(), linksHasPath("h7", "h6")); assertThat(reversePathIntent.path().links(), linksHasPath("h8", "h7")); assertThat(reversePathIntent.path().links(), linksHasPath(HOST_TWO, "h8")); } }
@Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPath(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPath(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createPathIntent(pathOne, one, two, intent), createPathIntent(pathTwo, two, one, intent)); }
HostToHostIntentCompiler extends ConnectivityIntentCompiler<HostToHostIntent> { @Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPath(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPath(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createPathIntent(pathOne, one, two, intent), createPathIntent(pathTwo, two, one, intent)); } }
HostToHostIntentCompiler extends ConnectivityIntentCompiler<HostToHostIntent> { @Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPath(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPath(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createPathIntent(pathOne, one, two, intent), createPathIntent(pathTwo, two, one, intent)); }  }
HostToHostIntentCompiler extends ConnectivityIntentCompiler<HostToHostIntent> { @Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPath(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPath(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createPathIntent(pathOne, one, two, intent), createPathIntent(pathTwo, two, one, intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(HostToHostIntent intent, List<Intent> installable); }
HostToHostIntentCompiler extends ConnectivityIntentCompiler<HostToHostIntent> { @Override public List<Intent> compile(HostToHostIntent intent, List<Intent> installable) { if (Objects.equals(intent.one(), intent.two())) { return ImmutableList.of(); } boolean isAsymmetric = intent.constraints().contains(new AsymmetricPathConstraint()); Path pathOne = getPath(intent, intent.one(), intent.two()); Path pathTwo = isAsymmetric ? getPath(intent, intent.two(), intent.one()) : invertPath(pathOne); Host one = hostService.getHost(intent.one()); Host two = hostService.getHost(intent.two()); return Arrays.asList(createPathIntent(pathOne, one, two, intent), createPathIntent(pathTwo, two, one, intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(HostToHostIntent intent, List<Intent> installable);  }