Remove RibSupportUtils 57/106657/2
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 23 Jun 2023 14:16:51 +0000 (16:16 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 23 Jun 2023 14:26:05 +0000 (16:26 +0200)
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 <robert.varga@pantheon.tech>
bgp/rib-impl/pom.xml
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtils.java [deleted file]
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/RibSupportUtilsTest.java [deleted file]

index 11aec9db64f992a92c95d936c3039ca7b447e4cc..91ee04315be9236047792b6013d1ddb8f00864ff 100644 (file)
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-binding-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.mdsal</groupId>
-            <artifactId>mdsal-binding-spec-util</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-common-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>util</artifactId>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-api</artifactId>
index 8162d365dbdfad2106fa5227d3c9487b14f3f8dc..89f9df173ed47951ca34d127d38b3e70fbf3a169 100644 (file)
@@ -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<TablesKey> 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 (file)
index a4a7aae..0000000
+++ /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<QName> 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 (file)
index 3c208aa..0000000
+++ /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<QName, Object> m = p.asMap();
-        assertFalse(m.isEmpty());
-        assertEquals(Tables.QNAME, p.getNodeType());
-        assertTrue(m.containsValue(Ipv4AddressFamily.QNAME));
-        assertTrue(m.containsValue(UnicastSubsequentAddressFamily.QNAME));
-    }
-}