@Test public void testOnDelete() throws Exception { ArgumentCaptor<VppEndpointConfEvent> argVppEpEvent = ArgumentCaptor.forClass(VppEndpointConfEvent.class); VppEndpoint vppEndpoint = getBaseVppEndpointBuilder() .build(); InstanceIdentifier<VppEndpoint> vppEpIid = InstanceIdentifier.builder(Config.class).child(VppEndpoint.class, vppEndpoint.getKey()).build(); WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, vppEpIid, vppEndpoint); wTx.submit().get(); wTx = getDataBroker().newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.CONFIGURATION, vppEpIid); wTx.submit().get(); Mockito.verify(eventBusMock, Mockito.times(2)).post(argVppEpEvent.capture()); VppEndpointConfEvent capturedVppEpEvent = argVppEpEvent.getAllValues().get(1); Assert.assertEquals(vppEpIid, capturedVppEpEvent.getIid()); assertEqualsOptional(vppEndpoint, capturedVppEpEvent.getBefore()); assertEqualsOptional(null, capturedVppEpEvent.getAfter()); }
@Override protected void onDelete(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { if (ConfigUtil.getInstance().isL3FlatEnabled()) { VppEndpoint vppEndpointBefore = rootNode.getDataBefore(); Preconditions.checkNotNull(vppEndpointBefore, "VppEndpoint cannot be null on delete operation."); LOG.trace("onDelete -> Vppendpoint deleted: {}", vppEndpointBefore); Preconditions.checkArgument(vppEndpointBefore.getVppNodeId() != null); Preconditions.checkArgument(vppEndpointBefore.getVppInterfaceName() != null); String intfName = rootNode.getDataBefore().getVppInterfaceName(); LOG.info("onDelete -> Checking pending endpoint to delete {}", pendingEndpointsTable.get(vppEndpointBefore.getVppNodeId().getValue(), intfName)); if(!portIsBusy(rootNode.getDataBefore())) { LOG.info("onDelete -> Endpoint is not busy, deleting {}", vppEndpointBefore); deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } else { LOG.info("onDelete -> Caching pending deleted endpoint {}", rootNode.getDataBefore()); pendingEndpointsTable.put(vppEndpointBefore.getVppNodeId().getValue(), intfName, new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } else { deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } }
VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> { @Override protected void onDelete(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { if (ConfigUtil.getInstance().isL3FlatEnabled()) { VppEndpoint vppEndpointBefore = rootNode.getDataBefore(); Preconditions.checkNotNull(vppEndpointBefore, "VppEndpoint cannot be null on delete operation."); LOG.trace("onDelete -> Vppendpoint deleted: {}", vppEndpointBefore); Preconditions.checkArgument(vppEndpointBefore.getVppNodeId() != null); Preconditions.checkArgument(vppEndpointBefore.getVppInterfaceName() != null); String intfName = rootNode.getDataBefore().getVppInterfaceName(); LOG.info("onDelete -> Checking pending endpoint to delete {}", pendingEndpointsTable.get(vppEndpointBefore.getVppNodeId().getValue(), intfName)); if(!portIsBusy(rootNode.getDataBefore())) { LOG.info("onDelete -> Endpoint is not busy, deleting {}", vppEndpointBefore); deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } else { LOG.info("onDelete -> Caching pending deleted endpoint {}", rootNode.getDataBefore()); pendingEndpointsTable.put(vppEndpointBefore.getVppNodeId().getValue(), intfName, new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } else { deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } }
VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> { @Override protected void onDelete(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { if (ConfigUtil.getInstance().isL3FlatEnabled()) { VppEndpoint vppEndpointBefore = rootNode.getDataBefore(); Preconditions.checkNotNull(vppEndpointBefore, "VppEndpoint cannot be null on delete operation."); LOG.trace("onDelete -> Vppendpoint deleted: {}", vppEndpointBefore); Preconditions.checkArgument(vppEndpointBefore.getVppNodeId() != null); Preconditions.checkArgument(vppEndpointBefore.getVppInterfaceName() != null); String intfName = rootNode.getDataBefore().getVppInterfaceName(); LOG.info("onDelete -> Checking pending endpoint to delete {}", pendingEndpointsTable.get(vppEndpointBefore.getVppNodeId().getValue(), intfName)); if(!portIsBusy(rootNode.getDataBefore())) { LOG.info("onDelete -> Endpoint is not busy, deleting {}", vppEndpointBefore); deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } else { LOG.info("onDelete -> Caching pending deleted endpoint {}", rootNode.getDataBefore()); pendingEndpointsTable.put(vppEndpointBefore.getVppNodeId().getValue(), intfName, new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } else { deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } VppEndpointListener(DataBroker dataProvider, EventBus eventBus); }
VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> { @Override protected void onDelete(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { if (ConfigUtil.getInstance().isL3FlatEnabled()) { VppEndpoint vppEndpointBefore = rootNode.getDataBefore(); Preconditions.checkNotNull(vppEndpointBefore, "VppEndpoint cannot be null on delete operation."); LOG.trace("onDelete -> Vppendpoint deleted: {}", vppEndpointBefore); Preconditions.checkArgument(vppEndpointBefore.getVppNodeId() != null); Preconditions.checkArgument(vppEndpointBefore.getVppInterfaceName() != null); String intfName = rootNode.getDataBefore().getVppInterfaceName(); LOG.info("onDelete -> Checking pending endpoint to delete {}", pendingEndpointsTable.get(vppEndpointBefore.getVppNodeId().getValue(), intfName)); if(!portIsBusy(rootNode.getDataBefore())) { LOG.info("onDelete -> Endpoint is not busy, deleting {}", vppEndpointBefore); deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } else { LOG.info("onDelete -> Caching pending deleted endpoint {}", rootNode.getDataBefore()); pendingEndpointsTable.put(vppEndpointBefore.getVppNodeId().getValue(), intfName, new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } else { deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } VppEndpointListener(DataBroker dataProvider, EventBus eventBus); void flushPendingVppEndpoint(@Nonnull String hostName,@Nonnull String intfName); }
VppEndpointListener extends DataTreeChangeHandler<VppEndpoint> { @Override protected void onDelete(DataObjectModification<VppEndpoint> rootNode, InstanceIdentifier<VppEndpoint> rootIdentifier) { if (ConfigUtil.getInstance().isL3FlatEnabled()) { VppEndpoint vppEndpointBefore = rootNode.getDataBefore(); Preconditions.checkNotNull(vppEndpointBefore, "VppEndpoint cannot be null on delete operation."); LOG.trace("onDelete -> Vppendpoint deleted: {}", vppEndpointBefore); Preconditions.checkArgument(vppEndpointBefore.getVppNodeId() != null); Preconditions.checkArgument(vppEndpointBefore.getVppInterfaceName() != null); String intfName = rootNode.getDataBefore().getVppInterfaceName(); LOG.info("onDelete -> Checking pending endpoint to delete {}", pendingEndpointsTable.get(vppEndpointBefore.getVppNodeId().getValue(), intfName)); if(!portIsBusy(rootNode.getDataBefore())) { LOG.info("onDelete -> Endpoint is not busy, deleting {}", vppEndpointBefore); deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } else { LOG.info("onDelete -> Caching pending deleted endpoint {}", rootNode.getDataBefore()); pendingEndpointsTable.put(vppEndpointBefore.getVppNodeId().getValue(), intfName, new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } else { deleteVppEndpoint(new VppEndpointConfEvent(rootIdentifier, rootNode.getDataBefore(), rootNode.getDataAfter())); } } VppEndpointListener(DataBroker dataProvider, EventBus eventBus); void flushPendingVppEndpoint(@Nonnull String hostName,@Nonnull String intfName);  }