- private void processRoute(final DOMDataWriteTransaction tx, final RIBSupport ribSupport,
- final YangInstanceIdentifier routesPath, final DataTreeCandidateNode route) {
- LOG.debug("Process route {}", route.getIdentifier());
- final YangInstanceIdentifier routeId = ribSupport.routePath(routesPath, route.getIdentifier());
- final TablesKey tablesKey = new TablesKey(ribSupport.getAfi(), ribSupport.getSafi());
- switch (route.getModificationType()) {
- case DELETE:
- case DISAPPEARED:
- tx.delete(LogicalDatastoreType.OPERATIONAL, routeId);
- LOG.debug("Route deleted. routeId={}", routeId);
- CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey);
- break;
- case UNMODIFIED:
- // No-op
- break;
- case APPEARED:
- case SUBTREE_MODIFIED:
- case WRITE:
- final NormalizedNode<?, ?> advRoute = route.getDataAfter().get();
- tx.put(LogicalDatastoreType.OPERATIONAL, routeId, advRoute);
- CountersUtil.increment(this.prefixesReceived.get(tablesKey), tablesKey);
- // Lookup per-table attributes from RIBSupport
-
- final NodeIdentifierWithPredicates routeIdentifier = ribSupport
- .createRouteKeyPathArgument((NodeIdentifierWithPredicates) route.getIdentifier());
- Optional<Attributes> advertisedAttrs = this.attBindingCodecSerializer
- .getAttributes(ribSupport, routeIdentifier, advRoute);
-
- final Optional<Attributes> effectiveAttrs;
- if (advertisedAttrs.isPresent()) {
- final PeerRole peerRole = this.peerTracker.getRole(this.peerId);
- final BGPRouteEntryImportParameters ribPolicyParameters =
- new BGPRouteEntryImportParametersImpl(
- (NodeIdentifierWithPredicates) route.getIdentifier(), this.peerId, peerRole);
- effectiveAttrs = this.ribPolicies
- .applyImportPolicies(ribPolicyParameters, advertisedAttrs.get());
- LOG.debug("Route {} effective attributes {} towards {}", route.getIdentifier(), effectiveAttrs,
- routeId);
-
- } else {
- effectiveAttrs = Optional.empty();
- }
-
- LOG.debug("Route {} effective attributes {} towards {}", route.getIdentifier(), effectiveAttrs, routeId);
-
- final Optional<ContainerNode> normEffAtt = this.attBindingCodecSerializer
- .toNormalizedNodeAttribute(ribSupport, routeIdentifier, effectiveAttrs);
- if (normEffAtt.isPresent()) {
- tx.put(LogicalDatastoreType.OPERATIONAL,
- routeId.node(ribSupport.routeAttributesIdentifier()), normEffAtt.get());
- if (route.getModificationType() == ModificationType.WRITE) {
- CountersUtil.increment(this.prefixesInstalled.get(tablesKey), tablesKey);
- }
- } else {
- LOG.warn("Route {} advertised empty attributes", routeId);
- tx.delete(LogicalDatastoreType.OPERATIONAL, routeId);
- }
- break;
- default:
- LOG.warn("Ignoring unhandled route {}", route);
- break;
- }
- }
-
- private void processTableChildren(final DOMDataWriteTransaction tx, final RIBSupport ribSupport, final YangInstanceIdentifier tablePath, final Collection<DataTreeCandidateNode> children) {
- for (final DataTreeCandidateNode child : children) {
- final PathArgument childIdentifier = child.getIdentifier();
- final Optional<NormalizedNode<?, ?>> childDataAfter = child.getDataAfter();
- final TablesKey tablesKey = new TablesKey(ribSupport.getAfi(), ribSupport.getSafi());
- LOG.debug("Process table {} type {}, dataAfter {}, dataBefore {}", childIdentifier, child
- .getModificationType(), childDataAfter, child.getDataBefore());
- final YangInstanceIdentifier childPath = tablePath.node(childIdentifier);
- switch (child.getModificationType()) {