DiagStatus integration for openflowplugin 97/64197/12
authorFaseela K <faseela.k@ericsson.com>
Thu, 12 Oct 2017 11:43:29 +0000 (17:13 +0530)
committerFaseela K <faseela.k@ericsson.com>
Tue, 7 Nov 2017 01:46:44 +0000 (07:16 +0530)
Openflowplugin should report their initial status once
all switch connection providers are initialized.
Subsequent patches will query the dynamic status of port
6653/6633 to advertise the live status.
Further enhancements can be done if openflowplugin can query
some of the major service status before opening up the
southbound interfaces.

Change-Id: Id57f52d3ad02d59f7469762b1e1f0fb468b785ce
Signed-off-by: Faseela K <faseela.k@ericsson.com>
features-aggregator/odl-openflowplugin-southbound/pom.xml
openflowplugin-api/pom.xml
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/pom.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/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java [new file with mode: 0644]
openflowplugin-impl/src/main/resources/org/opendaylight/blueprint/openflowplugin-impl.xml
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java
parent/pom.xml

index d72eac990c00e1db91df1dfbf3f70241c9a8c400..2a6c089e15c7ff2ef846109253c122be190fe690 100644 (file)
@@ -19,6 +19,7 @@
     <properties>
         <mdsal.version>1.7.0-SNAPSHOT</mdsal.version>
         <lldp.version>0.14.0-SNAPSHOT</lldp.version>
+        <infrautils.version>1.3.0-SNAPSHOT</infrautils.version>
     </properties>
 
     <dependencyManagement>
             <classifier>features</classifier>
             <type>xml</type>
         </dependency>
-
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>odl-infrautils-diagstatus</artifactId>
+            <version>${infrautils.version}</version>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
         <dependency>
             <groupId>org.opendaylight.openflowplugin</groupId>
             <artifactId>odl-openflowplugin-nsf-model</artifactId>
             <artifactId>liblldp</artifactId>
             <version>${lldp.version}</version>
         </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+        </dependency>
 
         <!-- config files -->
         <dependency>
index 9ad55925cd8b01a3644229163d52edee63b29cc9..052ecd09a8b41fc2bfd62c959247fd36db0eccb7 100644 (file)
             <groupId>org.opendaylight.mdsal</groupId>
             <artifactId>mdsal-singleton-common-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>diagstatus-api</artifactId>
+            <version>${infrautils.version}</version>
+        </dependency>
     </dependencies>
 
 </project>
index 3322cc5d18e4cfc5072f0c8e355487f5db42b003..d8f42f6dfd9ec02dbb57b1c4a2cc6540ba367894 100644 (file)
@@ -12,6 +12,7 @@ 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.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationService;
@@ -28,5 +29,6 @@ public interface OpenFlowPluginProviderFactory {
                                        EntityOwnershipService entityOwnershipService,
                                        List<SwitchConnectionProvider> switchConnectionProviders,
                                        ClusterSingletonServiceProvider singletonServiceProvider,
-                                       MastershipChangeServiceManager mastershipChangeServiceManager);
+                                       MastershipChangeServiceManager mastershipChangeServiceManager,
+                                       DiagStatusService diagStatusService);
 }
index 74ab81484e92a647744a6c1a275b3b774e5bd16c..f3f8b8bb08e926d50dd5d1139eb5ed2d75d314bc 100644 (file)
@@ -9,6 +9,7 @@
     <reference id="notificationPublishService" interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService"/>
     <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="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
                odl:type="openflow-switch-connection-provider-default-impl"/>
@@ -58,6 +59,7 @@
         </argument>
         <argument ref="clusterSingletonServiceProvider"/>
         <argument ref="mastershipChangeServiceManager"/>
+        <argument ref="diagStatusService"/>
     </bean>
 
     <service ref="openflowPluginProvider" odl:type="openflow-plugin-provider-impl">
index 2406609a05916188438bcb157b9f4b557d4133ee..5a4340fc3820f333f9c3b9c5888022f2d7f6fe2b 100644 (file)
             <groupId>${project.groupId}.openflowjava</groupId>
             <artifactId>openflow-protocol-api</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>diagstatus-api</artifactId>
+            <version>${infrautils.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.cdi</groupId>
+            <artifactId>pax-cdi-api</artifactId>
+            <optional>true</optional>
+        </dependency>
         <dependency>
             <groupId>${project.groupId}.openflowjava</groupId>
             <artifactId>openflow-protocol-spi</artifactId>
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
index 309ef486f82d051b773ff65cc28e3bdaa1a8f3eb..8ddd0e7c97611a9c859deffb119774801737f5e0 100644 (file)
@@ -12,6 +12,7 @@ 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.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
@@ -37,7 +38,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
                                               final EntityOwnershipService entityOwnershipService,
                                               final List<SwitchConnectionProvider> switchConnectionProviders,
                                               final ClusterSingletonServiceProvider singletonServiceProvider,
-                                              final MastershipChangeServiceManager mastershipChangeServiceManager) {
+                                              final MastershipChangeServiceManager mastershipChangeServiceManager,
+                                              final DiagStatusService diagStatusService) {
         LOG.info("Initializing new OFP southbound.");
         final OpenFlowPluginProvider openflowPluginProvider = new OpenFlowPluginProviderImpl(
                 configurationService,
@@ -47,7 +49,8 @@ public class OpenFlowPluginProviderFactoryImpl implements OpenFlowPluginProvider
                 notificationPublishService,
                 singletonServiceProvider,
                 entityOwnershipService,
-                mastershipChangeServiceManager);
+                mastershipChangeServiceManager,
+                diagStatusService);
 
         openflowPluginProvider.initialize();
         return openflowPluginProvider;
