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;
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
SfcOfFlowWriterInterface openflowWriter = new SfcOfFlowWriterImpl(dataBroker);
LogicalClassifierDataGetter dataGetter = new LogicalClassifierDataGetter(
- new SfcGeniusRpcClient(theRpcProvider));
+ new SfcGeniusRpcClient(rpcRegistry));
LogicallyAttachedClassifier logicalClassifier = new LogicallyAttachedClassifier(dataGetter);
* Implemented from the AutoCloseable interface.
*/
@Override
+ @PreDestroy
public void close() {
classifierRspsUpdateListener.close();
sfcScfDataListener.close();
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
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;
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;
@Mock
private ServiceFunction sf;
- @Mock
- ReadWriteTransaction readWriteTransaction;
-
@Mock
Match aclMatch;
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;
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;
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
@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;
<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>
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;
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);
// 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;
LOG.info("SFC Genius module {} initialized", this);
}
+ @PreDestroy
public void destroy() throws Exception {
LOG.info("Closing SFC Genius module {}", this);
onDestroy.close();
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;
* @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;
}
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;
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;
}
}
protected SfcGeniusServiceHandler getSfcGeniusServiceHandler(ReadWriteTransaction readWriteTransaction) {
- return new SfcGeniusServiceHandler(readWriteTransaction, rpcProviderRegistry, executor);
+ return new SfcGeniusServiceHandler(readWriteTransaction, rpcRegistry, executor);
}
}
*/
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;
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
*/
/**
* 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);
}
/**
GetEgressActionsForInterfaceInput input = builder.build();
try {
- OdlInterfaceRpcService service = getInterfaceManagerRpcService();
+ OdlInterfaceRpcService service = getIfmRpcService();
if (service != null) {
RpcResult<GetEgressActionsForInterfaceOutput> output = service.getEgressActionsForInterface(input)
.get();
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();
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);
return itmRpcService;
}
- private OdlInterfaceRpcService getInterfaceManagerRpcService() {
- return interfaceManagerRpcService;
+ private OdlInterfaceRpcService getIfmRpcService() {
+ return ifmRpcService;
}
}
-->
<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>
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;
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;
.thenReturn(CompletableFuture.completedFuture(null));
sfcGeniusInterfaceServiceManager = spy(
- new SfcGeniusServiceManagerImpl(dataBroker, rpcProviderRegistry, executor));
+ new SfcGeniusServiceManagerImpl(dataBroker, rpcRegistry, executor));
doReturn(sfcGeniusRspHandler).when(sfcGeniusInterfaceServiceManager)
.getSfcGeniusRspHandler(readWriteTransaction);
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;
/**
* 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);
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();
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);
* Implemented from the AutoCloseable interface.
*/
@Override
+ @PreDestroy
public void close() throws Exception {
LOG.info("SfcOfRenderer auto-closed");
try {
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;
+ 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<>();
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>
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;
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;
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<>();
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;
*/
@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;
private final OperDsUpdateHandlerLSFFImpl operDsUpdateHandler;
@Mock
- private RpcProviderRegistry rpcProviderRegistry;
+ private RpcConsumerRegistry rpcRegistry;
private final SfcOfRspProcessor sfcOfRspProcessor;
private final SfcOfProviderUtilsTestMock sfcUtils;
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);
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);
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;
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<>();