continue;
}
for (final DataTreeCandidateNode table : tables.getChildNodes()) {
- final PathArgument lastArg = table.getIdentifier();
- Verify.verify(lastArg instanceof NodeIdentifierWithPredicates, "Unexpected type %s in path %s", lastArg.getClass(), rootPath);
- final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) lastArg;
-
- switch (root.getModificationType()) {
- case DELETE:
- // delete the corresponding effective table
- tx.delete(LogicalDatastoreType.OPERATIONAL, effectiveTablePath(peerKey, tableKey));
- break;
- case MERGE:
- // TODO: upstream API should never give us this, as it leaks how the delta was created.
- LOG.info("Merge on {} reported, this should never have happened, but attempting to cope", rootPath);
- modifyTable(tx, peerKey, tableKey, table);
- break;
- case SUBTREE_MODIFIED:
- modifyTable(tx, peerKey, tableKey, table);
- break;
- case UNMODIFIED:
- LOG.info("Ignoring spurious notification on {} data {}", rootPath, table);
- break;
- case WRITE:
- writeTable(tx, peerKey, tableKey, table);
- break;
- default:
- LOG.warn("Ignoring unhandled root {}", root);
- break;
- }
+ changeDataTree(tx, rootPath, root, peerKey, table);
}
}
tx.submit();
}
+ private void changeDataTree(final DOMDataWriteTransaction tx, final YangInstanceIdentifier rootPath,
+ final DataTreeCandidateNode root, final NodeIdentifierWithPredicates peerKey, final DataTreeCandidateNode table) {
+
+ final PathArgument lastArg = table.getIdentifier();
+ Verify.verify(lastArg instanceof NodeIdentifierWithPredicates, "Unexpected type %s in path %s", lastArg.getClass(), rootPath);
+ final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) lastArg;
+
+ switch (root.getModificationType()) {
+ case DELETE:
+ // delete the corresponding effective table
+ tx.delete(LogicalDatastoreType.OPERATIONAL, effectiveTablePath(peerKey, tableKey));
+ break;
+ case MERGE:
+ // TODO: upstream API should never give us this, as it leaks how the delta was created.
+ LOG.info("Merge on {} reported, this should never have happened, but attempting to cope", rootPath);
+ modifyTable(tx, peerKey, tableKey, table);
+ break;
+ case SUBTREE_MODIFIED:
+ modifyTable(tx, peerKey, tableKey, table);
+ break;
+ case UNMODIFIED:
+ LOG.info("Ignoring spurious notification on {} data {}", rootPath, table);
+ break;
+ case WRITE:
+ writeTable(tx, peerKey, tableKey, table);
+ break;
+ default:
+ LOG.warn("Ignoring unhandled root {}", root);
+ break;
+ }
+ }
+
@Override
public void close() {
// FIXME: wipe all effective routes?
* calculations when multiple peers have changed a particular entry.
*/
final Map<RouteUpdateKey, AbstractRouteEntry> toUpdate = new HashMap<>();
+ update(tx, changes, toUpdate);
+
+ // Now walk all updated entries
+ walkThrough(tx, toUpdate);
+
+ tx.submit();
+ }
+
+ private void walkThrough(final DOMDataWriteTransaction tx, final Map<RouteUpdateKey, AbstractRouteEntry> toUpdate) {
+ for (final Entry<RouteUpdateKey, AbstractRouteEntry> e : toUpdate.entrySet()) {
+ LOG.trace("Walking through {}", e);
+ final AbstractRouteEntry entry = e.getValue();
+ final RouteUpdateKey key = e.getKey();
+ final NormalizedNode<?, ?> value;
+
+ if (entry != null) {
+ if (!entry.selectBest(this.ourAs)) {
+ // Best path has not changed, no need to do anything else. Proceed to next route.
+ LOG.trace("Continuing");
+ continue;
+ }
+ value = entry.createValue(key.getRouteId());
+ LOG.trace("Selected best value {}", value);
+ } else {
+ value = null;
+ }
+
+ final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget.node(Routes.QNAME), key.getRouteId());
+ if (value != null) {
+ LOG.debug("Write route to LocRib {}", value);
+ tx.put(LogicalDatastoreType.OPERATIONAL, writePath, value);
+ } else {
+ LOG.debug("Delete route from LocRib {}", entry);
+ tx.delete(LogicalDatastoreType.OPERATIONAL, writePath);
+ }
+ fillAdjRibsOut(tx, entry, value, key);
+ }
+ }
+
+ private void update(final DOMDataWriteTransaction tx, final Collection<DataTreeCandidate> changes,
+ final Map<RouteUpdateKey, AbstractRouteEntry> toUpdate) {
+
for (final DataTreeCandidate tc : changes) {
final YangInstanceIdentifier path = tc.getRootPath();
final NodeIdentifierWithPredicates peerKey = IdentifierUtils.peerKey(path);
}
}
}
-
- // Now walk all updated entries
- for (final Entry<RouteUpdateKey, AbstractRouteEntry> e : toUpdate.entrySet()) {
- LOG.trace("Walking through {}", e);
- final AbstractRouteEntry entry = e.getValue();
- final RouteUpdateKey key = e.getKey();
- final NormalizedNode<?, ?> value;
-
- if (entry != null) {
- if (!entry.selectBest(this.ourAs)) {
- // Best path has not changed, no need to do anything else. Proceed to next route.
- LOG.trace("Continuing");
- continue;
- }
- value = entry.createValue(key.getRouteId());
- LOG.trace("Selected best value {}", value);
- } else {
- value = null;
- }
-
- final YangInstanceIdentifier writePath = this.ribSupport.routePath(this.locRibTarget.node(Routes.QNAME), key.getRouteId());
- if (value != null) {
- LOG.debug("Write route to LocRib {}", value);
- tx.put(LogicalDatastoreType.OPERATIONAL, writePath, value);
- } else {
- LOG.debug("Delete route from LocRib {}", entry);
- tx.delete(LogicalDatastoreType.OPERATIONAL, writePath);
- }
- fillAdjRibsOut(tx, entry, value, key);
- }
- tx.submit();
}
private void fillAdjRibsOut(final DOMDataWriteTransaction tx, final AbstractRouteEntry entry, final NormalizedNode<?, ?> value, final RouteUpdateKey key) {