@Test public void testRendererPolicyChanged_update() throws Exception { AbsoluteLocation client1LocationNodeNull = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_1_IFACE_NAME); AddressEndpointWithLocation client1Ep = DtoFactory.createEndpoint(CLIENT_IP, CLIENT_MAC, DtoFactory.L2FD_CTX.getValue(), client1LocationNodeNull); AbsoluteLocation web1LocationNodeNull = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, WEB_1_IFACE_NAME); AddressEndpointWithLocation web1Ep = DtoFactory.createEndpoint(WEB_IP, WEB_MAC, DtoFactory.L2FD_CTX.getValue(), web1LocationNodeNull); AbsoluteLocation client2LocationNodeNull = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, null, CLIENT_2_IFACE_NAME); AddressEndpointWithLocation client2Ep = DtoFactory.createEndpoint(CLIENT_IP_2, CLIENT_MAC_2, DtoFactory.L2FD_CTX.getValue(), client2LocationNodeNull); AbsoluteLocation web2LocationNodeNull = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, null, WEB_2_IFACE_NAME); AddressEndpointWithLocation web2Ep = DtoFactory.createEndpoint(WEB_IP_2, WEB_MAC_2, DtoFactory.L2FD_CTX.getValue(), web2LocationNodeNull); storeVppEndpoint(client1Ep.getKey(), CLIENT_MAC, CLIENT_1_IFACE_NAME, createVppEndpointIid(client1Ep.getKey())); storeVppEndpoint(web1Ep.getKey(), WEB_MAC, WEB_1_IFACE_NAME, createVppEndpointIid(web1Ep.getKey())); storeVppEndpoint(client2Ep.getKey(), CLIENT_MAC_2, CLIENT_2_IFACE_NAME, createVppEndpointIid(client2Ep.getKey())); storeVppEndpoint(web2Ep.getKey(), WEB_MAC_2, WEB_2_IFACE_NAME, createVppEndpointIid(web2Ep.getKey())); Configuration configuration = DtoFactory.createConfiguration(Arrays.asList(client1Ep, client2Ep), Arrays.asList(web1Ep, web2Ep)); RendererPolicy rendererPolicy = new RendererPolicyBuilder().setVersion(1L).setConfiguration(configuration).build(); RendererPolicyConfEvent event = new RendererPolicyConfEvent(RENDERER_POLICY_IID, null, rendererPolicy); vppRendererPolicyManager.rendererPolicyChanged(event); Interface client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface); Interface web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface); Interface client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface); Interface web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface); ReadOnlyTransaction rTx = dataBroker.newReadOnlyTransaction(); Optional<LocationProvider> optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION, IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER)) .get(); Assert.assertTrue(optLocationProvider.isPresent()); List<ProviderAddressEndpointLocation> epLocs = optLocationProvider.get().getProviderAddressEndpointLocation(); Assert.assertNotNull(epLocs); Assert.assertEquals(4, epLocs.size()); assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs); AbsoluteLocation client1Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME); AbsoluteLocation web1Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME); AbsoluteLocation web2Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME); configuration = DtoFactory.createConfiguration( Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location) .build(), new AddressEndpointWithLocationBuilder(client2Ep).setAbsoluteLocation(client2LocationNodeNull) .build()), Arrays.asList(new AddressEndpointWithLocationBuilder(web1Ep).setAbsoluteLocation(web1Location).build(), new AddressEndpointWithLocationBuilder(web2Ep).setAbsoluteLocation(web2Location).build())); RendererPolicy rendererPolicy2 = new RendererPolicyBuilder().setVersion(2L).setConfiguration(configuration).build(); RendererPolicyConfEvent event2 = new RendererPolicyConfEvent(RENDERER_POLICY_IID, rendererPolicy, rendererPolicy2); vppRendererPolicyManager.rendererPolicyChanged(event2); client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface); web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface); client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface); web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface); rTx = dataBroker.newReadOnlyTransaction(); optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION, IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER)) .get(); Assert.assertTrue(optLocationProvider.isPresent()); epLocs = optLocationProvider.get().getProviderAddressEndpointLocation(); Assert.assertNotNull(epLocs); Assert.assertEquals(4, epLocs.size()); assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs); AbsoluteLocation client2Location = DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME); configuration = DtoFactory.createConfiguration( Arrays.asList(new AddressEndpointWithLocationBuilder(client1Ep).setAbsoluteLocation(client1Location) .build(), new AddressEndpointWithLocationBuilder(client2Ep).setAbsoluteLocation(client2Location).build()), Arrays.asList(new AddressEndpointWithLocationBuilder(web1Ep).setAbsoluteLocation(web1Location).build(), new AddressEndpointWithLocationBuilder(web2Ep).setAbsoluteLocation(web2Location).build())); RendererPolicy rendererPolicy3 = new RendererPolicyBuilder().setVersion(3L).setConfiguration(configuration).build(); RendererPolicyConfEvent event3 = new RendererPolicyConfEvent(RENDERER_POLICY_IID, rendererPolicy2, rendererPolicy3); vppRendererPolicyManager.rendererPolicyChanged(event3); client1Iface = readAndAssertInterface(CLIENT_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client1Iface); web1Iface = readAndAssertInterface(WEB_1_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web1Iface); client2Iface = readAndAssertInterface(CLIENT_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), client2Iface); web2Iface = readAndAssertInterface(WEB_2_IFACE_NAME); assertBridgeDomainOnInterface(DtoFactory.L2FD_CTX.getValue(), web2Iface); rTx = dataBroker.newReadOnlyTransaction(); optLocationProvider = rTx.read(LogicalDatastoreType.CONFIGURATION, IidFactory.locationProviderIid(VppEndpointLocationProvider.VPP_ENDPOINT_LOCATION_PROVIDER)) .get(); Assert.assertTrue(optLocationProvider.isPresent()); epLocs = optLocationProvider.get().getProviderAddressEndpointLocation(); Assert.assertNotNull(epLocs); Assert.assertEquals(4, epLocs.size()); assertProviderAddressEndpointLocation(client1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web1Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_1_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(client2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_1_IID, DtoFactory.L2FD_CTX.getValue(), CLIENT_2_IFACE_NAME), epLocs); assertProviderAddressEndpointLocation(web2Ep.getKey(), DtoFactory.absoluteLocation(DtoFactory.VPP_NODE_2_IID, DtoFactory.L2FD_CTX.getValue(), WEB_2_IFACE_NAME), epLocs); }
@Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); @Subscribe void rendererPolicyChanged(RendererPolicyConfEvent event); @Subscribe void vppNodeChanged(NodeOperEvent event); }
VppRendererPolicyManager { @Subscribe public void rendererPolicyChanged(RendererPolicyConfEvent event) { RendererPolicyBuilder responseBuilder = new RendererPolicyBuilder(); switch (event.getDtoModificationType()) { case CREATED: LOG.debug("CREATED : {}", event.getIid()); responseBuilder.setVersion(event.getAfter().get().getVersion()); rendererPolicyCreated(event.getAfter().get()); break; case UPDATED: LOG.debug("UPDATED: {}", event.getIid()); RendererPolicy rPolicyBefore = event.getBefore().get(); RendererPolicy rPolicyAfter = event.getAfter().get(); responseBuilder.setVersion(rPolicyAfter.getVersion()); if (rPolicyBefore.getConfiguration() == null && rPolicyAfter.getConfiguration() == null) { LOG.debug("Configuration is not changed only updating config version from {} to {}", rPolicyBefore.getVersion(), rPolicyAfter.getVersion()); } else { rendererPolicyUpdated(rPolicyBefore, rPolicyAfter); } break; case DELETED: LOG.debug("DELETED: {}", event.getIid()); responseBuilder.setVersion(event.getBefore().get().getVersion()); rendererPolicyDeleted(event.getBefore().get()); break; } WriteTransaction wTx = dataProvider.newWriteOnlyTransaction(); RendererPolicy response = responseBuilder.build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.rendererIid(VppRenderer.NAME).child(RendererPolicy.class), response, true); try { wTx.submit().get(); } catch (Exception ex) { LOG.trace("Got Exception in renderer policy update. Exception: {}", ex); } } VppRendererPolicyManager(@Nonnull ForwardingManager fwManager, @Nonnull AclManager aclManager,
                                    @Nonnull DataBroker dataProvider); @Subscribe void rendererPolicyChanged(RendererPolicyConfEvent event); @Subscribe void vppNodeChanged(NodeOperEvent event);  }