Remove RIBImpl's use of DataBroker 90/94490/10
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 7 Jan 2021 19:35:22 +0000 (20:35 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 21 Feb 2021 17:47:21 +0000 (18:47 +0100)
We do not need the binding DataBroker anywhere in the core logic,
do not propagate it there.

JIRA: BGPCEP-853
Change-Id: I283857e7dce16b66aa6d83ab25c87adbb6b75e88
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
14 files changed:
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImpl.java
bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIB.java
bgp/rib-impl/src/main/resources/OSGI-INF/blueprint/bgp-rib.xml
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractRIBTestSetup.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathBasePathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/GracefulRestartTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/SynchronizationAndExceptionTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/AbstractConfig.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpDeployerImplTest.java
bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/config/RibImplTest.java

index 1f79af94cfa1205a92b31a2cf7fe29ef5618ee6e..ea97fbe551bb9001799a2008560ce120576aea67 100644 (file)
@@ -27,10 +27,6 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import org.checkerframework.checker.lock.qual.GuardedBy;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.Transaction;
-import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
@@ -81,8 +77,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 // This class is thread-safe
-public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionChainListener,
-        DOMTransactionChainListener, AutoCloseable {
+public final class RIBImpl extends BGPRibStateImpl implements RIB, DOMTransactionChainListener, AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(RIBImpl.class);
     private static final QName RIB_ID_QNAME = QName.create(Rib.QNAME, "id").intern();
 
@@ -92,7 +87,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
     private final Set<BgpTableType> localTables;
     private final Set<TablesKey> localTablesKeys;
     private final DOMDataBroker domDataBroker;
-    private final DataBroker dataBroker;
     private final RIBExtensionConsumerContext extensions;
     private final YangInstanceIdentifier yangRibId;
     private final RIBSupportContextRegistryImpl ribContextRegistry;
@@ -121,7 +115,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
             final BGPDispatcher dispatcher,
             final CodecsRegistry codecsRegistry,
             final DOMDataBroker domDataBroker,
-            final DataBroker dataBroker,
             final BGPRibRoutingPolicy ribPolicies,
             final List<BgpTableType> localTables,
             final Map<TablesKey, PathSelectionMode> bestPathSelectionStrategies
@@ -135,7 +128,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
         this.localTables = ImmutableSet.copyOf(localTables);
         this.localTablesKeys = new HashSet<>();
         this.domDataBroker = requireNonNull(domDataBroker);
-        this.dataBroker = requireNonNull(dataBroker);
         this.domService = this.domDataBroker.getExtensions().get(DOMDataTreeChangeService.class);
         this.extensions = requireNonNull(extensions);
         this.ribPolicies = requireNonNull(ribPolicies);
@@ -236,13 +228,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
         return this.dispatcher;
     }
 
-    @Override
-    public synchronized void onTransactionChainFailed(final TransactionChain chain,
-            final Transaction transaction, final Throwable cause) {
-        LOG.error("Broken chain in RIB {} transaction {}",
-                getInstanceIdentifier(), transaction != null ? transaction.getIdentifier() : null, cause);
-    }
-
     @Override
     public synchronized void onTransactionChainFailed(final DOMTransactionChain chain,
             final DOMDataTreeTransaction transaction, final Throwable cause) {
@@ -257,11 +242,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
         }
     }
 
-    @Override
-    public void onTransactionChainSuccessful(final TransactionChain chain) {
-        LOG.info("RIB {} closed successfully", getInstanceIdentifier());
-    }
-
     @Override
     public void onTransactionChainSuccessful(final DOMTransactionChain chain) {
         LOG.info("RIB {} closed successfully", getInstanceIdentifier());
@@ -300,11 +280,6 @@ public final class RIBImpl extends BGPRibStateImpl implements RIB, TransactionCh
         return (DOMDataTreeChangeService) this.domService;
     }
 
