<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-eos-binding-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin-annotation</artifactId>
+ <optional>true</optional>
+ </dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
package org.opendaylight.openflowplugin.applications.deviceownershipservice.impl;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.regex.Pattern;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.annotation.service.Service;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipChange;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListener;
import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Singleton
+@Service(classes = DeviceOwnershipService.class)
public class DeviceOwnershipServiceImpl implements DeviceOwnershipService, EntityOwnershipListener {
private static final Logger LOG = LoggerFactory.getLogger(DeviceOwnershipServiceImpl.class);
private static final String SERVICE_ENTITY_TYPE = "org.opendaylight.mdsal.ServiceEntityType";
private final EntityOwnershipService eos;
private final ConcurrentMap<String, EntityOwnershipState> ownershipStateCache = new ConcurrentHashMap<>();
- public DeviceOwnershipServiceImpl(final EntityOwnershipService entityOwnershipService) {
+ public DeviceOwnershipServiceImpl(@Reference final EntityOwnershipService entityOwnershipService) {
this.eos = entityOwnershipService;
}
+ @PostConstruct
public void start() {
registerEntityOwnershipListener();
LOG.info("DeviceOwnershipService started");
}
+ @PreDestroy
public void close() {
LOG.info("DeviceOwnershipService closed");
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <reference id="entityOwnershipService" interface="org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService"/>
-
- <bean id="deviceOwnershipService" class="org.opendaylight.openflowplugin.applications.deviceownershipservice.impl.DeviceOwnershipServiceImpl"
- init-method="start"
- destroy-method="close">
- <argument ref="entityOwnershipService"/>
- </bean>
-
- <service ref="deviceOwnershipService"
- interface="org.opendaylight.openflowplugin.applications.deviceownershipservice.DeviceOwnershipService"
- odl:type="default"/>
-
-</blueprint>
<artifactId>arbitratorreconciliation-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin-annotation</artifactId>
+ <optional>true</optional>
+ </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
<scm>
<connection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</connection>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/openflowplugin.git</developerConnection>
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
import javax.annotation.Nonnull;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
* provide all RPC services.
*
*/
+@Singleton
public class ForwardingRulesManagerImpl implements ForwardingRulesManager {
private static final Logger LOG = LoggerFactory.getLogger(ForwardingRulesManagerImpl.class);
private final OpenflowServiceRecoveryHandler openflowServiceRecoveryHandler;
private final ServiceRecoveryRegistry serviceRecoveryRegistry;
- public ForwardingRulesManagerImpl(final DataBroker dataBroker, final RpcProviderRegistry rpcRegistry,
+ @Inject
+ public ForwardingRulesManagerImpl(@Reference final DataBroker dataBroker,
+ @Reference final RpcProviderRegistry rpcRegistry,
final ForwardingRulesManagerConfig config,
- final MastershipChangeServiceManager mastershipChangeServiceManager,
- final ClusterSingletonServiceProvider clusterSingletonService,
- final ConfigurationService configurationService,
- final ReconciliationManager reconciliationManager,
+ @Reference final MastershipChangeServiceManager mastershipChangeServiceManager,
+ @Reference final ClusterSingletonServiceProvider clusterSingletonService,
+ @Reference final ConfigurationService configurationService,
+ @Reference final ReconciliationManager reconciliationManager,
final OpenflowServiceRecoveryHandler openflowServiceRecoveryHandler,
- final ServiceRecoveryRegistry serviceRecoveryRegistry) {
+ @Reference final ServiceRecoveryRegistry serviceRecoveryRegistry) {
disableReconciliation = config.isDisableReconciliation();
staleMarkingEnabled = config.isStaleMarkingEnabled();
reconciliationRetryCount = config.getReconciliationRetryCount();
}
@Override
+ @PostConstruct
public void start() {
nodeConfigurator = new NodeConfiguratorImpl();
this.devicesGroupRegistry = new DevicesGroupRegistry();
}
@Override
+ @PreDestroy
public void close() throws Exception {
configurationServiceRegistration.close();
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.apache.aries.blueprint.annotation.service.Service;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Singleton
+@Service(classes = FrmReconciliationService.class)
public class FrmReconciliationServiceImpl implements FrmReconciliationService {
private static final Logger LOG = LoggerFactory.getLogger(FrmReconciliationServiceImpl.class);
private final ForwardingRulesManagerImpl forwardingRulesManagerImpl;
+ @Inject
public FrmReconciliationServiceImpl(ForwardingRulesManagerImpl forwardingRulesManagerImpl) {
this.forwardingRulesManagerImpl = forwardingRulesManagerImpl;
}
import javax.inject.Inject;
import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
+import org.apache.aries.blueprint.annotation.service.Service;
import org.opendaylight.openflowplugin.applications.frm.recovery.OpenflowServiceRecoveryHandler;
import org.opendaylight.serviceutils.srm.RecoverableListener;
import org.opendaylight.serviceutils.srm.ServiceRecoveryInterface;
import org.slf4j.LoggerFactory;
@Singleton
+@Service(classes = OpenflowServiceRecoveryHandler.class)
public class OpenflowServiceRecoveryHandlerImpl implements ServiceRecoveryInterface,
OpenflowServiceRecoveryHandler {
private final ServiceRecoveryRegistry serviceRecoveryRegistry;
@Inject
- public OpenflowServiceRecoveryHandlerImpl(final ServiceRecoveryRegistry serviceRecoveryRegistry) {
+ public OpenflowServiceRecoveryHandlerImpl(@Reference final ServiceRecoveryRegistry serviceRecoveryRegistry) {
LOG.info("Registering openflowplugin service recovery handlers");
this.serviceRecoveryRegistry = serviceRecoveryRegistry;
serviceRecoveryRegistry.registerServiceRecoveryRegistry(buildServiceRegistryKey(), this);
xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
odl:use-default-for-reference-types="true">
- <service ref="openflowServiceRecoveryHandler"
- interface="org.opendaylight.openflowplugin.applications.frm.recovery.OpenflowServiceRecoveryHandler"
- odl:type="default"/>
- <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
- <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry"/>
- <reference id="clusterSingletonService" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
- <reference id="mastershipChangeServiceManager" interface="org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager"/>
- <reference id="configurationService" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService"/>
- <reference id="reconciliationservice" interface="org.opendaylight.openflowplugin.applications.reconciliation.ReconciliationManager"/>
- <reference id="serviceRecoveryRegistry" interface="org.opendaylight.serviceutils.srm.ServiceRecoveryRegistry"/>
-
- <odl:clustered-app-config id="frmConfig"
+ <odl:clustered-app-config id="forwardingRulesManagerConfig"
binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.forwardingrules.manager.config.rev160511.ForwardingRulesManagerConfig"/>
- <bean id="openflowServiceRecoveryHandler"
- class="org.opendaylight.openflowplugin.applications.frm.recovery.impl.OpenflowServiceRecoveryHandlerImpl">
- <argument ref="serviceRecoveryRegistry"/>
- </bean>
- <bean id="frmManager" class="org.opendaylight.openflowplugin.applications.frm.impl.ForwardingRulesManagerImpl"
- init-method="start" destroy-method="close">
- <argument ref="dataBroker"/>
- <argument ref="rpcRegistry"/>
- <argument ref="frmConfig"/>
- <argument ref="mastershipChangeServiceManager"/>
- <argument ref="clusterSingletonService"/>
- <argument ref="configurationService"/>
- <argument ref="reconciliationservice"/>
- <argument ref="openflowServiceRecoveryHandler"/>
- <argument ref="serviceRecoveryRegistry"/>
- </bean>
-
- <bean id="frmReconciliationService"
- class="org.opendaylight.openflowplugin.applications.frm.impl.FrmReconciliationServiceImpl">
- <argument ref="frmManager"/>
- </bean>
- <service ref="frmReconciliationService"
- interface="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.app.frm.reconciliation.service.rev180227.FrmReconciliationService"
- odl:type="default"/>
-
</blueprint>
*/
package org.opendaylight.openflowplugin.impl.mastership;
+import static org.opendaylight.infrautils.utils.concurrent.LoggingFutures.addErrorLogging;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.annotation.Nonnull;
import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkEvent;
import org.opendaylight.openflowplugin.api.openflow.mastership.ReconciliationFrameworkRegistration;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflowplugin.rf.state.rev170713.ResultState;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@Singleton
@Service(classes = MastershipChangeServiceManager.class)
public final class MastershipChangeServiceManagerImpl implements MastershipChangeServiceManager {
+ private static final Logger LOG = LoggerFactory.getLogger(MastershipChangeServiceManagerImpl.class);
+
private final List<MastershipChangeService> serviceGroup = new CopyOnWriteArrayList<>();
private ReconciliationFrameworkEvent rfService = null;
private MasterChecker masterChecker;
}
@Override
- // FB flags this for onDeviceDisconnected but unclear why - seems a false positive.
- @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT")
public void becomeSlaveOrDisconnect(@Nonnull final DeviceInfo deviceInfo) {
if (rfService != null) {
- rfService.onDeviceDisconnected(deviceInfo);
+ ListenableFuture<Void> future = rfService.onDeviceDisconnected(deviceInfo);
+ // TODO This null future check here should ideally not be required, but some tests currently rely on it
+ if (future != null) {
+ addErrorLogging(future, LOG, "onDeviceDisconnected() failed");
+ }
}
serviceGroup.forEach(mastershipChangeService -> mastershipChangeService.onLoseOwnership(deviceInfo));
}
private ContextChainHolderImpl contextChainHolder;
private ReconciliationFrameworkRegistration registration;
- private MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
+ private final MastershipChangeServiceManager manager = new MastershipChangeServiceManagerImpl();
@Before
public void setUp() throws Exception {
-
Mockito.when(connectionContext.getDeviceInfo()).thenReturn(deviceInfo);
Mockito.when(deviceManager.createContext(connectionContext)).thenReturn(deviceContext);
Mockito.when(rpcManager.createContext(deviceContext)).thenReturn(rpcContext);
@Test
public void reconciliationFrameworkSuccessButNotSubmit() throws Exception {
contextChainHolder.createContextChain(connectionContext);
+ // TODO when if (future != null) check in MastershipChangeServiceManagerImpl's becomeSlaveOrDisconnect() is rm
+ // Mockito.when(reconciliationFrameworkEvent.onDevicePrepared(deviceInfo))
+ // .thenReturn(Futures.immediateFuture(null));
contextChainHolder.createContextChain(connectionContext);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.INITIAL_FLOW_REGISTRY_FILL);
contextChainHolder.onMasterRoleAcquired(deviceInfo, ContextChainMastershipState.RPC_REGISTRATION);
*/
package org.opendaylight.openflowplugin.impl.mastership;
+import com.google.common.util.concurrent.Futures;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
public void setUp() throws Exception {
registration = manager.register(service);
registrationRF = manager.reconciliationFrameworkRegistration(event);
+
+ Mockito.when(event.onDeviceDisconnected(Mockito.any())).thenReturn(Futures.immediateFuture(null));
}
@Test
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin-annotation</artifactId>
+ <optional>true</optional>
+ </dependency>
</dependencies>
<build>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
package org.opendaylight.openflowplugin.test;
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.inject.Singleton;
+import org.apache.aries.blueprint.annotation.service.Reference;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Singleton
public class OpenflowpluginTestActivator implements AutoCloseable {
private static final Logger LOG = LoggerFactory
.getLogger(OpenflowpluginTestActivator.class);
public static final String NODE_ID = "foo:node:1";
- public OpenflowpluginTestActivator(DataBroker dataBroker, NotificationProviderService notificationService,
- BundleContext ctx) {
+ public OpenflowpluginTestActivator(@Reference DataBroker dataBroker,
+ @Reference NotificationProviderService notificationService, BundleContext ctx) {
provider = new OpenflowpluginTestServiceProvider(dataBroker, notificationService);
OpenflowpluginTestCommandProvider openflowpluginTestCommandProvider = new OpenflowpluginTestCommandProvider(
dataBroker, notificationService, ctx);
this.groupCmdProvider = openflowPluginBulkGroupTransactionProvider;
}
+ @PostConstruct
public void init() {
provider.register(rpcRegistry);
}
@Override
+ @PreDestroy
@SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
try {
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker"/>
- <reference id="notificationService" interface="org.opendaylight.controller.sal.binding.api.NotificationProviderService"/>
-
- <bean id="activator" class="org.opendaylight.openflowplugin.test.OpenflowpluginTestActivator"
- init-method="init" destroy-method="close">
- <argument ref="dataBroker"/>
- <argument ref="notificationService"/>
- <argument ref="blueprintBundleContext"/>
- </bean>
-</blueprint>