Search in sources :

Example 1 with DataTreeIdentifier

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));
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) TaskRetryLooper(org.opendaylight.genius.datastoreutils.TaskRetryLooper)

Example 2 with DataTreeIdentifier

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());
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeChangeListener(org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) Collection(java.util.Collection) ListItem(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItem) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) AsyncDataBroker(org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker) AbstractDataBrokerTest(org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest) Test(org.junit.Test) ListenerTest(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.ListenerTest)

Example 3 with DataTreeIdentifier

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);
}
Also used : LocRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.LocRib) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey) Tables(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)

Example 4 with DataTreeIdentifier

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);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) AuthenticationKey(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) IMappingSystem(org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Before(org.junit.Before)

Example 5 with DataTreeIdentifier

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);
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) IMappingSystem(org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem) Mapping(org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.Mapping) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Before(org.junit.Before)

Aggregations

DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)22 Before (org.junit.Before)7 FlowCapableNode (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)5 DataObjectModification (org.opendaylight.controller.md.sal.binding.api.DataObjectModification)4 SimpleTaskRetryLooper (org.opendaylight.openflowplugin.common.wait.SimpleTaskRetryLooper)4 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)4 Test (org.junit.Test)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)3 IMappingSystem (org.opendaylight.lispflowmapping.interfaces.mapcache.IMappingSystem)2 FlowCapableNodeCachedDao (org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeCachedDao)2 FlowCapableNodeDao (org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeDao)2 FlowCapableNodeOdlDao (org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeOdlDao)2 FlowCapableNodeSnapshotDao (org.opendaylight.openflowplugin.applications.frsync.dao.FlowCapableNodeSnapshotDao)2 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)2 Tables (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables)2 TopologyBuilder (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyBuilder)2 Collection (java.util.Collection)1