@Test public void testUnregisterEndpoint_containmentEndpointWithChild() throws Exception { WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction(); ContainmentEndpoint contEpWithL2EpChild = createBaseContEpBuilder().setChildEndpoint(Arrays.asList(BASE_L2_CHILD)).build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(contEpWithL2EpChild.getKey()), contEpWithL2EpChild); AddressEndpoint l2EpWithContEpParent = createBaseL2EpBuilder().setParentEndpointChoice(new ParentContainmentEndpointCaseBuilder() .setParentContainmentEndpoint(Arrays.asList(BASE_CONT_PARENT)).build()).build(); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(l2EpWithContEpParent.getKey()), l2EpWithContEpParent); wTx.submit().get(); UnregisterEndpointInputBuilder inputBuilder = new UnregisterEndpointInputBuilder(); setContEpsToBuilder(inputBuilder, contEpWithL2EpChild); RpcResult<Void> rpcResult = baseEndpointRpcRegistry.unregisterEndpoint(inputBuilder.build()).get(); Assert.assertTrue(rpcResult.isSuccessful()); ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction(); Optional<ContainmentEndpoint> contEpWithL2EpChildFromDsOptional = DataStoreHelper.readFromDs( LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(contEpWithL2EpChild.getKey()), rTx); Assert.assertFalse(contEpWithL2EpChildFromDsOptional.isPresent()); Optional<AddressEndpoint> l2EpWithContEpParentFromDsOptional = DataStoreHelper.readFromDs( LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(l2EpWithContEpParent.getKey()), rTx); Assert.assertTrue(l2EpWithContEpParentFromDsOptional.isPresent()); Assert.assertEquals(0, EndpointUtils .getParentEndpoints(l2EpWithContEpParentFromDsOptional.get().getParentEndpointChoice()).size()); }
@Override public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) { ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); List<AddressEndpointUnreg> addrEndpoints = input.getAddressEndpointUnreg(); for (AddressEndpointUnreg aeUnreg : nullToEmpty(addrEndpoints)) { AddressEndpointKey key = new AddressEndpointKey(aeUnreg.getAddress(), aeUnreg.getAddressType(), aeUnreg.getContextId(), aeUnreg.getContextType()); Optional<AddressEndpoint> aeOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(key), t); if (aeOptional.isPresent()) { deleteAddressEndpointFromParents(t, aeOptional.get()); deleteAddressEndpointFromChilds(t, aeOptional.get()); } } List<ContainmentEndpointUnreg> contEndpoints = input.getContainmentEndpointUnreg(); for (ContainmentEndpointUnreg ceUnreg : nullToEmpty(contEndpoints)) { ContainmentEndpointKey key = new ContainmentEndpointKey(ceUnreg.getContextId(), ceUnreg.getContextType()); Optional<ContainmentEndpoint> ceOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(key), t); if (ceOptional.isPresent()) { deleteContainmentEndpointFromChilds(t, ceOptional.get()); } } ListenableFuture<Void> r = t.submit(); return Futures.transform(r, TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) { ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); List<AddressEndpointUnreg> addrEndpoints = input.getAddressEndpointUnreg(); for (AddressEndpointUnreg aeUnreg : nullToEmpty(addrEndpoints)) { AddressEndpointKey key = new AddressEndpointKey(aeUnreg.getAddress(), aeUnreg.getAddressType(), aeUnreg.getContextId(), aeUnreg.getContextType()); Optional<AddressEndpoint> aeOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(key), t); if (aeOptional.isPresent()) { deleteAddressEndpointFromParents(t, aeOptional.get()); deleteAddressEndpointFromChilds(t, aeOptional.get()); } } List<ContainmentEndpointUnreg> contEndpoints = input.getContainmentEndpointUnreg(); for (ContainmentEndpointUnreg ceUnreg : nullToEmpty(contEndpoints)) { ContainmentEndpointKey key = new ContainmentEndpointKey(ceUnreg.getContextId(), ceUnreg.getContextType()); Optional<ContainmentEndpoint> ceOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(key), t); if (ceOptional.isPresent()) { deleteContainmentEndpointFromChilds(t, ceOptional.get()); } } ListenableFuture<Void> r = t.submit(); return Futures.transform(r, TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) { ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); List<AddressEndpointUnreg> addrEndpoints = input.getAddressEndpointUnreg(); for (AddressEndpointUnreg aeUnreg : nullToEmpty(addrEndpoints)) { AddressEndpointKey key = new AddressEndpointKey(aeUnreg.getAddress(), aeUnreg.getAddressType(), aeUnreg.getContextId(), aeUnreg.getContextType()); Optional<AddressEndpoint> aeOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(key), t); if (aeOptional.isPresent()) { deleteAddressEndpointFromParents(t, aeOptional.get()); deleteAddressEndpointFromChilds(t, aeOptional.get()); } } List<ContainmentEndpointUnreg> contEndpoints = input.getContainmentEndpointUnreg(); for (ContainmentEndpointUnreg ceUnreg : nullToEmpty(contEndpoints)) { ContainmentEndpointKey key = new ContainmentEndpointKey(ceUnreg.getContextId(), ceUnreg.getContextType()); Optional<ContainmentEndpoint> ceOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(key), t); if (ceOptional.isPresent()) { deleteContainmentEndpointFromChilds(t, ceOptional.get()); } } ListenableFuture<Void> r = t.submit(); return Futures.transform(r, TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) { ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); List<AddressEndpointUnreg> addrEndpoints = input.getAddressEndpointUnreg(); for (AddressEndpointUnreg aeUnreg : nullToEmpty(addrEndpoints)) { AddressEndpointKey key = new AddressEndpointKey(aeUnreg.getAddress(), aeUnreg.getAddressType(), aeUnreg.getContextId(), aeUnreg.getContextType()); Optional<AddressEndpoint> aeOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(key), t); if (aeOptional.isPresent()) { deleteAddressEndpointFromParents(t, aeOptional.get()); deleteAddressEndpointFromChilds(t, aeOptional.get()); } } List<ContainmentEndpointUnreg> contEndpoints = input.getContainmentEndpointUnreg(); for (ContainmentEndpointUnreg ceUnreg : nullToEmpty(contEndpoints)) { ContainmentEndpointKey key = new ContainmentEndpointKey(ceUnreg.getContextId(), ceUnreg.getContextType()); Optional<ContainmentEndpoint> ceOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(key), t); if (ceOptional.isPresent()) { deleteContainmentEndpointFromChilds(t, ceOptional.get()); } } ListenableFuture<Void> r = t.submit(); return Futures.transform(r, TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override void close(); }
BaseEndpointServiceImpl implements BaseEndpointService, AutoCloseable { @Override public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) { ReadWriteTransaction t = dataProvider.newReadWriteTransaction(); List<AddressEndpointUnreg> addrEndpoints = input.getAddressEndpointUnreg(); for (AddressEndpointUnreg aeUnreg : nullToEmpty(addrEndpoints)) { AddressEndpointKey key = new AddressEndpointKey(aeUnreg.getAddress(), aeUnreg.getAddressType(), aeUnreg.getContextId(), aeUnreg.getContextType()); Optional<AddressEndpoint> aeOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.addressEndpointIid(key), t); if (aeOptional.isPresent()) { deleteAddressEndpointFromParents(t, aeOptional.get()); deleteAddressEndpointFromChilds(t, aeOptional.get()); } } List<ContainmentEndpointUnreg> contEndpoints = input.getContainmentEndpointUnreg(); for (ContainmentEndpointUnreg ceUnreg : nullToEmpty(contEndpoints)) { ContainmentEndpointKey key = new ContainmentEndpointKey(ceUnreg.getContextId(), ceUnreg.getContextType()); Optional<ContainmentEndpoint> ceOptional = DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.containmentEndpointIid(key), t); if (ceOptional.isPresent()) { deleteContainmentEndpointFromChilds(t, ceOptional.get()); } } ListenableFuture<Void> r = t.submit(); return Futures.transform(r, TO_SUCCESS_RPC_RESULT, MoreExecutors.directExecutor()); } BaseEndpointServiceImpl(DataBroker dataProvider, EndpointAugmentorRegistryImpl epAugRegistry); @Override Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input); @Override Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input); @Override void close();  }