Swap RpcProviderRegistry with RpcConsumerRegistry 97/73897/5
authorJaime Caamaño Ruiz <[email protected]>
Tue, 10 Jul 2018 20:37:09 +0000 (22:37 +0200)
committerBrady Johnson <[email protected]>
Tue, 17 Jul 2018 08:39:57 +0000 (08:39 +0000)
Avoids validation of the RPC model which is currently causing issues
with genius RPCs that are not properly augmented with the OFP nicira
extension models.

Change-Id: Ie2c3edee5ede3e963016da5e57a7fe0ab316adfb
JIRA: SFC-222 GENIUS-174
Signed-off-by: Jaime Caamaño Ruiz <[email protected]>
17 files changed:
sfc-classifiers/sfc-scf-openflow/src/main/java/org/opendaylight/sfc/scfofrenderer/renderers/SfcScfOfRenderer.java
sfc-classifiers/sfc-scf-openflow/src/main/resources/org/opendaylight/blueprint/sfc-scf-openflow.xml
sfc-classifiers/sfc-scf-openflow/src/test/java/org/opendaylight/sfc/scfofrenderer/flowgenerators/LogicallyAttachedClassifierTest.java
sfc-classifiers/sfc-scf-openflow/src/test/java/org/opendaylight/sfc/scfofrenderer/processors/OpenflowClassifierProcessorTest.java
sfc-genius/pom.xml
sfc-genius/src/main/java/org/opendaylight/sfc/genius/impl/SfcGeniusImpl.java
sfc-genius/src/main/java/org/opendaylight/sfc/genius/impl/handlers/SfcGeniusServiceHandler.java
sfc-genius/src/main/java/org/opendaylight/sfc/genius/impl/handlers/SfcGeniusServiceManagerImpl.java
sfc-genius/src/main/java/org/opendaylight/sfc/genius/util/SfcGeniusRpcClient.java
sfc-genius/src/main/resources/org/opendaylight/blueprint/sfc-genius.xml
sfc-genius/src/test/java/org/opendaylight/sfc/genius/impl/handlers/SfcGeniusInterfaceServiceManagerTest.java
sfc-renderers/sfc-openflow-renderer/src/main/java/org/opendaylight/sfc/renderers/openflow/SfcOfRenderer.java
sfc-renderers/sfc-openflow-renderer/src/main/java/org/opendaylight/sfc/renderers/openflow/processors/SfcOfRspProcessor.java
sfc-renderers/sfc-openflow-renderer/src/main/resources/org/opendaylight/blueprint/sfc-openflow-renderer.xml
sfc-renderers/sfc-openflow-renderer/src/test/java/org/opendaylight/sfc/renderers/openflow/SfcOfRspTransactionalProcessorTest.java
sfc-renderers/sfc-openflow-renderer/src/test/java/org/opendaylight/sfc/renderers/openflow/processors/SfcOfLogicalSffRspProcessorTest.java
sfc-renderers/sfc-openflow-renderer/src/test/java/org/opendaylight/sfc/renderers/openflow/processors/SfcOfRspProcessorTest.java

index 987d376a959837e127744b6f4c9bbf2930e0cb0c..4d70889efc9d8e2bce497463d8fe1a4e962611dc 100644 (file)
@@ -8,10 +8,13 @@
 
 package org.opendaylight.sfc.scfofrenderer.renderers;
 
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.util.SfcGeniusRpcClient;
 import org.opendaylight.sfc.scfofrenderer.flowgenerators.BareClassifier;
 import org.opendaylight.sfc.scfofrenderer.flowgenerators.LogicallyAttachedClassifier;
@@ -28,15 +31,16 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 // General entry point for the sfc-scf-openflow feature/plugin
-
+@Singleton
 public class SfcScfOfRenderer implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(SfcScfOfRenderer.class);
     private final ClassifierRspsUpdateListener classifierRspsUpdateListener;
     private final SfcScfOfDataListener sfcScfDataListener;
 
