use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class DsbenchmarkListener method logDataTreeChangeEvent.
private static synchronized void logDataTreeChangeEvent(final int eventNum, final Collection<DataTreeModification<TestExec>> changes) {
LOG.debug("DsbenchmarkListener-onDataTreeChanged: Event {}", eventNum);
for (DataTreeModification<TestExec> change : changes) {
final DataObjectModification<TestExec> rootNode = change.getRootNode();
final ModificationType modType = rootNode.getModificationType();
final PathArgument changeId = rootNode.getIdentifier();
final Collection<DataObjectModification<? extends DataObject>> modifications = rootNode.getModifiedChildren();
LOG.debug(" changeId {}, modType {}, mods: {}", changeId, modType, modifications.size());
for (DataObjectModification<? extends DataObject> mod : modifications) {
LOG.debug(" mod-getDataAfter: {}", mod.getDataAfter());
}
}
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class Bug1418AugmentationTest method complexAugmentationUpdatedTest.
@Test
public void complexAugmentationUpdatedTest() {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY_MOD));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getUpdatedData(), COMPLEX_AUGMENT);
assertContains(event.getCreatedData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY_MOD));
assertContains(event.getRemovedPaths(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
assertContains(event.getOriginalData(), COMPLEX_AUGMENT);
assertContains(event.getOriginalData(), COMPLEX_AUGMENT.child(ListViaUses.class, LIST_VIA_USES_KEY));
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class Bug1418AugmentationTest method leafOnlyAugmentationCreatedTest.
@Test
public void leafOnlyAugmentationCreatedTest() {
final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, AsyncDataBroker.DataChangeScope.SUBTREE, false);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> event = listener.event();
assertContains(event.getCreatedData(), SIMPLE_AUGMENT);
assertEmpty(event.getUpdatedData());
assertEmpty(event.getOriginalData());
assertEmpty(event.getRemovedPaths());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class ListInsertionDataChangeListenerTest method replaceTopNodeSubtreeListeners.
@Test
public void replaceTopNodeSubtreeListeners() {
TestListener topListener = createListener(CONFIGURATION, TOP, DataChangeScope.SUBTREE);
TestListener allListener = createListener(CONFIGURATION, WILDCARDED, DataChangeScope.SUBTREE, false);
TestListener fooListener = createListener(CONFIGURATION, TOP_FOO, DataChangeScope.SUBTREE);
TestListener barListener = createListener(CONFIGURATION, TOP_BAR, DataChangeScope.SUBTREE, false);
ReadWriteTransaction writeTx = getDataBroker().newReadWriteTransaction();
writeTx.put(CONFIGURATION, TOP, top(topLevelList(TOP_BAR_KEY)));
assertCommit(writeTx.submit());
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> top = topListener.event();
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> all = allListener.event();
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> foo = fooListener.event();
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> bar = barListener.event();
// Listener for TOP element
assertContains(top.getOriginalData(), TOP, TOP_FOO);
assertContains(top.getCreatedData(), TOP_BAR);
assertContains(top.getUpdatedData(), TOP);
assertContains(top.getRemovedPaths(), TOP_FOO);
/*
* Listener for all list items
*
* Updated should be empty, since no list item was
* updated, items were only removed and added
*/
assertContains(all.getOriginalData(), TOP_FOO);
assertContains(all.getCreatedData(), TOP_BAR);
assertEmpty(all.getUpdatedData());
assertContains(all.getRemovedPaths(), TOP_FOO);
/*
* Listener for all Foo item
*
* This one should see only Foo item removed
*/
assertContains(foo.getOriginalData(), TOP_FOO);
assertEmpty(foo.getCreatedData());
assertEmpty(foo.getUpdatedData());
assertContains(foo.getRemovedPaths(), TOP_FOO);
/*
* Listener for bar list items
*
* Updated should be empty, since no list item was
* updated, items were only removed and added
*/
assertEmpty(bar.getOriginalData());
assertContains(bar.getCreatedData(), TOP_BAR);
assertEmpty(bar.getUpdatedData());
assertEmpty(bar.getRemovedPaths());
}
use of org.opendaylight.yangtools.yang.binding.DataObject in project controller by opendaylight.
the class AbstractForwardedDataBroker method toBinding.
protected Set<InstanceIdentifier<?>> toBinding(final InstanceIdentifier<?> path, final Set<YangInstanceIdentifier> normalized) {
final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
for (final YangInstanceIdentifier normalizedPath : normalized) {
try {
final Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
if (potential.isPresent()) {
final InstanceIdentifier<? extends DataObject> binding = potential.get();
hashSet.add(binding);
} else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) {
hashSet.add(path);
}
} catch (final DeserializationException e) {
LOG.warn("Failed to transform {}, omitting it", normalizedPath, e);
}
}
return hashSet;
}
Aggregations