-    @Override
-    public DataBroker getDataBroker() {
-        return this.dataBroker;
-    }
-
     @Override
     public YangInstanceIdentifier getYangRibId() {
         return this.yangRibId;
index 2f3a261f0fde7864a3a0bbeea0f19eac69a563d6..279db3ab4460227e28e3c8e4cd9385eb7ed58282 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
@@ -73,21 +72,18 @@ public final class RibImpl implements RIB, BGPRibStateConsumer, AutoCloseable {
     private Ipv4AddressNoZone routerId;
 
     private ClusterIdentifier clusterId;
-    private final DataBroker dataBroker;
 
     public RibImpl(
             final RIBExtensionConsumerContext contextProvider,
             final BGPDispatcher dispatcher,
             final BGPRibRoutingPolicyFactory policyProvider,
             final CodecsRegistry codecsRegistry,
-            final DOMDataBroker domBroker,
-            final DataBroker dataBroker
+            final DOMDataBroker domBroker
     ) {
         this.extensions = contextProvider;
         this.dispatcher = dispatcher;
         this.codecsRegistry = codecsRegistry;
         this.domBroker = domBroker;
-        this.dataBroker = dataBroker;
         this.policyProvider = policyProvider;
     }
 
@@ -164,11 +160,6 @@ public final class RibImpl implements RIB, BGPRibStateConsumer, AutoCloseable {
         return this.ribImpl.getService();
     }
 
-    @Override
-    public DataBroker getDataBroker() {
-        return this.ribImpl.getDataBroker();
-    }
-
     FluentFuture<? extends CommitInfo> closeServiceInstance() {
         if (this.ribImpl != null) {
             return this.ribImpl.closeServiceInstance();
@@ -248,7 +239,6 @@ public final class RibImpl implements RIB, BGPRibStateConsumer, AutoCloseable {
                 this.dispatcher,
                 codecsRegistry,
                 this.domBroker,
-                this.dataBroker,
                 ribPolicy,
                 toTableTypes(this.afiSafi, tableTypeRegistry),
                 pathSelectionModes);
index 252bd5ccea3b755120840dabb2225c358900bcb5..8ee03ddf31ab59faa6bf9297b97202ec89b300ef 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.protocol.bgp.rib.impl.spi;
 
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChain;
 import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
@@ -87,13 +86,6 @@ public interface RIB extends RibReference, RibOutRefresh {
      */
     DOMDataTreeChangeService getService();
 
-    /**
-     * Return DataBroker.
-     *
-     * @return DataBroker
-     */
-    DataBroker getDataBroker();
-
     /**
      * Returns true if RIB supports table.
      *
index 629d5bef73b9a4dc5bf2d178291339cdb71aed70..7d400e1606ee2cf9cad8622ad4603cfdc54f137f 100644 (file)
@@ -56,7 +56,6 @@
     <argument ref="policiesProvider"/>
     <argument ref="codecRegistry"/>
     <argument ref="domDataBroker"/>
-    <argument ref="dataBroker"/>
   </bean>
 
   <bean id="bgpPeer" class="org.opendaylight.protocol.bgp.rib.impl.config.BgpPeer" scope="prototype">
index ba9f0d48ff227ef0f3329e6553da61cc3aed34f6..16b12290970d0a63362289925c3c06ea2b9df24d 100644 (file)
@@ -138,7 +138,7 @@ public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
         doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
                 .registerClusterSingletonService(any(ClusterSingletonService.class));
         this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(Uint32.valueOf(5)), RIB_ID, context,
-                this.dispatcher, new ConstantCodecsRegistry(serializer), this.dom, getDataBroker(), this.policies,
+                this.dispatcher, new ConstantCodecsRegistry(serializer), this.dom, this.policies,
                 localTables, Collections.singletonMap(KEY,
                 BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
     }
index 200dd45a84d627bf7a861552650a6c20286fa54c..101b079b6b3b9a47d02e3b5844b0e8915866a99d 100644 (file)
@@ -57,7 +57,7 @@ public class AddPathAllPathsTest extends AbstractAddPathTest {
 
         this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, BGP_ID,
                 this.ribExtension, this.serverDispatcher, this.codecsRegistry,
-            getDomBroker(), getDataBroker(), this.policies, TABLES_TYPE, pathTables);
+            getDomBroker(), this.policies, TABLES_TYPE, pathTables);
 
         this.ribImpl.instantiateServiceInstance();
         final ChannelFuture channelFuture = this.serverDispatcher.createServer(
index d80259d8c4fdea728a471f48d9ce3b79b9334a8e..f766cda1f133c7517b5a1701f383995448b48c9d 100644 (file)
@@ -43,7 +43,7 @@ public class AddPathBasePathsTest extends AbstractAddPathTest {
 
         this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
                 this.ribExtension,
-                this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                this.serverDispatcher, this.codecsRegistry, getDomBroker(), this.policies,
                 TABLES_TYPE, pathTables);
         this.ribImpl.instantiateServiceInstance();
         final ChannelFuture channelFuture = this.serverDispatcher.createServer(
index 72ee0d0900aafd9d2339f0bd75c2eb34666471e4..72a62d080403ef7b370104db5bae1b82754c027e 100644 (file)
@@ -42,7 +42,7 @@ public class AddPathNPathsTest extends AbstractAddPathTest {
 
         this.ribImpl = new RIBImpl(this.tableRegistry, new RibId("test-rib"), AS_NUMBER, new BgpId(RIB_ID),
                 this.ribExtension,
-                this.serverDispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                this.serverDispatcher, this.codecsRegistry, getDomBroker(), this.policies,
                 TABLES_TYPE,  pathTables);
 
         this.ribImpl.instantiateServiceInstance();
index c22cd0fb20c1f3aeb7cbe568917556e3ec125ae1..7ba6fa3c3d4872149c498440261ff6c1c8d94fa9 100644 (file)
@@ -113,7 +113,7 @@ public class GracefulRestartTest extends AbstractAddPathTest {
         tableTypes.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
         this.ribImpl = new RIBImpl(this.tableRegistry, RIBID, AS_NUMBER, BGP_ID, this.ribExtension,
                 this.serverDispatcher, this.codecsRegistry,
-                getDomBroker(), getDataBroker(), this.policies, tableTypes, pathTables);
+                getDomBroker(), this.policies, tableTypes, pathTables);
 
         this.ribImpl.instantiateServiceInstance();
         final ChannelFuture channelFuture = this.serverDispatcher.createServer(
index 5402f1a8d577eede04c6530be4917eb655a2aa0b..2111153d795740e10e9566c370cd0f2808269dea 100644 (file)
@@ -101,7 +101,7 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
                 LinkstateSubsequentAddressFamily.class));
 
         final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2,
-                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies,
                 tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
                 .createBestPathSelectionStrategy()));
         rib.instantiateServiceInstance();
@@ -118,7 +118,7 @@ public class ParserToSalTest extends DefaultRibPoliciesMockTest {
         final List<BgpTableType> tables = ImmutableList.of(new BgpTableTypeImpl(Ipv4AddressFamily.class,
                 UnicastSubsequentAddressFamily.class));
         final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext1,
-                this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
+                this.dispatcher, this.codecsRegistry, getDomBroker(), this.policies,
                 tables, Collections.singletonMap(TABLE_KEY,
                 BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
         rib.instantiateServiceInstance();
index a9b0f2835b781083e92add3ca5c3924cb9f61a8b..f334914ee825ddfd2ff8f044a4fa1fdea8aab4c3 100644 (file)
@@ -214,7 +214,7 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
             BasePathSelectionModeFactory.createBestPathSelectionStrategy());
         final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER,  new BgpId(RIB_ID),
                 this.ribExtension,
-                this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
+                this.serverDispatcher, this.codecsRegistry, this.domBroker, this.policies,
                 ImmutableList.of(this.ipv4tt), pathTables);
         ribImpl.instantiateServiceInstance();
 
@@ -262,7 +262,7 @@ public class SynchronizationAndExceptionTest extends AbstractAddPathTest {
                 BasePathSelectionModeFactory.createBestPathSelectionStrategy());
         final RIBImpl ribImpl = new RIBImpl(this.tableRegistry, new RibId(RIB_ID), AS_NUMBER, new BgpId(RIB_ID),
                 this.ribExtension,
-                this.serverDispatcher, this.codecsRegistry, this.domBroker, getDataBroker(), this.policies,
+                this.serverDispatcher, this.codecsRegistry, this.domBroker, this.policies,
                 ImmutableList.of(this.ipv4tt), pathTables);
         ribImpl.instantiateServiceInstance();
 
index fb97d99af12311949ff776747aa081dc2ff6509c..d97d17d7765e5d0596e0a4b0aa5b0ef0bb18e502 100644 (file)
@@ -93,7 +93,6 @@ class AbstractConfig extends DefaultRibPoliciesMockTest {
                 .getInstanceIdentifier();
         doReturn(this.domTx).when(this.rib).createPeerDOMChain(any(DOMTransactionChainListener.class));
 
-        doReturn(getDataBroker()).when(this.rib).getDataBroker();
         doReturn(AS).when(this.rib).getLocalAs();
         doReturn(mock(RIBSupportContextRegistry.class)).when(this.rib).getRibSupportContext();
         doReturn(Collections.emptySet()).when(this.rib).getLocalTablesKeys();
index f1895ae877959ad823998a2a6dbd9b707f833219..7ae7cb8012a2faf0ac8fb50cf7982d0500523be1 100644 (file)
@@ -111,7 +111,7 @@ public class BgpDeployerImplTest extends DefaultRibPoliciesMockTest {
         doNothing().when(serviceRegistration).close();
 
         final RibImpl ribImpl = new RibImpl(extension, mock(BGPDispatcher.class), this.policyProvider,
-            mock(CodecsRegistry.class), getDomBroker(), getDataBroker());
+            mock(CodecsRegistry.class), getDomBroker());
         doReturn(ribImpl).when(this.blueprintContainer).getComponentInstance(eq("ribImpl"));
 
         doReturn(new BgpPeer(mock(RpcProviderService.class))).when(this.blueprintContainer)
index a2001196fbf0181c64123b6a93edbd8ce4525265..1767d94afbf4a8d9726f475b73d1c5ada0242362 100644 (file)
@@ -103,8 +103,7 @@ public class RibImplTest extends AbstractConfig {
                 this.dispatcher,
                 this.policyProvider,
                 this.codecsRegistry,
-                this.domDataBroker,
-                getDataBroker());
+                this.domDataBroker);
         ribImpl.setServiceRegistration(this.serviceRegistration);
         ribImpl.start(createGlobal(), "rib-test", this.tableTypeRegistry);
         verify(this.domDataBroker).getExtensions();