+    @Inject
     public SfcScfOfRenderer(DataBroker dataBroker, NotificationProviderService notificationService,
-            RpcProviderRegistry theRpcProvider) {
+                            RpcConsumerRegistry rpcRegistry) {
         LOG.info("SfcScfOfRenderer starting the SfcScfOfRenderer plugin...");
 
         // this transaction object will be afterwards injected into the
@@ -46,7 +50,7 @@ public class SfcScfOfRenderer implements AutoCloseable {
         SfcOfFlowWriterInterface openflowWriter = new SfcOfFlowWriterImpl(dataBroker);
 
         LogicalClassifierDataGetter dataGetter = new LogicalClassifierDataGetter(
-                new SfcGeniusRpcClient(theRpcProvider));
+                new SfcGeniusRpcClient(rpcRegistry));
 
         LogicallyAttachedClassifier logicalClassifier = new LogicallyAttachedClassifier(dataGetter);
 
@@ -77,6 +81,7 @@ public class SfcScfOfRenderer implements AutoCloseable {
      * Implemented from the AutoCloseable interface.
      */
     @Override
+    @PreDestroy
     public void close()  {
         classifierRspsUpdateListener.close();
         sfcScfDataListener.close();
index 2f2c69242aa2c92abab33aa15c1ef87c706c1cdc..c59eaeb8ee9e2b5adbceed2669f0db3d0caec465 100644 (file)
@@ -8,15 +8,7 @@
     odl:type="default" />
   <reference id="notificationService"
     interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService" />
-  <reference id="rpcProviderRegistry"
-    interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
-
-  <bean id="sfcScfOfRenderer"
-    class="org.opendaylight.sfc.scfofrenderer.renderers.SfcScfOfRenderer"
-    destroy-method="close">
-    <argument ref="dataBroker"/>
-    <argument ref="notificationService"/>
-    <argument ref="rpcProviderRegistry"/>
-  </bean>
+  <reference id="rpcRegistry"
+    interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
 
 </blueprint>
\ No newline at end of file
index b946cf215850fb8590ff290aa9ceee2b114e4e57..a808977d7f3d8f5ad686825acbe8797f9c686425 100644 (file)
@@ -23,12 +23,8 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.mockito.InjectMocks;
 import org.mockito.Mock;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.sfc.genius.util.SfcGeniusDataUtils;
-import org.opendaylight.sfc.genius.util.SfcGeniusRpcClient;
 import org.opendaylight.sfc.ovs.provider.SfcOvsUtil;
 import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
 import org.opendaylight.sfc.scfofrenderer.logicalclassifier.LogicalClassifierDataGetter;
@@ -51,27 +47,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ SfcGeniusDataUtils.class, SfcGeniusRpcClient.class, SfcRspInfo.class,
-        LogicalClassifierDataGetter.class, SfcProviderServiceFunctionAPI.class })
+@PrepareForTest({ SfcGeniusDataUtils.class, SfcRspInfo.class, LogicalClassifierDataGetter.class,
+        SfcProviderServiceFunctionAPI.class })
 public class LogicallyAttachedClassifierTest {
-    @InjectMocks
-    private SfcGeniusRpcClient geniusClient;
-
-    @Mock
-    private DataBroker dataBroker;
-
-    @Mock
-    private OdlInterfaceRpcService interfaceManagerRpcService;
-
-    @Mock
-    private ItmRpcService itmRpcService;
 
     @Mock
     private ServiceFunctionForwarder sff;
@@ -79,9 +62,6 @@ public class LogicallyAttachedClassifierTest {
     @Mock
     private ServiceFunction sf;
 
-    @Mock
-    ReadWriteTransaction readWriteTransaction;
-
     @Mock
     Match aclMatch;
 
index e691abd04ba71785915b5930dcec8dfdf16b1d7a..f471df98b802e8f290d4b6052ef3a4a24e3eb3d8 100644 (file)
@@ -26,13 +26,9 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.sfc.genius.util.SfcGeniusDataUtils;
-import org.opendaylight.sfc.genius.util.SfcGeniusRpcClient;
 import org.opendaylight.sfc.ovs.provider.SfcOvsUtil;
 import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
 import org.opendaylight.sfc.provider.api.SfcProviderServiceForwarderAPI;
-import org.opendaylight.sfc.provider.api.SfcProviderServiceFunctionAPI;
 import org.opendaylight.sfc.scfofrenderer.ClassifierAclDataBuilder;
 import org.opendaylight.sfc.scfofrenderer.flowgenerators.BareClassifier;
 import org.opendaylight.sfc.scfofrenderer.flowgenerators.LogicallyAttachedClassifier;
@@ -43,14 +39,12 @@ import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev1
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
-import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.attachment.point.attachment.point.type.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.ServiceFunctionClassifier;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.scf.rev140701.service.function.classifiers.service.function.classifier.SclServiceFunctionForwarder;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType;
-import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.RspLogicalSffAugmentation;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.Acl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.AccessListEntries;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.Ace;
@@ -64,8 +58,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ SfcGeniusDataUtils.class, SfcGeniusRpcClient.class, SfcRspInfo.class,
-        SfcProviderServiceFunctionAPI.class, SfcProviderServiceForwarderAPI.class, SfcProviderRenderedPathAPI.class,
+@PrepareForTest({ SfcRspInfo.class, SfcProviderServiceForwarderAPI.class, SfcProviderRenderedPathAPI.class,
         LogicalClassifierDataGetter.class, SfcOvsUtil.class })
 public class OpenflowClassifierProcessorTest {
     @Mock
@@ -89,21 +82,9 @@ public class OpenflowClassifierProcessorTest {
     @Mock
     LogicalClassifierDataGetter dataGetter;
 
-    @Mock
-    RpcProviderRegistry rpcProvider;
-
     @Mock
     RenderedServicePath rsp;
 
-    @Mock
-    List<RenderedServicePathHop> theHops;
-
-    @Mock
-    RenderedServicePathHop hop;
-
-    @Mock
-    RspLogicalSffAugmentation logicalSffAugmentation;
-
     private LogicallyAttachedClassifier classifierInterface;
 
     private final String interfaceToClassify;
index c82673891937a65e9d8c21e342e05a1a6035fa69..75955bbbdd61da7835d3390e8cb3ee535728454d 100644 (file)
   <name>ODL :: sfc :: ${project.artifactId}</name>
 
   <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>mdsal-binding-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.sfc</groupId>
       <artifactId>sfc-model</artifactId>
index 5bf71758b6ded1ed16715e424e314e10178719f8..def6bd05b17aeeceb878405a14a1f0964e72f1a5 100644 (file)
@@ -11,8 +11,12 @@ package org.opendaylight.sfc.genius.impl;
 import com.google.common.base.Preconditions;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.impl.handlers.SfcGeniusServiceManagerImpl;
 import org.opendaylight.sfc.genius.impl.listeners.SfcGeniusInterfaceStateListener;
 import org.opendaylight.sfc.genius.impl.listeners.SfcGeniusSfListener;
@@ -21,18 +25,21 @@ import org.opendaylight.sfc.genius.impl.listeners.SfcGeniusSffDpnStateListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@Singleton
 public class SfcGeniusImpl {
 
     private static final Logger LOG = LoggerFactory.getLogger(SfcGeniusImpl.class);
     private final DataBroker dataBroker;
-    private final RpcProviderRegistry rpcProviderRegistry;
+    private final RpcConsumerRegistry rpcRegistry;
     private AutoCloseable onDestroy;
 
-    public SfcGeniusImpl(DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry) {
+    @Inject
+    public SfcGeniusImpl(DataBroker dataBroker, RpcConsumerRegistry rpcRegistry) {
         this.dataBroker = Preconditions.checkNotNull(dataBroker);
-        this.rpcProviderRegistry = Preconditions.checkNotNull(rpcProviderRegistry);
+        this.rpcRegistry = Preconditions.checkNotNull(rpcRegistry);
     }
 
+    @PostConstruct
     public void init() {
         LOG.info("Initializing SFC Genius module {}", this);
 
@@ -45,7 +52,7 @@ public class SfcGeniusImpl {
 
         // Main handler of data store events
         SfcGeniusServiceManager interfaceManager;
-        interfaceManager = new SfcGeniusServiceManagerImpl(dataBroker, rpcProviderRegistry, handlerExecutor);
+        interfaceManager = new SfcGeniusServiceManagerImpl(dataBroker, rpcRegistry, handlerExecutor);
 
         // Listeners to data store events
         SfcGeniusSfStateListener sfStateListener;
@@ -74,6 +81,7 @@ public class SfcGeniusImpl {
         LOG.info("SFC Genius module {} initialized", this);
     }
 
+    @PreDestroy
     public void destroy() throws Exception {
         LOG.info("Closing SFC Genius module {}", this);
         onDestroy.close();
index 619259436849c389302d930e9ea52f6476093284..d45020407a2cbed7f9be43eefdabc77da3452a46 100644 (file)
@@ -12,7 +12,7 @@ import java.math.BigInteger;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Executor;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.impl.handlers.writers.SfcGeniusBoundServiceWriter;
 import org.opendaylight.sfc.genius.impl.handlers.writers.SfcGeniusTsaWriter;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.ItmRpcService;
@@ -41,15 +41,15 @@ class SfcGeniusServiceHandler {
      * @param transaction
      *            the transaction used for read & write operations to the data
      *            store.
-     * @param rpcProviderRegistry
+     * @param rpcRegistry
      *            the provider registry to obtain the {@link ItmRpcService}.
      * @param executor
      *            the executor used for callbacks & blocking calls.
      */
-    SfcGeniusServiceHandler(ReadWriteTransaction transaction, RpcProviderRegistry rpcProviderRegistry,
+    SfcGeniusServiceHandler(ReadWriteTransaction transaction, RpcConsumerRegistry rpcRegistry,
             Executor executor) {
         this.transaction = transaction;
-        this.itmRpcService = rpcProviderRegistry.getRpcService(ItmRpcService.class);
+        this.itmRpcService = rpcRegistry.getRpcService(ItmRpcService.class);
         this.executor = executor;
     }
 
index 0ed9bdc488c2a76ecf775e468f5b6620895add3f..f8ab2a5854d5e9f9ae47c01b7e06d550a1d16e35 100644 (file)
@@ -15,7 +15,7 @@ import java.util.concurrent.CompletionException;
 import java.util.concurrent.Executor;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.impl.handlers.readers.SfcGeniusSfReader;
 import org.opendaylight.sfc.genius.impl.utils.SfcGeniusRuntimeException;
 import org.opendaylight.sfc.genius.impl.utils.SfcGeniusUtils;
@@ -45,28 +45,28 @@ import org.slf4j.LoggerFactory;
 public class SfcGeniusServiceManagerImpl implements org.opendaylight.sfc.genius.impl.SfcGeniusServiceManager {
 
     private final DataBroker dataBroker;
-    private final RpcProviderRegistry rpcProviderRegistry;
+    private final RpcConsumerRegistry rpcRegistry;
     private final Executor executor;
     private static final Logger LOG = LoggerFactory.getLogger(SfcGeniusServiceManagerImpl.class);
 
     /**
      * Constructs a {@code SfcGeniusInterfaceServiceManager} using the provided
      * {@link DataBroker} for data store operations, the
-     * {@link RpcProviderRegistry} to access RPC services and the
+     * {@link RpcConsumerRegistry} to access RPC services and the
      * {@link Executor} for asynchronous tasks.
      *
      *
      * @param dataBroker
      *            the data broker for data store operations.
-     * @param rpcProviderRegistry
-     *            the RPC provider registry of services.
+     * @param rpcRegistry
+     *            the RPC service registry.
      * @param executor
      *            the executor where asynchronous tasks are executed.
      */
-    public SfcGeniusServiceManagerImpl(DataBroker dataBroker, RpcProviderRegistry rpcProviderRegistry,
+    public SfcGeniusServiceManagerImpl(DataBroker dataBroker, RpcConsumerRegistry rpcRegistry,
             Executor executor) {
         this.dataBroker = dataBroker;
-        this.rpcProviderRegistry = rpcProviderRegistry;
+        this.rpcRegistry = rpcRegistry;
         this.executor = executor;
     }
 
@@ -180,6 +180,6 @@ public class SfcGeniusServiceManagerImpl implements org.opendaylight.sfc.genius.
     }
 
     protected SfcGeniusServiceHandler getSfcGeniusServiceHandler(ReadWriteTransaction readWriteTransaction) {
-        return new SfcGeniusServiceHandler(readWriteTransaction, rpcProviderRegistry, executor);
+        return new SfcGeniusServiceHandler(readWriteTransaction, rpcRegistry, executor);
     }
 }
index 51526117399682d45ff38e1a3dd7ad83537f0807..5df75e8fbf17ccf52468edc294f4ad1d874fecbd 100644 (file)
@@ -7,11 +7,12 @@
  */
 package org.opendaylight.sfc.genius.util;
 
+import com.google.common.base.Preconditions;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 import java.util.concurrent.ExecutionException;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.impl.utils.SfcGeniusRuntimeException;
 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.sff.logical.rev160620.DpnIdType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
@@ -44,8 +45,9 @@ import org.slf4j.LoggerFactory;
 public class SfcGeniusRpcClient {
 
     private static final Logger LOG = LoggerFactory.getLogger(SfcGeniusRpcClient.class);
-    private ItmRpcService itmRpcService;
-    private OdlInterfaceRpcService interfaceManagerRpcService;
+    private final ItmRpcService itmRpcService;
+    private final OdlInterfaceRpcService ifmRpcService;
+
     /*
      * Tunnel key used in the transport zone created to support the logical SFF
      */
@@ -54,15 +56,14 @@ public class SfcGeniusRpcClient {
     /**
      * Constructor.
      *
-     * @param rpcProviderRegistry
+     * @param rpcRegistry
      *            The registry used to retrieve RPC services
      */
-    public SfcGeniusRpcClient(RpcProviderRegistry rpcProviderRegistry) {
+    public SfcGeniusRpcClient(RpcConsumerRegistry rpcRegistry) {
         LOG.debug("SfcGeniusRpcClient: starting");
-        if (rpcProviderRegistry != null) {
-            itmRpcService = rpcProviderRegistry.getRpcService(ItmRpcService.class);
-            interfaceManagerRpcService = rpcProviderRegistry.getRpcService(OdlInterfaceRpcService.class);
-        }
+        Preconditions.checkNotNull(rpcRegistry);
+        itmRpcService = rpcRegistry.getRpcService(ItmRpcService.class);
+        ifmRpcService = rpcRegistry.getRpcService(OdlInterfaceRpcService.class);
     }
 
     /**
@@ -96,7 +97,7 @@ public class SfcGeniusRpcClient {
 
         GetEgressActionsForInterfaceInput input = builder.build();
         try {
-            OdlInterfaceRpcService service = getInterfaceManagerRpcService();
+            OdlInterfaceRpcService service = getIfmRpcService();
             if (service != null) {
                 RpcResult<GetEgressActionsForInterfaceOutput> output = service.getEgressActionsForInterface(input)
                         .get();
@@ -198,7 +199,7 @@ public class SfcGeniusRpcClient {
         GetDpidFromInterfaceInput input = builder.build();
 
         try {
-            OdlInterfaceRpcService service = getInterfaceManagerRpcService();
+            OdlInterfaceRpcService service = getIfmRpcService();
             if (service != null) {
                 LOG.debug("getDpnIdFromInterfaceNameFromGeniusRPC: service is not null, invoking rpc");
                 RpcResult<GetDpidFromInterfaceOutput> output = service.getDpidFromInterface(input).get();
@@ -231,7 +232,7 @@ public class SfcGeniusRpcClient {
         GetEndpointIpForDpnInputBuilder builder = new GetEndpointIpForDpnInputBuilder();
         builder.setDpid(theDpnIdType.getValue());
         GetEndpointIpForDpnInput input = builder.build();
-        OdlInterfaceRpcService service = getInterfaceManagerRpcService();
+        OdlInterfaceRpcService service = getIfmRpcService();
 
         if (service == null) {
             LOG.error("Genius RPC service not available", input);
@@ -261,7 +262,7 @@ public class SfcGeniusRpcClient {
         return itmRpcService;
     }
 
-    private OdlInterfaceRpcService getInterfaceManagerRpcService() {
-        return interfaceManagerRpcService;
+    private OdlInterfaceRpcService getIfmRpcService() {
+        return ifmRpcService;
     }
 }
index 83f71b85a91bd1e22be39c4e3f41a1a7aacff48e..ffaee3560b6161fe7876354da925e5c5cdecf1c6 100644 (file)
@@ -8,22 +8,14 @@
   -->
 
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
-           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
-           odl:use-default-for-reference-types="true">
+  xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+  odl:use-default-for-reference-types="true">
 
-    <reference id="dataBroker"
-               interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
-               odl:type="default" />
-    <reference id="rpcProviderRegistry"
-               interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"
-               odl:type="default" />
+  <reference id="dataBroker"
+    interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"
+    odl:type="default" />
 
-    <bean id="sfcGeniusImpl"
-          class="org.opendaylight.sfc.genius.impl.SfcGeniusImpl"
-          init-method="init"
-          destroy-method="destroy">
-        <argument ref="dataBroker"/>
-        <argument ref="rpcProviderRegistry"/>
-    </bean>
+  <reference id="rpcRegistry"
+    interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
 
 </blueprint>
index 883d1b3d90127c57cde1a8a725699767a54897c1..7f4262312f44ed36c174efcdc20f8c5dbab487d9 100644 (file)
@@ -31,7 +31,7 @@ import org.mockito.Mock;
 import org.mockito.runners.MockitoJUnitRunner;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.impl.handlers.readers.SfcGeniusSfReader;
 import org.opendaylight.sfc.genius.impl.utils.SfcGeniusRuntimeException;
 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
@@ -65,14 +65,14 @@ public class SfcGeniusInterfaceServiceManagerTest {
     SfcGeniusServiceHandler sfcGeniusServiceHandler;
 
     @Mock
-    RpcProviderRegistry rpcProviderRegistry;
+    RpcConsumerRegistry rpcRegistry;
 
     SfcGeniusServiceManagerImpl sfcGeniusInterfaceServiceManager;
 
     @Before
     public void setup() {
         when(dataBroker.newReadWriteTransaction()).thenReturn(readWriteTransaction);
-        when(rpcProviderRegistry.getRpcService(ItmRpcService.class)).thenReturn(itmRpcService);
+        when(rpcRegistry.getRpcService(ItmRpcService.class)).thenReturn(itmRpcService);
         doAnswer(invocationOnMock -> {
             invocationOnMock.getArgumentAt(0, Runnable.class).run();
             return null;
@@ -85,7 +85,7 @@ public class SfcGeniusInterfaceServiceManagerTest {
                 .thenReturn(CompletableFuture.completedFuture(null));
 
         sfcGeniusInterfaceServiceManager = spy(
-                new SfcGeniusServiceManagerImpl(dataBroker, rpcProviderRegistry, executor));
+                new SfcGeniusServiceManagerImpl(dataBroker, rpcRegistry, executor));
 
         doReturn(sfcGeniusRspHandler).when(sfcGeniusInterfaceServiceManager)
                 .getSfcGeniusRspHandler(readWriteTransaction);
index 8d1e4e5ac051f168e758e48c4d11f74dc7d45a83..7ca1dfaa3963620919594f40053665762920e443 100644 (file)
@@ -8,9 +8,12 @@
 
 package org.opendaylight.sfc.renderers.openflow;
 
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.renderers.openflow.listeners.SfcOfRendererDataListener;
 import org.opendaylight.sfc.renderers.openflow.listeners.SfcOfRspDataListener;
 import org.opendaylight.sfc.renderers.openflow.listeners.SfcOfSfgDataListener;
@@ -29,6 +32,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Entry point for the sfc openflow renderer (blueprint-instantiated).
  */
+@Singleton
 public final class SfcOfRenderer implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(SfcOfRenderer.class);
 
@@ -42,8 +46,9 @@ public final class SfcOfRenderer implements AutoCloseable {
     private SfcIpv4PacketInHandler packetInHandler;
     private SfcOfRendererDataListener sfcOfRendererListener;
 
+    @Inject
     public SfcOfRenderer(DataBroker dataBroker, NotificationProviderService notificationService,
-                          RpcProviderRegistry rpcProviderRegistry) {
+                         RpcConsumerRegistry rpcRegistry) {
         LOG.info("SfcOfRenderer starting the SfcOfRenderer plugin...");
 
         this.sfcSynchronizer = new SfcSynchronizer();
@@ -52,7 +57,7 @@ public final class SfcOfRenderer implements AutoCloseable {
         this.sfcOfFlowProgrammer = new SfcOfFlowProgrammerImpl(sfcofflowwriterimpl);
         SfcOfBaseProviderUtils sfcOfProviderUtils = new SfcOfProviderUtils();
         this.sfcOfRspProcessor = new SfcOfRspProcessor(sfcOfFlowProgrammer, sfcOfProviderUtils, sfcSynchronizer,
-                rpcProviderRegistry, dataBroker);
+                rpcRegistry, dataBroker);
 
         this.openflowRspDataListener = new SfcOfRspDataListener(dataBroker, sfcOfRspProcessor);
         this.sfcOfSfgDataListener = new SfcOfSfgDataListener(dataBroker, sfcOfFlowProgrammer, sfcOfProviderUtils);
@@ -68,6 +73,7 @@ public final class SfcOfRenderer implements AutoCloseable {
      * Implemented from the AutoCloseable interface.
      */
     @Override
+    @PreDestroy
     public void close() throws Exception {
         LOG.info("SfcOfRenderer auto-closed");
         try {
index 054c49fb31ac17612fa03e0525f95d2b24767b92..bed8f2d2324e2fe8c8469512f315aff1006b7000 100644 (file)
@@ -16,8 +16,8 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.util.SfcGeniusDataUtils;
 import org.opendaylight.sfc.genius.util.SfcGeniusRpcClient;
 import org.opendaylight.sfc.ovs.provider.SfcOvsUtil;
@@ -70,13 +70,13 @@ public class SfcOfRspProcessor {
             + TRANSPORT_ENCAP_SEPARATOR_STRING + Nsh.class.getName();
 
     public SfcOfRspProcessor(SfcOfFlowProgrammerInterface sfcOfFlowProgrammer,
-            SfcOfBaseProviderUtils sfcOfProviderUtils, SfcSynchronizer sfcSynchronizer,
-            RpcProviderRegistry rpcProviderRegistry, DataBroker dataBroker) {
+                             SfcOfBaseProviderUtils sfcOfProviderUtils, SfcSynchronizer sfcSynchronizer,
+                             RpcConsumerRegistry rpcRegistry, DataBroker dataBroker) {
         this.sfcOfFlowProgrammer = sfcOfFlowProgrammer;
         this.sfcOfProviderUtils = sfcOfProviderUtils;
         this.sfcSynchronizer = sfcSynchronizer;
         this.sffInitialized = new HashMap<>();
-        this.theGeniusRpcClient = new SfcGeniusRpcClient(rpcProviderRegistry);
+        this.theGeniusRpcClient = new SfcGeniusRpcClient(rpcRegistry);
         this.operDsHandler = new OperDsUpdateHandlerLSFFImpl(dataBroker);
         this.rspTransportProcessors = new HashMap<>();
 
index a1554538077d99f3b77e8d90286f14832a3b3a76..107a22855b474e880a6ec2c4e9d8035f616378b5 100644 (file)
@@ -8,15 +8,7 @@
     odl:type="default" />
   <reference id="notificationService"
     interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
-  <reference id="rpcProviderRegistry"
-    interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
-
-  <bean id="renderer"
-    class="org.opendaylight.sfc.renderers.openflow.SfcOfRenderer"
-    destroy-method="close">
-    <argument ref="dataBroker"/>
-    <argument ref="notificationService"/>
-    <argument ref="rpcProviderRegistry"/>
-  </bean>
+  <reference id="rpcRegistry"
+    interface="org.opendaylight.mdsal.binding.api.RpcConsumerRegistry"/>
 
 </blueprint>
index 02d16a8174ececfbb5a8c88d05e32b923a2e4fc8..180e00b57f525e9c6f4fe207b22bf1cd7a038c6c 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.sfc.renderers.openflow;
 
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.core.Is.is;
+import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyObject;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -33,6 +34,7 @@ import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.renderers.openflow.openflow.SfcOfFlowProgrammerImpl;
 import org.opendaylight.sfc.renderers.openflow.openflow.SfcOfFlowProgrammerInterface;
 import org.opendaylight.sfc.renderers.openflow.processors.SfcOfRspProcessor;
@@ -100,10 +102,13 @@ public class SfcOfRspTransactionalProcessorTest {
         dataBroker = Mockito.mock(DataBroker.class);
         Mockito.when(dataBroker.newWriteOnlyTransaction()).thenReturn(Mockito.mock(WriteTransaction.class));
 
+        RpcConsumerRegistry rpcRegistry = Mockito.mock(RpcConsumerRegistry.class);
+        Mockito.when(rpcRegistry.getRpcService(any())).thenReturn(null);
+
         this.sfcUtilsTestMock = new SfcOfProviderUtilsTestMock();
         // spied in order to check private methods
         this.sfcOfRspProcessor = PowerMockito.spy(new SfcOfRspProcessor(this.flowProgrammerTestMock,
-                this.sfcUtilsTestMock, new SfcSynchronizer(), null, dataBroker));
+                this.sfcUtilsTestMock, new SfcSynchronizer(), rpcRegistry, dataBroker));
 
         this.rspBuilder = new RspBuilder(this.sfcUtilsTestMock);
         this.sfTypes = new ArrayList<>();
index b2e76df9ac7cb06437c9a7ff553d7386eac312b2..1e97339b4d7a38b5d824653c8c0005eb7707ca0f 100644 (file)
@@ -41,8 +41,8 @@ import org.mockito.Mockito;
 import org.mockito.Spy;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.genius.util.SfcGeniusDataUtils;
 import org.opendaylight.sfc.genius.util.SfcGeniusRpcClient;
 import org.opendaylight.sfc.ovs.provider.SfcOvsUtil;
@@ -124,11 +124,12 @@ import org.powermock.reflect.Whitebox;
  * @author Miguel Duarte ([email protected])
  */
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({ SfcGeniusRpcClient.class, SfcGeniusDataUtils.class, OperDsUpdateHandlerLSFFImpl.class,
-        SfcOfRspProcessor.class, SfcRspProcessorLogicalSff.class, SfcOvsUtil.class})
+@PrepareForTest({ SfcGeniusDataUtils.class, OperDsUpdateHandlerLSFFImpl.class, SfcOfRspProcessor.class,
+        SfcOvsUtil.class})
 public class SfcOfLogicalSffRspProcessorTest {
 
-    private final SfcGeniusRpcClient geniusClient;
+    @Mock
+    private SfcGeniusRpcClient geniusClient;
 
     @Mock
     private OdlInterfaceRpcService interfaceManagerRpcService;
@@ -148,7 +149,7 @@ public class SfcOfLogicalSffRspProcessorTest {
     private final OperDsUpdateHandlerLSFFImpl operDsUpdateHandler;
 
     @Mock
-    private RpcProviderRegistry rpcProviderRegistry;
+    private RpcConsumerRegistry rpcRegistry;
 
     private final SfcOfRspProcessor sfcOfRspProcessor;
     private final SfcOfProviderUtilsTestMock sfcUtils;
@@ -179,13 +180,17 @@ public class SfcOfLogicalSffRspProcessorTest {
         operDsUpdateHandler = PowerMockito.spy(new OperDsUpdateHandlerLSFFImpl(dataBroker));
         flowProgrammer.setFlowWriter(ofFlowWriter);
         sfcUtils = new SfcOfProviderUtilsTestMock();
-        geniusClient = PowerMockito.spy(new SfcGeniusRpcClient(rpcProviderRegistry));
+
+        when(rpcRegistry.getRpcService(ItmRpcService.class)).thenReturn(itmRpcService);
+        when(rpcRegistry.getRpcService(OdlInterfaceRpcService.class)).thenReturn(interfaceManagerRpcService);
+        geniusClient = PowerMockito.spy(new SfcGeniusRpcClient(rpcRegistry));
+
         logicalSffProcessor = new SfcRspProcessorLogicalSff(geniusClient, operDsUpdateHandler);
         logicalSffProcessor.setSfcProviderUtils(sfcUtils);
         logicalSffProcessor.setFlowProgrammer(flowProgrammer);
 
         sfcOfRspProcessor = PowerMockito.spy(new SfcOfRspProcessor(flowProgrammer, sfcUtils, new SfcSynchronizer(),
-                rpcProviderRegistry, dataBroker));
+                rpcRegistry, dataBroker));
         PowerMockito.when(sfcOfRspProcessor, "getOperDsHandler").thenReturn(operDsUpdateHandler);
 
         rspBuilder = new RspBuilder(sfcUtils);
@@ -218,8 +223,6 @@ public class SfcOfLogicalSffRspProcessorTest {
         PowerMockito.when(sfcOfRspProcessor, "getGeniusRpcClient").thenReturn(geniusClient);
         PowerMockito.doReturn(logicalSffProcessor).when(sfcOfRspProcessor, "getReusableTransportProcessor", any(),
                 any());
-        PowerMockito.when(geniusClient, "getInterfaceManagerRpcService").thenReturn(interfaceManagerRpcService);
-        PowerMockito.when(geniusClient, "getItmRpcService").thenReturn(itmRpcService);
 
         String ifName0 = rspBuilder.getLogicalInterfaceName(0);
         String ifName1 = rspBuilder.getLogicalInterfaceName(1);
index 105fd64ee08d03daa48ca6e646354898067dc27e..b0e17e7ec058d4ba31dd96c69c36e739c0deb558 100644 (file)
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
 import org.opendaylight.sfc.renderers.openflow.RspBuilder;
 import org.opendaylight.sfc.renderers.openflow.openflow.SfcOfFlowProgrammerImpl;
 import org.opendaylight.sfc.renderers.openflow.openflow.SfcOfFlowProgrammerInterface;
@@ -78,8 +79,9 @@ public class SfcOfRspProcessorTest {
         this.flowProgrammerTestMoc = mock(SfcOfFlowProgrammerImpl.class);
         this.flowProgrammerTestMoc.setFlowWriter(mock(SfcOfFlowWriterInterface.class));
         this.sfcUtilsTestMock = new SfcOfProviderUtilsTestMock();
+        RpcConsumerRegistry rpcRegistry = mock(RpcConsumerRegistry.class);
         this.sfcOfRspProcessor = new SfcOfRspProcessor(this.flowProgrammerTestMoc, this.sfcUtilsTestMock,
-                                                       new SfcSynchronizer(), null, null);
+                                                       new SfcSynchronizer(), rpcRegistry, null);
         this.rspBuilder = new RspBuilder(this.sfcUtilsTestMock);
 
         this.sfTypes = new ArrayList<>();