@Test public void testEventLinkDownMatch() throws Exception { Link link = link("src", 1, "dst", 2); LinkEvent linkEvent = new LinkEvent(LinkEvent.Type.LINK_REMOVED, link); reasons.add(linkEvent); TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topology, reasons); Key key = Key.of(0x333L, APP_ID); Collection<NetworkResource> resources = ImmutableSet.of(link); tracker.addTrackedResources(key, resources); listener.event(event); assertThat(delegate.latch.await(WAIT_TIMEOUT_SECONDS, TimeUnit.SECONDS), is(true)); assertThat(delegate.intentIdsFromEvent, hasSize(1)); assertThat(delegate.compileAllFailedFromEvent, is(false)); assertThat(delegate.intentIdsFromEvent.get(0).toString(), equalTo("0x333")); }
@Override public void addTrackedResources(Key intentKey, Collection<NetworkResource> resources) { for (NetworkResource resource : resources) { if (resource instanceof Link) { intentsByLink.put(linkKey((Link) resource), intentKey); } else if (resource instanceof ElementId) { intentsByElement.put((ElementId) resource, intentKey); } } }
ObjectiveTracker implements ObjectiveTrackerService { @Override public void addTrackedResources(Key intentKey, Collection<NetworkResource> resources) { for (NetworkResource resource : resources) { if (resource instanceof Link) { intentsByLink.put(linkKey((Link) resource), intentKey); } else if (resource instanceof ElementId) { intentsByElement.put((ElementId) resource, intentKey); } } } }
ObjectiveTracker implements ObjectiveTrackerService { @Override public void addTrackedResources(Key intentKey, Collection<NetworkResource> resources) { for (NetworkResource resource : resources) { if (resource instanceof Link) { intentsByLink.put(linkKey((Link) resource), intentKey); } else if (resource instanceof ElementId) { intentsByElement.put((ElementId) resource, intentKey); } } }  }
ObjectiveTracker implements ObjectiveTrackerService { @Override public void addTrackedResources(Key intentKey, Collection<NetworkResource> resources) { for (NetworkResource resource : resources) { if (resource instanceof Link) { intentsByLink.put(linkKey((Link) resource), intentKey); } else if (resource instanceof ElementId) { intentsByElement.put((ElementId) resource, intentKey); } } }  @Activate void activate(); @Deactivate void deactivate(); @Override void setDelegate(TopologyChangeDelegate delegate); @Override void unsetDelegate(TopologyChangeDelegate delegate); @Override void addTrackedResources(Key intentKey,
                                    Collection<NetworkResource> resources); @Override void removeTrackedResources(Key intentKey,
                                       Collection<NetworkResource> resources); @Override void trackIntent(IntentData intentData); }
ObjectiveTracker implements ObjectiveTrackerService { @Override public void addTrackedResources(Key intentKey, Collection<NetworkResource> resources) { for (NetworkResource resource : resources) { if (resource instanceof Link) { intentsByLink.put(linkKey((Link) resource), intentKey); } else if (resource instanceof ElementId) { intentsByElement.put((ElementId) resource, intentKey); } } }  @Activate void activate(); @Deactivate void deactivate(); @Override void setDelegate(TopologyChangeDelegate delegate); @Override void unsetDelegate(TopologyChangeDelegate delegate); @Override void addTrackedResources(Key intentKey,
                                    Collection<NetworkResource> resources); @Override void removeTrackedResources(Key intentKey,
                                       Collection<NetworkResource> resources); @Override void trackIntent(IntentData intentData);  }