From: Claudio D. Gasparini Date: Sun, 13 Jan 2019 13:26:48 +0000 (+0100) Subject: Handle table deletion under eff-rib-in X-Git-Tag: release/neon~23 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=4018b6cc2297c93facef3c1f42b380db017e31a1;p=bgpcep.git Handle table deletion under eff-rib-in Improve handling of empty tables Change-Id: If33ad3eea717288f743c8e74e8b5c76263dcc0a3 Signed-off-by: Claudio D. Gasparini --- diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java index 3d38a30367..1b46203fdf 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java @@ -258,11 +258,11 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn switch (child.getModificationType()) { case DELETE: LOG.debug("Route deleted. routeId={}", routesPath); - processTableChildenDelete(child, childIdentifier, tx, ribSupport, routesPath); + processTableChildrenDelete(child, childIdentifier, tx, ribSupport, routesPath); break; case DISAPPEARED: LOG.debug("Route disappeared. routeId={}", routesPath); - processTableChildenDelete(child, childIdentifier, tx, ribSupport, routesPath); + processTableChildrenDelete(child, childIdentifier, tx, ribSupport, routesPath); break; case UNMODIFIED: // No-op @@ -281,30 +281,27 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn } } - private void processTableChildenDelete( + private void processTableChildrenDelete( final DataTreeCandidateNode child, final PathArgument childIdentifier, final DOMDataWriteTransaction tx, final RIBSupport ribSupport, final YangInstanceIdentifier routesPath) { - processDeleteRouteTables(child, childIdentifier, ribSupport, routesPath); - tx.delete(LogicalDatastoreType.OPERATIONAL, routesPath); - } - - private void processDeleteRouteTables( - final DataTreeCandidateNode child, - final PathArgument childIdentifier, - final RIBSupport ribSupport, - final YangInstanceIdentifier routesPath) { if (TABLE_ROUTES.equals(childIdentifier)) { final Collection changedRoutes = ribSupport.changedRoutes(child); - for (final DataTreeCandidateNode route : changedRoutes) { - handleRouteTarget(ModificationType.DELETE, ribSupport, routesPath.getParent(), - route.getDataBefore().orElse(null)); - final TablesKey tablesKey = ribSupport.getTablesKey(); - CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey); + if (!changedRoutes.isEmpty()) { + for (final DataTreeCandidateNode route : changedRoutes) { + final NormalizedNode routeBefore = route.getDataBefore().orElse(null); + if (routeBefore != null) { + final YangInstanceIdentifier routePath = ribSupport.routePath(routesPath, route.getIdentifier()); + handleRouteTarget(ModificationType.DELETE, ribSupport, routePath, routeBefore); + final TablesKey tablesKey = ribSupport.getTablesKey(); + CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey); + } + } } } + tx.delete(LogicalDatastoreType.OPERATIONAL, routesPath); } private void processModifiedRouteTables( @@ -316,8 +313,10 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn final Optional> childDataAfter) { if (TABLE_ROUTES.equals(childIdentifier)) { final Collection changedRoutes = ribSupport.changedRoutes(child); - for (final DataTreeCandidateNode route : changedRoutes) { - processRoute(tx, ribSupport, routesPath.getParent(), route); + if (!changedRoutes.isEmpty()) { + for (final DataTreeCandidateNode route : changedRoutes) { + processRoute(tx, ribSupport, routesPath.getParent(), route); + } } } else { tx.put(LogicalDatastoreType.OPERATIONAL, routesPath, childDataAfter.get());