use of org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier in project netvirt by opendaylight.
the class ChildListener method registerListener.
private ListenerRegistration<?> registerListener(final LogicalDatastoreType dsType, final InstanceIdentifier wildCard) throws Exception {
DataTreeIdentifier<P> treeId = new DataTreeIdentifier<>(dsType, wildCard);
TaskRetryLooper looper = new TaskRetryLooper(STARTUP_LOOP_TICK, STARTUP_LOOP_MAX_RETRIES);
return looper.loopUntilNoException(() -> dataBroker.registerDataTreeChangeListener(treeId, this));
}
use of org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier in project controller by opendaylight.
the class Bug4513Test method testDataTreeChangeListener.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testDataTreeChangeListener() throws Exception {
DataBroker dataBroker = getDataBroker();
DataTreeChangeListener<ListItem> listener = mock(DataTreeChangeListener.class);
InstanceIdentifier<ListItem> wildCard = InstanceIdentifier.builder(ListenerTest.class).child(ListItem.class).build();
ListenerRegistration<DataTreeChangeListener<ListItem>> reg = dataBroker.registerDataTreeChangeListener(new DataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, wildCard), listener);
final ListItem item = writeListItem();
ArgumentCaptor<Collection> captor = ArgumentCaptor.forClass(Collection.class);
verify(listener, timeout(100)).onDataTreeChanged(captor.capture());
Collection<DataTreeModification<ListItem>> mods = captor.getValue();
assertEquals("ListItem", item, mods.iterator().next().getRootNode().getDataAfter());
}
use of org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier in project bgpcep by opendaylight.
the class AbstractTopologyBuilder method registerDataChangeListener.
/**
* Register to data tree change listener.
*/
private synchronized void registerDataChangeListener() {
Preconditions.checkState(this.listenerRegistration == null, "Topology Listener on topology %s has been registered before.", this.getInstanceIdentifier());
final InstanceIdentifier<Tables> tablesId = this.locRibReference.getInstanceIdentifier().child(LocRib.class).child(Tables.class, new TablesKey(this.afi, this.safi));
final DataTreeIdentifier<T> id = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, getRouteWildcard(tablesId));
this.listenerRegistration = this.dataProvider.registerDataTreeChangeListener(id, this);
LOG.debug("Registered listener {} on topology {}. Timestamp={}", this, this.getInstanceIdentifier(), this.listenerScheduledRestartTime);
}
use of org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListenerTest method init.
@Before
@SuppressWarnings("unchecked")
public void init() {
DataBroker dataBrokerMock = Mockito.mock(DataBroker.class);
iMappingSystemMock = Mockito.mock(IMappingSystem.class);
authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBrokerMock, iMappingSystemMock);
final InstanceIdentifier<AuthenticationKey> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
change_write = Mockito.mock(DataTreeModification.class);
mod_del = Mockito.mock(DataObjectModification.class);
mod_subtreeModified = Mockito.mock(DataObjectModification.class);
mod_write = Mockito.mock(DataObjectModification.class);
Mockito.when(change_del.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_del.getRootNode()).thenReturn(mod_del);
Mockito.when(change_subtreeModified.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
}
use of org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier in project lispflowmapping by opendaylight.
the class MappingDataListenerTest method init.
@Before
@SuppressWarnings("unchecked")
public void init() {
final DataBroker dataBrokerMock = Mockito.mock(DataBroker.class);
iMappingSystemMock = Mockito.mock(IMappingSystem.class);
notificationPublishServiceMock = Mockito.mock(NotificationPublishService.class);
mappingDataListener = new MappingDataListener(dataBrokerMock, iMappingSystemMock, notificationPublishServiceMock);
final InstanceIdentifier<Mapping> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
final DataTreeIdentifier<Mapping> dataTreeIdentifier = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
change_del = Mockito.mock(DataTreeModification.class);
change_subtreeModified = Mockito.mock(DataTreeModification.class);
change_write = Mockito.mock(DataTreeModification.class);
mod_del = Mockito.mock(DataObjectModification.class);
mod_subtreeModified = Mockito.mock(DataObjectModification.class);
mod_write = Mockito.mock(DataObjectModification.class);
Mockito.when(change_del.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_del.getRootNode()).thenReturn(mod_del);
Mockito.when(change_subtreeModified.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
Mockito.when(mod_del.getModificationType()).thenReturn(ModificationType.DELETE);
Mockito.when(mod_subtreeModified.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED);
Mockito.when(mod_write.getModificationType()).thenReturn(ModificationType.WRITE);
Mockito.when(iMappingSystemMock.isMaster()).thenReturn(true);
}
Aggregations