Search in sources :

Example 1 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class WakeupOnNode method onDataTreeChanged.

@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Table>> modifications) {
    Short requiredTableId = 0;
    for (DataTreeModification modification : modifications) {
        if (modification.getRootNode().getModificationType() == ModificationType.SUBTREE_MODIFIED) {
            DataObject table = modification.getRootNode().getDataAfter();
            if (table instanceof Table) {
                Table tableSure = (Table) table;
                LOG.trace("table: {}", table);
                if (requiredTableId.equals(tableSure.getId())) {
                    InstanceIdentifier<Table> tablePath = modification.getRootPath().getRootIdentifier();
                    learningSwitchHandler.onSwitchAppeared(tablePath);
                }
            }
        }
    }
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table)

Example 2 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification 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 DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class NodeNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestFlowCapableNodePath(), null, createTestFlowCapableNode(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<FlowCapableNode>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(NodeUpdated.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) NodeUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeUpdated) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class FlowNotificationSupplierImplTest method testCreateChangeEvent.

@Test
public void testCreateChangeEvent() {
    final TestData testData = new TestData(createTestFlowPath(), null, createTestFlow(), DataObjectModification.ModificationType.WRITE);
    Collection<DataTreeModification<Flow>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(FlowAdded.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) ArrayList(java.util.ArrayList) FlowAdded(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded) Test(org.junit.Test)

Example 5 with DataTreeModification

use of org.opendaylight.controller.md.sal.binding.api.DataTreeModification in project openflowplugin by opendaylight.

the class MeterNotificationSupplierImplTest method testUdateChangeEvent.

@Test
public void testUdateChangeEvent() {
    final TestData testData = new TestData(createTestMeterPath(), createTestMeter(), createUpdatedTestMeter(), DataObjectModification.ModificationType.SUBTREE_MODIFIED);
    Collection<DataTreeModification<Meter>> collection = new ArrayList<>();
    collection.add(testData);
    notifSupplierImpl.onDataTreeChanged(collection);
    verify(notifProviderService, times(1)).publish(Matchers.any(MeterUpdated.class));
}
Also used : DataTreeModification(org.opendaylight.controller.md.sal.binding.api.DataTreeModification) TestData(org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData) MeterUpdated(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.MeterUpdated) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

DataTreeModification (org.opendaylight.controller.md.sal.binding.api.DataTreeModification)42 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)20 TestData (org.opendaylight.openflowplugin.applications.notification.supplier.impl.helper.TestData)19 CountDownLatch (java.util.concurrent.CountDownLatch)8 Mockito.doReturn (org.mockito.Mockito.doReturn)8 ReadWriteTransaction (org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction)8 TestUtils.newInvNodeKey (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newInvNodeKey)8 NodeId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId)8 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)8 NodeKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey)8 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)7 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)5 TpId (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId)5 TerminationPoint (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint)5 TerminationPointKey (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPointKey)5 Optional (com.google.common.base.Optional)4 DataTreeIdentifier (org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier)4 TestUtils.newLink (org.opendaylight.openflowplugin.applications.topology.manager.TestUtils.newLink)4 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)4