System ready integration for OFP 81/65881/12
authorGobinath <gobinath@ericsson.com>
Fri, 24 Nov 2017 06:31:22 +0000 (12:01 +0530)
committerGobinath Suganthan <gobinath@ericsson.com>
Tue, 5 Dec 2017 09:58:56 +0000 (09:58 +0000)
The openflowplugin will start switch connections only on the system
ready event triggered by the infrautils.

Change-Id: Ia60b36cb2446ed92d58d3507d2de9524d6efbc00
Signed-off-by: gobinath <gobinath@ericsson.com>
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/diagstatus/OpenflowPluginDiagStatusProvider.java [moved from openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java with 91% similarity]
openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/OpenFlowPluginProviderFactory.java
openflowplugin-blueprint-config/src/main/resources/org/opendaylight/blueprint/openflowplugin.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderFactoryImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java

@@ -5,18 +5,16 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.openflowplugin.impl.diagstatus;
+package org.opendaylight.openflowplugin.api.diagstatus;
 
 import org.opendaylight.infrautils.diagstatus.DiagStatusService;
 import org.opendaylight.infrautils.diagstatus.ServiceDescriptor;
 import org.opendaylight.infrautils.diagstatus.ServiceState;
 import org.opendaylight.infrautils.diagstatus.ServiceStatusProvider;
 
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-@OsgiServiceProvider(classes = ServiceStatusProvider.class)
 public class OpenflowPluginDiagStatusProvider implements ServiceStatusProvider {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginDiagStatusProvider.class);
index d8f42f6dfd9ec02dbb57b1c4a2cc6540ba367894..dbde3c6a022b4adfc47915b510894c0b2ee86b0a 100644 (file)
@@ -12,9 +12,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.infrautils.ready.SystemReadyMonitor;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
 
@@ -30,5 +31,6 @@ public interface OpenFlowPluginProviderFactory {
                                        List<SwitchConnectionProvider> switchConnectionProviders,
                                        ClusterSingletonServiceProvider singletonServiceProvider,
                                        MastershipChangeServiceManager mastershipChangeServiceManager,
-                                       DiagStatusService diagStatusService);
+                                       OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider,
+                                       SystemReadyMonitor systemReadyMonitor);
 }
index f3f8b8bb08e926d50dd5d1139eb5ed2d75d314bc..fabb5ee34c8b1a83dc192bc0bf582dda2ff9188d 100644 (file)
@@ -10,6 +10,7 @@
     <reference id="entityOwnershipService" interface="org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService"/>
     <reference id="clusterSingletonServiceProvider" interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
     <reference id="diagStatusService" interface="org.opendaylight.infrautils.diagstatus.DiagStatusService" />
+    <reference id="systemReadyMonitor" interface="org.opendaylight.infrautils.ready.SystemReadyMonitor" />
 
     <reference id="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
                odl:type="openflow-switch-connection-provider-default-impl"/>
                                update-method="update"/>
     </bean>
 
+    <bean id="ofPluginDiagstatusProvider"
+          class="org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider">
+        <argument ref="diagStatusService"/>
+    </bean>
+
+    <service ref="ofPluginDiagstatusProvider" interface="org.opendaylight.infrautils.diagstatus.ServiceStatusProvider"/>
+
     <service ref="configurationService" interface="org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService"/>
 
     <bean id="openflowPluginProvider"
@@ -59,7 +67,8 @@
         </argument>
         <argument ref="clusterSingletonServiceProvider"/>
         <argument ref="mastershipChangeServiceManager"/>
-        <argument ref="diagStatusService"/>
+        <argument ref="ofPluginDiagstatusProvider"/>
+        <argument ref="systemReadyMonitor"/>
     </bean>
 
     <service ref="openflowPluginProvider" odl:type="openflow-plugin-provider-impl">
index 8ddd0e7c97611a9c859deffb119774801737f5e0..ecbabd0dcf125f46af84c3543ff717c78e6820ae 100644 (file)
@@ -12,9 +12,10 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.infrautils.ready.SystemReadyMonitor;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
@@ -39,7 +40,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
                                               final List<SwitchConnectionProvider> switchConnectionProviders,
                                               final ClusterSingletonServiceProvider singletonServiceProvider,
                                               final MastershipChangeServiceManager mastershipChangeServiceManager,
-                                              final DiagStatusService diagStatusService) {
+                                              final OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider,
+                                              final SystemReadyMonitor systemReadyMonitor) {
         LOG.info("Initializing new OFP southbound.");
         final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(
                 configurationService,
@@ -50,7 +52,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
                 singletonServiceProvider,
                 entityOwnershipService,
                 mastershipChangeServiceManager,
-                diagStatusService);
+                ofPluginDiagstatusProvider,
+                systemReadyMonitor);
 
         openflowPluginProvider.initialize();
         return openflowPluginProvider;
index cf960fb28d5068a3be23cf81907dd03fcc7921ae..034245b55e336149c30b7499b886ce355c9bc34c 100644 (file)
@@ -37,10 +37,12 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
 import org.opendaylight.infrautils.diagstatus.ServiceState;
