@Test public void test_CreateLocationForAddrEndpoint_SimultaneousWrite() throws Exception { NetworkElements nes = createNetworkElements(NODE_ID_1, CONNECTOR_ID_1, L3_CONTEXT_ID, IP_V4_NETWORK_ADDRESS_1); InstanceIdentifier<NetworkElements> neIid = InstanceIdentifier.builder(NetworkElements.class).build(); WriteTransaction wtx = dataBroker.newWriteOnlyTransaction(); wtx.put(LogicalDatastoreType.CONFIGURATION, neIid, nes); wtx.submit().get(); AddressEndpoint endpoint = createAddressEndpoint(IP_V4_HOST_ADDRESS_1, IpPrefixType.class, L3_CONTEXT_ID, L3Context.class); InstanceIdentifier<AddressEndpoint> iid = IidFactory.addressEndpointIid(endpoint.getKey()); wtx = dataBroker.newWriteOnlyTransaction(); wtx.put(LogicalDatastoreType.OPERATIONAL, iid, endpoint, true); wtx.submit().get(); ReadOnlyTransaction rtx = dataBroker.newReadOnlyTransaction(); InstanceIdentifier<LocationProviders> locationIid = InstanceIdentifier.builder(LocationProviders.class).build(); CheckedFuture<Optional<LocationProviders>, ReadFailedException> read = rtx.read(LogicalDatastoreType.CONFIGURATION, locationIid); assertTrue(read.get().isPresent()); rtx.close(); LocationProviders locations = read.get().get(); LocationProviders locationReference = new LocationProvidersBuilder() .setLocationProvider(Collections.singletonList(new LocationProviderBuilder() .setProvider(new ProviderName(NeLocationProvider.NE_LOCATION_PROVIDER_NAME)) .setProviderAddressEndpointLocation(Collections.singletonList( new ProviderAddressEndpointLocationBuilder() .setAddress(IP_V4_HOST_ADDRESS_1) .setAddressType(IpPrefixType.class) .setContextId(new ContextId(L3_CONTEXT_ID)) .setContextType(L3Context.class) .setAbsoluteLocation(new AbsoluteLocationBuilder() .setLocationType(new ExternalLocationCaseBuilder() .setExternalNodeMountPoint(createNetworkElementIid(NODE_ID_1)) .setExternalNodeConnector(CONNECTOR_ID_1) .build()) .build()) .build())) .build())) .build(); assertEquals(locationReference, locations); }
@Override public void close() { this.listenerRegistration.close(); this.endpointsListener.close(); }
NeLocationProvider implements ClusteredDataTreeChangeListener<NetworkElements>, AutoCloseable { @Override public void close() { this.listenerRegistration.close(); this.endpointsListener.close(); } }
NeLocationProvider implements ClusteredDataTreeChangeListener<NetworkElements>, AutoCloseable { @Override public void close() { this.listenerRegistration.close(); this.endpointsListener.close(); } NeLocationProvider(DataBroker dataBroker); }
NeLocationProvider implements ClusteredDataTreeChangeListener<NetworkElements>, AutoCloseable { @Override public void close() { this.listenerRegistration.close(); this.endpointsListener.close(); } NeLocationProvider(DataBroker dataBroker); @Override void close(); synchronized void onEndpointsChange(Collection<DataTreeModification<AddressEndpoint>> changes); @Override synchronized void onDataTreeChanged(Collection<DataTreeModification<NetworkElements>> changes); }
NeLocationProvider implements ClusteredDataTreeChangeListener<NetworkElements>, AutoCloseable { @Override public void close() { this.listenerRegistration.close(); this.endpointsListener.close(); } NeLocationProvider(DataBroker dataBroker); @Override void close(); synchronized void onEndpointsChange(Collection<DataTreeModification<AddressEndpoint>> changes); @Override synchronized void onDataTreeChanged(Collection<DataTreeModification<NetworkElements>> changes); static final String NE_LOCATION_PROVIDER_NAME; }