From d85ae8f1faeeba36ab1321671e52dec37e139c84 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 23 Jun 2023 16:16:51 +0200 Subject: [PATCH] Remove RibSupportUtils ApplicationPeer is the last holdout of reflection-based transcoding, convert it to pick up the DOM tablesKey from RIBSupport and remove RibSupportUtils. JIRA: BGPCEP-1016 Change-Id: Ie567ecd5ff5189538a2c5a98d1cacfe8e7c83796 Signed-off-by: Robert Varga --- bgp/rib-impl/pom.xml | 8 ---- .../bgp/rib/impl/ApplicationPeer.java | 11 +++++- .../bgp/rib/impl/RibSupportUtils.java | 37 ------------------- .../bgp/rib/impl/RibSupportUtilsTest.java | 34 ----------------- 4 files changed, 9 insertions(+), 81 deletions(-) delete mode 100644 bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtils.java delete mode 100644 bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtilsTest.java diff --git a/bgp/rib-impl/pom.xml b/bgp/rib-impl/pom.xml index 11aec9db64..91ee04315b 100644 --- a/bgp/rib-impl/pom.xml +++ b/bgp/rib-impl/pom.xml @@ -89,18 +89,10 @@ org.opendaylight.mdsal mdsal-binding-api - - org.opendaylight.mdsal - mdsal-binding-spec-util - org.opendaylight.mdsal mdsal-common-api - - org.opendaylight.yangtools - util - org.opendaylight.yangtools yang-data-api diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java index 8162d365db..89f9df173e 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java @@ -131,8 +131,15 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre public synchronized void instantiateServiceInstance(final DOMDataTreeChangeService dataTreeChangeService, final DOMDataTreeIdentifier appPeerDOMId) { setActive(true); - final Set localTables = rib.getLocalTablesKeys(); - localTables.forEach(tablesKey -> supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey))); + final var localTables = rib.getLocalTablesKeys(); + for (var localTable : localTables) { + final var tableSupport = rib.getRibSupportContext().getRIBSupport(localTable); + if (tableSupport != null) { + supportedTables.add(tableSupport.tablesKey()); + } else { + LOG.warn("Ignoring unsupported table {}", localTable); + } + } setAdvertizedGracefulRestartTableTypes(List.of()); createDomChain(); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtils.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtils.java deleted file mode 100644 index a4a7aae289..0000000000 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.protocol.bgp.rib.impl; - -import com.google.common.collect.ImmutableList; -import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections; -import org.opendaylight.protocol.bgp.rib.spi.RIBQNames; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey; -import org.opendaylight.yangtools.util.ImmutableOffsetMapTemplate; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; - -final class RibSupportUtils { - private static final ImmutableOffsetMapTemplate AFI_SAFI_TEMPLATE = - ImmutableOffsetMapTemplate.ordered(ImmutableList.of(RIBQNames.AFI_QNAME, RIBQNames.SAFI_QNAME)); - - private RibSupportUtils() { - // Hidden on purpose - } - - /** - * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}. - * - * @param tablesKey Tables key representing table. - * @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination. - */ - static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey tablesKey) { - return NodeIdentifierWithPredicates.of(Tables.QNAME, AFI_SAFI_TEMPLATE.instantiateWithValues( - BindingReflections.getQName(tablesKey.getAfi()), BindingReflections.getQName(tablesKey.getSafi()))); - } -} diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtilsTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtilsTest.java deleted file mode 100644 index 3c208aa776..0000000000 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtilsTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.protocol.bgp.rib.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.Map; -import org.junit.Test; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; - -public class RibSupportUtilsTest { - @Test - public void testYangTablesKey() { - final NodeIdentifierWithPredicates p = RibSupportUtils.toYangTablesKey(new TablesKey(Ipv4AddressFamily.VALUE, - UnicastSubsequentAddressFamily.VALUE)); - final Map m = p.asMap(); - assertFalse(m.isEmpty()); - assertEquals(Tables.QNAME, p.getNodeType()); - assertTrue(m.containsValue(Ipv4AddressFamily.QNAME)); - assertTrue(m.containsValue(UnicastSubsequentAddressFamily.QNAME)); - } -} -- 2.36.6