+import org.opendaylight.infrautils.ready.SystemReadyListener;
+import org.opendaylight.infrautils.ready.SystemReadyMonitor;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
+import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionManager;
@@ -59,7 +61,6 @@ import org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl;
 import org.opendaylight.openflowplugin.impl.device.DeviceManagerImpl;
 import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProvider;
 import org.opendaylight.openflowplugin.impl.device.initialization.DeviceInitializerProviderFactory;
-import org.opendaylight.openflowplugin.impl.diagstatus.OpenflowPluginDiagStatusProvider;
 import org.opendaylight.openflowplugin.impl.lifecycle.ContextChainHolderImpl;
 import org.opendaylight.openflowplugin.impl.protocol.deserialization.DeserializerInjector;
 import org.opendaylight.openflowplugin.impl.protocol.serialization.SerializerInjector;
@@ -80,7 +81,8 @@ import org.slf4j.LoggerFactory;
 
 public class OpenFlowPluginProviderImpl implements
         OpenFlowPluginProvider,
-        OpenFlowPluginExtensionRegistratorProvider {
+        OpenFlowPluginExtensionRegistratorProvider,
+        SystemReadyListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(OpenFlowPluginProviderImpl.class);
 
@@ -128,7 +130,8 @@ public class OpenFlowPluginProviderImpl implements
                                final ClusterSingletonServiceProvider singletonServiceProvider,
                                final EntityOwnershipService entityOwnershipService,
                                final MastershipChangeServiceManager mastershipChangeServiceManager,
-                               final DiagStatusService diagStatusService) {
+                               final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor,
+                               final SystemReadyMonitor systemReadyMonitor) {
         this.switchConnectionProviders = switchConnectionProviders;
         this.dataBroker = dataBroker;
         this.rpcProviderRegistry = rpcProviderRegistry;
@@ -140,9 +143,16 @@ public class OpenFlowPluginProviderImpl implements
         deviceInitializerProvider = DeviceInitializerProviderFactory.createDefaultProvider();
         config = new OpenFlowProviderConfigImpl(configurationService);
         this.mastershipChangeServiceManager = mastershipChangeServiceManager;
-        openflowPluginStatusMonitor = new OpenflowPluginDiagStatusProvider(diagStatusService);
+        this.openflowPluginStatusMonitor = openflowPluginStatusMonitor;
+        systemReadyMonitor.registerListener(this);
+        LOG.debug("registered onSystemBootReady() listener for deferred startSwitchConnections()");
     }
 
+    @Override
+    public void onSystemBootReady() {
+        LOG.debug("onSystemBootReady() received, starting the switch connections");
+        startSwitchConnections();
+    }
 
     private void startSwitchConnections() {
         Futures.addCallback(Futures.allAsList(switchConnectionProviders.stream().map(switchConnectionProvider -> {
@@ -259,7 +269,6 @@ public class OpenFlowPluginProviderImpl implements
         connectionManager.setDeviceDisconnectedHandler(contextChainHolder);
 
         deviceManager.initialize();
-        startSwitchConnections();
     }
 
     @Override
index 656b9d6de0682d602bc8dbbd6e5cecece1c2ee67..e9c1f7e42e214beecc69cc73d6e22aed50e737a2 100644 (file)
@@ -27,10 +27,10 @@ import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipL
 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.infrautils.ready.SystemReadyMonitor;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
-import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
+import org.opendaylight.openflowplugin.api.diagstatus.OpenflowPluginDiagStatusProvider;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
 import org.opendaylight.openflowplugin.api.openflow.mastership.MastershipChangeServiceManager;
@@ -49,7 +49,10 @@ public class OpenFlowPluginProviderImplTest {
     NotificationPublishService notificationPublishService;
 
     @Mock
-    DiagStatusService diagStatusService;
+    OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider;
+
+    @Mock
+    SystemReadyMonitor systemReadyMonitor;
 
     @Mock
     WriteTransaction writeTransaction;
@@ -110,17 +113,21 @@ public class OpenFlowPluginProviderImplTest {
 
     @Test
     public void testInitializeAndClose() throws Exception {
-        final OpenFlowPluginProvider provider = new OpenFlowPluginProviderFactoryImpl().newInstance(
+        final OpenFlowPluginProviderImpl provider = new OpenFlowPluginProviderImpl(
                 configurationService,
+                Lists.newArrayList(switchConnectionProvider),
                 dataBroker,
                 rpcProviderRegistry,
                 notificationPublishService,
-                entityOwnershipService,
-                Lists.newArrayList(switchConnectionProvider),
                 clusterSingletonServiceProvider,
+                entityOwnershipService,
                 mastershipChangeServiceManager,
-                diagStatusService);
+                ofPluginDiagstatusProvider,
+                systemReadyMonitor);
 
+        provider.initialize();
+        // Calling the onSystemBootReady() callback
+        provider.onSystemBootReady();
         verify(switchConnectionProvider).startup();
         provider.close();
         verify(switchConnectionProvider).shutdown();