@Ignore("Ignore until Delegate spec. is clear.") @Test public final void testEvents() throws InterruptedException { final ConnectPoint d1P1 = new ConnectPoint(DID1, P1); final ConnectPoint d2P2 = new ConnectPoint(DID2, P2); final LinkKey linkId1 = LinkKey.linkKey(d1P1, d2P2); final CountDownLatch addLatch = new CountDownLatch(1); LinkStoreDelegate checkAdd = event -> { assertEquals(LINK_ADDED, event.type()); assertLink(linkId1, INDIRECT, event.subject()); addLatch.countDown(); }; final CountDownLatch updateLatch = new CountDownLatch(1); LinkStoreDelegate checkUpdate = event -> { assertEquals(LINK_UPDATED, event.type()); assertLink(linkId1, DIRECT, event.subject()); updateLatch.countDown(); }; final CountDownLatch removeLatch = new CountDownLatch(1); LinkStoreDelegate checkRemove = event -> { assertEquals(LINK_REMOVED, event.type()); assertLink(linkId1, DIRECT, event.subject()); removeLatch.countDown(); }; linkStore.setDelegate(checkAdd); putLink(linkId1, INDIRECT); assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS)); linkStore.unsetDelegate(checkAdd); linkStore.setDelegate(checkUpdate); putLink(linkId1, DIRECT); assertTrue("Update event fired", updateLatch.await(1, TimeUnit.SECONDS)); linkStore.unsetDelegate(checkUpdate); linkStore.setDelegate(checkRemove); linkStore.removeLink(d1P1, d2P2); assertTrue("Remove event fired", removeLatch.await(1, TimeUnit.SECONDS)); }
@Override public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { final LinkKey linkKey = LinkKey.linkKey(src, dst); ProviderId primaryProviderId = getBaseProviderId(linkKey); if (primaryProviderId == null) { return null; } LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId)); if (removedLinkDescription != null) { return purgeLinkCache(linkKey); } return null; }
ECLinkStore extends AbstractStore<LinkEvent, LinkStoreDelegate> implements LinkStore { @Override public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { final LinkKey linkKey = LinkKey.linkKey(src, dst); ProviderId primaryProviderId = getBaseProviderId(linkKey); if (primaryProviderId == null) { return null; } LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId)); if (removedLinkDescription != null) { return purgeLinkCache(linkKey); } return null; } }
ECLinkStore extends AbstractStore<LinkEvent, LinkStoreDelegate> implements LinkStore { @Override public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { final LinkKey linkKey = LinkKey.linkKey(src, dst); ProviderId primaryProviderId = getBaseProviderId(linkKey); if (primaryProviderId == null) { return null; } LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId)); if (removedLinkDescription != null) { return purgeLinkCache(linkKey); } return null; }  }
ECLinkStore extends AbstractStore<LinkEvent, LinkStoreDelegate> implements LinkStore { @Override public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { final LinkKey linkKey = LinkKey.linkKey(src, dst); ProviderId primaryProviderId = getBaseProviderId(linkKey); if (primaryProviderId == null) { return null; } LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId)); if (removedLinkDescription != null) { return purgeLinkCache(linkKey); } return null; }  @Activate void activate(); @Deactivate void deactivate(); @Override int getLinkCount(); @Override Iterable<Link> getLinks(); @Override Set<Link> getDeviceEgressLinks(DeviceId deviceId); @Override Set<Link> getDeviceIngressLinks(DeviceId deviceId); @Override Link getLink(ConnectPoint src, ConnectPoint dst); @Override Set<Link> getEgressLinks(ConnectPoint src); @Override Set<Link> getIngressLinks(ConnectPoint dst); @Override LinkEvent createOrUpdateLink(ProviderId providerId,
                                        LinkDescription linkDescription); @Override LinkEvent removeOrDownLink(ConnectPoint src, ConnectPoint dst); @Override LinkEvent removeLink(ConnectPoint src, ConnectPoint dst); }
ECLinkStore extends AbstractStore<LinkEvent, LinkStoreDelegate> implements LinkStore { @Override public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) { final LinkKey linkKey = LinkKey.linkKey(src, dst); ProviderId primaryProviderId = getBaseProviderId(linkKey); if (primaryProviderId == null) { return null; } LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId)); if (removedLinkDescription != null) { return purgeLinkCache(linkKey); } return null; }  @Activate void activate(); @Deactivate void deactivate(); @Override int getLinkCount(); @Override Iterable<Link> getLinks(); @Override Set<Link> getDeviceEgressLinks(DeviceId deviceId); @Override Set<Link> getDeviceIngressLinks(DeviceId deviceId); @Override Link getLink(ConnectPoint src, ConnectPoint dst); @Override Set<Link> getEgressLinks(ConnectPoint src); @Override Set<Link> getIngressLinks(ConnectPoint dst); @Override LinkEvent createOrUpdateLink(ProviderId providerId,
                                        LinkDescription linkDescription); @Override LinkEvent removeOrDownLink(ConnectPoint src, ConnectPoint dst); @Override LinkEvent removeLink(ConnectPoint src, ConnectPoint dst);  }