index f8fffb2c30879814ab0cae45c4bfa4cc02c0b404..cf960fb28d5068a3be23cf81907dd03fcc7921ae 100644 (file)
@@ -37,6 +37,8 @@ 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.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
@@ -57,6 +59,7 @@ 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;
@@ -111,6 +114,7 @@ public class OpenFlowPluginProviderImpl implements
     private ConnectionManager connectionManager;
     private ListeningExecutorService executorService;
     private ContextChainHolderImpl contextChainHolder;
+    private OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor;
 
     public static MessageIntelligenceAgency getMessageIntelligenceAgency() {
         return MESSAGE_INTELLIGENCE_AGENCY;
@@ -123,7 +127,8 @@ public class OpenFlowPluginProviderImpl implements
                                final NotificationPublishService notificationPublishService,
                                final ClusterSingletonServiceProvider singletonServiceProvider,
                                final EntityOwnershipService entityOwnershipService,
-                               final MastershipChangeServiceManager mastershipChangeServiceManager) {
+                               final MastershipChangeServiceManager mastershipChangeServiceManager,
+                               final DiagStatusService diagStatusService) {
         this.switchConnectionProviders = switchConnectionProviders;
         this.dataBroker = dataBroker;
         this.rpcProviderRegistry = rpcProviderRegistry;
@@ -135,6 +140,7 @@ public class OpenFlowPluginProviderImpl implements
         deviceInitializerProvider = DeviceInitializerProviderFactory.createDefaultProvider();
         config = new OpenFlowProviderConfigImpl(configurationService);
         this.mastershipChangeServiceManager = mastershipChangeServiceManager;
+        openflowPluginStatusMonitor = new OpenflowPluginDiagStatusProvider(diagStatusService);
     }
 
 
@@ -155,11 +161,13 @@ public class OpenFlowPluginProviderImpl implements
             @Override
             public void onSuccess(final List<Boolean> result) {
                 LOG.info("All switchConnectionProviders are up and running ({}).", result.size());
+                openflowPluginStatusMonitor.reportStatus(ServiceState.OPERATIONAL, "switch connections started");
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 LOG.warn("Some switchConnectionProviders failed to start.", throwable);
+                openflowPluginStatusMonitor.reportStatus(ServiceState.ERROR, "some switch connections failed to start");
             }
         });
     }
@@ -275,6 +283,7 @@ public class OpenFlowPluginProviderImpl implements
         gracefulShutdown(executorService);
         gracefulShutdown(hashedWheelTimer);
         unregisterMXBean(MESSAGE_INTELLIGENCE_AGENCY_MX_BEAN_NAME);
+        openflowPluginStatusMonitor.reportStatus(ServiceState.UNREGISTERED, "service shutting down");
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/diagstatus/OpenflowPluginDiagStatusProvider.java
new file mode 100644 (file)
index 0000000..83b17ac
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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;
+
+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);
+    private static final String OPENFLOW_SERVICE_NAME = "OPENFLOW";
+
+    private final DiagStatusService diagStatusService;
+    private volatile ServiceDescriptor serviceDescriptor;
+
+    public OpenflowPluginDiagStatusProvider(final DiagStatusService diagStatusService) {
+        this.diagStatusService = diagStatusService;
+        diagStatusService.register(OPENFLOW_SERVICE_NAME);
+    }
+
+    public void reportStatus(ServiceState serviceState, String description) {
+        LOG.debug("reporting status as {} for {}", serviceState, OPENFLOW_SERVICE_NAME);
+        serviceDescriptor = new ServiceDescriptor(OPENFLOW_SERVICE_NAME, serviceState, description);
+        diagStatusService.report(serviceDescriptor);
+    }
+
+    @Override
+    public ServiceDescriptor getServiceDescriptor() {
+        // TODO Check 6653/6633 port status to report dynamic status
+        return serviceDescriptor;
+    }
+}
\ No newline at end of file
index d6e37a20950b62a59d81a123eb510374a05dc68b..ede48ec53516c1bf98a3a878bec0256630a0578c 100644 (file)
@@ -4,7 +4,6 @@
            odl:use-default-for-reference-types="true">
 
   <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
-
   <bean id="ofPluginProviderFactory" class="org.opendaylight.openflowplugin.impl.OpenFlowPluginProviderFactoryImpl"/>
   <service ref="ofPluginProviderFactory" interface="org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProviderFactory"/>
 
index 882d4e58bc1e68b369d4ac96f43b79ba32fc6503..656b9d6de0682d602bc8dbbd6e5cecece1c2ee67 100644 (file)
@@ -27,6 +27,7 @@ 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.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
@@ -47,6 +48,9 @@ public class OpenFlowPluginProviderImplTest {
     @Mock
     NotificationPublishService notificationPublishService;
 
+    @Mock
+    DiagStatusService diagStatusService;
+
     @Mock
     WriteTransaction writeTransaction;
 
@@ -114,7 +118,8 @@ public class OpenFlowPluginProviderImplTest {
                 entityOwnershipService,
                 Lists.newArrayList(switchConnectionProvider),
                 clusterSingletonServiceProvider,
-                mastershipChangeServiceManager);
+                mastershipChangeServiceManager,
+                diagStatusService);
 
         verify(switchConnectionProvider).startup();
         provider.close();
index e61719069d698273607af6faed9fa10f14a2c0bb..1a7cd144e9f4fc4e7def02accfd6e03594ed0fd6 100644 (file)
@@ -39,6 +39,7 @@
         <yangtools.version>1.2.0</yangtools.version>
         <argparse4j.version>0.7.0</argparse4j.version>
         <exi.nagasena.version>0000.0002.0053.0</exi.nagasena.version>
+        <infrautils.version>1.3.0-SNAPSHOT</infrautils.version>
     </properties>
 
     <dependencyManagement>