use of org.opendaylight.controller.md.sal.binding.api.DataObjectModification in project netvirt by opendaylight.
the class LocalUcastMacListener method getChildMod.
@Override
protected Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> getChildMod(final InstanceIdentifier<Node> parentIid, final DataObjectModification<Node> mod) {
Map<InstanceIdentifier<LocalUcastMacs>, DataObjectModification<LocalUcastMacs>> result = new HashMap<>();
DataObjectModification<HwvtepGlobalAugmentation> aug = mod.getModifiedAugmentation(HwvtepGlobalAugmentation.class);
if (aug != null && getModificationType(aug) != null) {
Collection<DataObjectModification<? extends DataObject>> children = aug.getModifiedChildren();
children.stream().filter(childMod -> getModificationType(childMod) != null).filter(childMod -> childMod.getDataType() == LocalUcastMacs.class).forEach(childMod -> {
LocalUcastMacs afterMac = (LocalUcastMacs) childMod.getDataAfter();
LocalUcastMacs mac = afterMac != null ? afterMac : (LocalUcastMacs) childMod.getDataBefore();
InstanceIdentifier<LocalUcastMacs> iid = parentIid.augmentation(HwvtepGlobalAugmentation.class).child(LocalUcastMacs.class, mac.getKey());
result.put(iid, (DataObjectModification<LocalUcastMacs>) childMod);
});
}
return result;
}
use of org.opendaylight.controller.md.sal.binding.api.DataObjectModification in project netvirt by opendaylight.
the class MergeCommandsAggregator method mergeUpdate.
public void mergeUpdate(InstanceIdentifier<Node> dstPath, DataObjectModification mod, LogicalDatastoreType datastoreType, ReadWriteTransaction tx) {
if (mod == null) {
return;
}
Collection<DataObjectModification> modifications = mod.getModifiedChildren();
modifications.stream().filter(modification -> skipCopy.negate().test(datastoreType, modification.getDataType())).filter(modification -> commands.get(modification.getDataType()) != null).peek(modification -> LOG.debug("Received {} modification {} copy/delete to {}", datastoreType, modification, dstPath)).forEach(modification -> {
MergeCommand mergeCommand = commands.get(modification.getDataType());
boolean create = modification.getDataAfter() != null;
DataObject data = create ? modification.getDataAfter() : modification.getDataBefore();
InstanceIdentifier<DataObject> transformedId = mergeCommand.generateId(dstPath, data);
DataObject transformedItem = mergeCommand.transform(dstPath, data);
Optional<DataObject> existingDataOptional = null;
try {
existingDataOptional = tx.read(datastoreType, transformedId).checkedGet();
} catch (ReadFailedException ex) {
LOG.error("Failed to read data {} from {}", transformedId, datastoreType);
return;
}
String destination = datastoreType == CONFIGURATION ? "child" : "parent";
if (create) {
if (isDataUpdated(existingDataOptional, transformedItem)) {
LOG.debug("Copy to {} {} {}", destination, datastoreType, transformedId);
tx.put(datastoreType, transformedId, transformedItem, true);
} else {
LOG.debug("Data not updated skip copy to {}", transformedId);
}
} else {
if (existingDataOptional.isPresent()) {
LOG.debug("Delete from {} {} {}", destination, datastoreType, transformedId);
tx.delete(datastoreType, transformedId);
} else {
LOG.debug("Delete skipped for {}", transformedId);
}
}
});
}
use of org.opendaylight.controller.md.sal.binding.api.DataObjectModification 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.controller.md.sal.binding.api.DataObjectModification in project bgpcep by opendaylight.
the class LocRibWriter method updateNodes.
@SuppressWarnings("unchecked")
private void updateNodes(final DataObjectModification<Tables> table, final UnsignedInteger peerUuid, final WriteTransaction tx, final Map<RouteUpdateKey, RouteEntry> routes) {
final DataObjectModification<Attributes> attUpdate = table.getModifiedChildContainer(Attributes.class);
if (attUpdate != null && attUpdate.getDataAfter() != null) {
final Attributes newAttValue = attUpdate.getDataAfter();
LOG.trace("Uptodate found for {}", newAttValue);
tx.put(LogicalDatastoreType.OPERATIONAL, this.locRibTableIID.child(Attributes.class), newAttValue);
}
final DataObjectModification routesChangesContainer = table.getModifiedChildContainer(this.ribSupport.routesContainerClass());
if (routesChangesContainer == null) {
return;
}
updateRoutesEntries(routesChangesContainer.getModifiedChildren(), peerUuid, routes);
}
use of org.opendaylight.controller.md.sal.binding.api.DataObjectModification in project lispflowmapping by opendaylight.
the class AuthenticationKeyDataListenerTest method onDataTreeChangedTest_nullModType.
/**
* Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with null mod type.
*/
@Test
@SuppressWarnings("unchecked")
public void onDataTreeChangedTest_nullModType() {
final DataTreeModification<AuthenticationKey> change_nullModType = Mockito.mock(DataTreeModification.class);
final DataObjectModification mod_nullModType = Mockito.mock(DataObjectModification.class);
Mockito.when(change_nullModType.getRootNode()).thenReturn(mod_nullModType);
Mockito.when(mod_nullModType.getModificationType()).thenReturn(null);
authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_nullModType));
Mockito.verifyZeroInteractions(akdbMock);
}
Aggregations