OPNFLWPLUG-1064: Openflow diagstatus: Merge all 93/79793/22
authorShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Mon, 21 Jan 2019 12:14:40 +0000 (17:44 +0530)
committerShweta Chaturvedi <shweta.chaturvedi@ericsson.com>
Fri, 1 Mar 2019 05:56:37 +0000 (11:26 +0530)
the 3 openflow services into one "OPENFLOW"

Change-Id: I6d192ca72153f48892d8ee14c6e0d10f41c40dfc
Signed-off-by: Shweta Chaturvedi <shweta.chaturvedi@ericsson.com>
14 files changed:
openflowjava/openflow-protocol-api/pom.xml
openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OpenflowDiagStatusProvider.java [new file with mode: 0644]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OpenflowDiagStatusProviderImpl.java [new file with mode: 0644]
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderFactoryImpl.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java
openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java
openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java
openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java
openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProviderFactory.java
openflowjava/openflowjava-blueprint-config/src/main/resources/OSGI-INF/blueprint/openflowjava.xml
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java
openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginDiagStatusProvider.java [deleted file]
openflowplugin-impl/src/main/resources/OSGI-INF/blueprint/openflowplugin-impl.xml
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java

index 96595d998201c8752ea9675987024019cdd58753..1215163f7d0b8b707b20e042270063cec6e14b1f 100644 (file)
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>diagstatus-api</artifactId>
+            <version>${infrautils.version}</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OpenflowDiagStatusProvider.java b/openflowjava/openflow-protocol-api/src/main/java/org/opendaylight/openflowjava/protocol/api/connection/OpenflowDiagStatusProvider.java
new file mode 100644 (file)
index 0000000..dfb2c45
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019 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.openflowjava.protocol.api.connection;
+
+import org.opendaylight.infrautils.diagstatus.ServiceState;
+
+public interface OpenflowDiagStatusProvider {
+
+    void reportStatus(ServiceState serviceState);
+
+    void reportStatus(String diagStatusService, Throwable throwable);
+
+    void reportStatus(String diagStatusIdentifier, ServiceState serviceState, String description);
+
+    void reportStatus(String diagStatusIdentifier, ServiceState serviceState);
+}
+
+
diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OpenflowDiagStatusProviderImpl.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OpenflowDiagStatusProviderImpl.java
new file mode 100644 (file)
index 0000000..9c87771
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2019 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.openflowjava.protocol.impl.core;
+
+import static org.opendaylight.infrautils.diagstatus.ServiceState.ERROR;
+import static org.opendaylight.infrautils.diagstatus.ServiceState.OPERATIONAL;
+import static org.opendaylight.infrautils.diagstatus.ServiceState.STARTING;
+
+import java.util.HashMap;
+import java.util.Map;
+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.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.infrautils.diagstatus.ServiceDescriptor;
+import org.opendaylight.infrautils.diagstatus.ServiceState;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@Singleton
+@Service(classes = OpenflowDiagStatusProvider.class)
+public class OpenflowDiagStatusProviderImpl implements OpenflowDiagStatusProvider {
+    private static final Logger LOG = LoggerFactory.getLogger(OpenflowDiagStatusProviderImpl.class);
+    private static final String OPENFLOW_SERVICE = "OPENFLOW";
+    private static final String OPENFLOW_SERVER_6633 = "OPENFLOW_SERVER_6633";
+    private static final String OPENFLOW_SERVER_6653 = "OPENFLOW_SERVER_6653";
+    private static final String OPENFLOW_SERVICE_AGGREGATE = OPENFLOW_SERVICE;
+
+    private final DiagStatusService diagStatusService;
+    private volatile Map<String, ServiceState> statusMap = new HashMap<String, ServiceState>() {{
+            put(OPENFLOW_SERVICE, STARTING);
+            put(OPENFLOW_SERVER_6633, STARTING);
+            put(OPENFLOW_SERVER_6653, STARTING);
+        }
+    };
+
+    @Inject
+    public OpenflowDiagStatusProviderImpl(final @Reference DiagStatusService diagStatusService) {
+        this.diagStatusService = diagStatusService;
+        diagStatusService.register(OPENFLOW_SERVICE_AGGREGATE);
+    }
+
+    @Override
+    public void reportStatus(final ServiceState serviceState) {
+        LOG.debug("reporting status as {} for {}", serviceState,OPENFLOW_SERVICE_AGGREGATE);
+        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_AGGREGATE, serviceState));
+    }
+
+    @Override
+    public void reportStatus(final String diagStatusIdentifier, final Throwable throwable) {
+        LOG.debug("Reporting error for {} as {}",  diagStatusIdentifier, throwable.toString());
+        statusMap.replace(diagStatusIdentifier, ERROR);
+        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_AGGREGATE, throwable));
+    }
+
+    @Override
+    public void reportStatus(final String diagStatusIdentifier, final ServiceState serviceState,
+                             final String description) {
+        LOG.debug("Reporting status {} for {} and desc {}", serviceState, diagStatusIdentifier, description);
+        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_AGGREGATE, serviceState, description));
+    }
+
+    @Override
+    public void reportStatus(final String diagStatusIdentifier, final ServiceState serviceState) {
+        statusMap.replace(diagStatusIdentifier, serviceState);
+        LOG.info("The report status is {} for {}", serviceState, diagStatusIdentifier);
+        reportStatus();
+    }
+
+    public void reportStatus() {
+        boolean state = statusMap.values().stream().allMatch(serviceState -> serviceState.equals(OPERATIONAL));
+        if (state) {
+            reportStatus(OPERATIONAL);
+        }
+    }
+}
\ No newline at end of file
index 319c5b9622c9043dc55a745ef99a68966c69b59f..63357e1d678c3ab45b71b36586e0bedb8c527091 100644 (file)
@@ -11,12 +11,10 @@ import com.google.common.base.MoreObjects;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.List;
-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.infrautils.diagstatus.DiagStatusService;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
@@ -35,16 +33,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow
 @Service(classes = SwitchConnectionProviderFactory.class)
 public class SwitchConnectionProviderFactoryImpl implements SwitchConnectionProviderFactory {
 
-    private final DiagStatusService diagStatusService;
-
-    @Inject
-    public SwitchConnectionProviderFactoryImpl(@Reference DiagStatusService diagStatusService) {
-        this.diagStatusService = diagStatusService;
-    }
-
     @Override
-    public SwitchConnectionProvider newInstance(SwitchConnectionConfig config) {
-        return new SwitchConnectionProviderImpl(new ConnectionConfigurationImpl(config), diagStatusService);
+    public SwitchConnectionProvider newInstance(SwitchConnectionConfig config,
+                                                OpenflowDiagStatusProvider openflowPluginDiagStatusProvider) {
+        return new SwitchConnectionProviderImpl(new ConnectionConfigurationImpl(config),
+                openflowPluginDiagStatusProvider);
     }
 
     private static InetAddress getInetAddress(final IpAddress address) throws UnknownHostException {
index 40adc5716bb71bdb03a42b33c03c96c5a4cd11d8..b0f53810747bea3f8f61df75298af2492c35d408 100755 (executable)
@@ -17,11 +17,10 @@ import com.google.common.util.concurrent.MoreExecutors;
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.epoll.Epoll;
 import org.checkerframework.checker.nullness.qual.Nullable;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
-import org.opendaylight.infrautils.diagstatus.ServiceDescriptor;
 import org.opendaylight.infrautils.diagstatus.ServiceState;
 import org.opendaylight.infrautils.utils.concurrent.Executors;
 import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistry;
 import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
@@ -80,23 +79,19 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
     private final DeserializerRegistry deserializerRegistry;
     private final DeserializationFactory deserializationFactory;
     private final ListeningExecutorService listeningExecutorService;
-    private final DiagStatusService diagStatusService;
     private final String diagStatusIdentifier;
     private final String threadName;
     private TcpConnectionInitializer connectionInitializer;
+    private OpenflowDiagStatusProvider openflowDiagStatusProvider;
 
     public SwitchConnectionProviderImpl(
-            @Nullable ConnectionConfiguration connConfig, DiagStatusService diagStatusService) {
+            @Nullable ConnectionConfiguration connConfig, OpenflowDiagStatusProvider openflowDiagStatusProvider) {
         this.connConfig = connConfig;
         String connectionSuffix = createConnectionSuffix(connConfig);
-
-        this.diagStatusService = diagStatusService;
         this.diagStatusIdentifier = OPENFLOW_JAVA_SERVICE_NAME_PREFIX + connectionSuffix;
-        diagStatusService.register(diagStatusIdentifier);
-
+        this.openflowDiagStatusProvider = openflowDiagStatusProvider;
         this.threadName = THREAD_NAME_PREFIX + connectionSuffix;
         this.listeningExecutorService = Executors.newListeningSingleThreadExecutor(threadName, LOG);
-
         serializerRegistry = new SerializerRegistryImpl();
         if (connConfig != null) {
             serializerRegistry.setGroupAddModConfig(connConfig.isGroupAddModEnabled());
@@ -150,13 +145,13 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
 
                 @Override
                 public void onFailure(Throwable throwable) {
-                    diagStatusService.report(new ServiceDescriptor(diagStatusIdentifier, throwable));
+                    openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, throwable);
                 }
 
                 @Override
                 public void onSuccess(@Nullable Object nullResult) {
-                    diagStatusService.report(new ServiceDescriptor(
-                            diagStatusIdentifier, ServiceState.ERROR, threadName + " terminated"));
+                    openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, ServiceState.ERROR,
+                            threadName + " terminated");
                 }
             } , MoreExecutors.directExecutor());
             return serverFacade.getIsOnlineFuture();
@@ -177,25 +172,23 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         factory.setUseBarrier(connConfig.useBarrier());
         factory.setChannelOutboundQueueSize(connConfig.getChannelOutboundQueueSize());
         final TransportProtocol transportProtocol = (TransportProtocol) connConfig.getTransferProtocol();
-
         // Check if Epoll native transport is available.
         // TODO : Add option to disable Epoll.
         boolean isEpollEnabled = Epoll.isAvailable();
 
         if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
-            server = new TcpHandler(connConfig.getAddress(), connConfig.getPort(), () -> diagStatusService
-                            .report(new ServiceDescriptor(diagStatusIdentifier, ServiceState.OPERATIONAL)));
+            server = new TcpHandler(connConfig.getAddress(), connConfig.getPort(), () ->
+                    openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, ServiceState.OPERATIONAL));
             final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
             ((TcpHandler) server).setChannelInitializer(channelInitializer);
             ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
-
             final EventLoopGroup workerGroupFromTcpHandler = ((TcpHandler) server).getWorkerGroup();
             connectionInitializer = new TcpConnectionInitializer(workerGroupFromTcpHandler, isEpollEnabled);
             connectionInitializer.setChannelInitializer(channelInitializer);
             connectionInitializer.run();
         } else if (TransportProtocol.UDP.equals(transportProtocol)) {
-            server = new UdpHandler(connConfig.getAddress(), connConfig.getPort(), () -> diagStatusService
-                    .report(new ServiceDescriptor(diagStatusIdentifier, ServiceState.OPERATIONAL)));
+            server = new UdpHandler(connConfig.getAddress(), connConfig.getPort(), () ->
+                    openflowDiagStatusProvider.reportStatus(diagStatusIdentifier, ServiceState.OPERATIONAL));
             ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
             ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
         } else {
index e43e93b3ff16f73664eb0b27cb86c3598c9fa77d..fcfc1a461f8e670bba017009c766862c3a0d2df1 100755 (executable)
@@ -15,7 +15,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
@@ -59,7 +59,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731
  * @author michal.polkorab
  */
 public class SwitchConnectionProviderImpl02Test {
-    @Mock DiagStatusService diagStatusService;
     @Mock SwitchConnectionHandler handler;
     @Mock OFGeneralSerializer serializer;
     @Mock OFGeneralDeserializer deserializer;
@@ -72,6 +71,7 @@ public class SwitchConnectionProviderImpl02Test {
     @Mock OFSerializer<ExperimenterDataOfChoice> serializerMultipartRequestExpCase;
     @Mock OFSerializer<MeterBandExperimenterCase> serializerMeterBandExpCase;
     @Mock ConnectionConfigurationImpl config;
+    @Mock OpenflowDiagStatusProvider openflowPluginDiagStatusProvider;
     private static final int CHANNEL_OUTBOUND_QUEUE_SIZE = 1024;
     private static final int SWITCH_IDLE_TIMEOUT = 2000;
     private TlsConfiguration tlsConfiguration;
@@ -88,7 +88,7 @@ public class SwitchConnectionProviderImpl02Test {
         if (protocol != null) {
             createConfig(protocol);
         }
-        provider = new SwitchConnectionProviderImpl(config, diagStatusService);
+        provider = new SwitchConnectionProviderImpl(config,openflowPluginDiagStatusProvider);
     }
 
     private void createConfig(final TransportProtocol protocol) throws UnknownHostException {
index 4ebdd969838c5c1b763240a206ecbe01a51ce367..ca6bc3e50e329d44deb95132c17a5fa176d969a7 100644 (file)
@@ -19,7 +19,7 @@ import org.junit.Assert;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
 public class SwitchConnectionProviderImplTest {
 
     @Mock SwitchConnectionHandler handler;
-    @Mock DiagStatusService diagStatusService;
+    @Mock OpenflowDiagStatusProvider openflowPluginDiagStatusProvider;
 
     private static final int SWITCH_IDLE_TIMEOUT = 2000;
     private static final int WAIT_TIMEOUT = 2000;
@@ -51,13 +51,14 @@ public class SwitchConnectionProviderImplTest {
      * Creates new {@link SwitchConnectionProvider} instance for each test.
      * @param protocol communication protocol
      */
+
     public void startUp(final TransportProtocol protocol) throws UnknownHostException {
         MockitoAnnotations.initMocks(this);
         config = null;
         if (protocol != null) {
             createConfig(protocol);
         }
-        provider = new SwitchConnectionProviderImpl(config, diagStatusService);
+        provider = new SwitchConnectionProviderImpl(config, openflowPluginDiagStatusProvider);
     }
 
     private void createConfig(final TransportProtocol protocol) throws UnknownHostException {
index 92c9d64bc9df7089c15431e000ec6a0e6d5d556c..63bd44a6f6b6b083e24ee031c2406f3f1e6596cf 100644 (file)
@@ -18,7 +18,7 @@ import java.util.concurrent.TimeoutException;
 import org.junit.After;
 import org.junit.Test;
 import org.mockito.Mockito;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
@@ -88,7 +88,8 @@ public class IntegrationTest {
         connConfig.setTransferProtocol(protocol);
         mockPlugin = new MockPlugin();
 
-        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig, Mockito.mock(DiagStatusService.class));
+        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig,
+                Mockito.mock(OpenflowDiagStatusProvider.class));
         switchConnectionProvider.setSwitchConnectionHandler(mockPlugin);
         switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
         if (protocol.equals(TransportProtocol.TCP) || protocol.equals(TransportProtocol.TLS)) {
index 9ef8c4dda660e5b50ff94d2c619c992260c87483..d0447af2dd706c79f7423e3dc7919f5f129b06a8 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.openflowjava.protocol.spi.connection;
 
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig;
 
 /**
@@ -21,5 +22,6 @@ public interface SwitchConnectionProviderFactory {
      * @param config the SwitchConnectionConfig
      * @return a SwitchConnectionProvider instance
      */
-    SwitchConnectionProvider newInstance(SwitchConnectionConfig config);
+    SwitchConnectionProvider newInstance(SwitchConnectionConfig config,
+                                         OpenflowDiagStatusProvider openflowPluginDiagStatusProvider);
 }
index d26b04ea4e8f24863b26d75ae95f43fab7958e79..9043183f32723c6db315ff01f1ce0c1d9ac535a2 100644 (file)
@@ -1,9 +1,8 @@
 <?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">
-
+  <reference id="openflowPluginDiagStatusProvider" interface="org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider"/>
   <reference id="switchConnectionProviderFactory" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderFactory"/>
-
   <!-- Create OF switch connection provider on port 6653 (default) -->
   <odl:clustered-app-config id="defaultSwitchConnConfig" default-config-file-name="default-openflow-connection-config.xml"
       binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.openflow._switch.connection.config.rev160506.SwitchConnectionConfig"
@@ -11,6 +10,7 @@
   </odl:clustered-app-config>
   <bean id="defaultSwitchConnProvider" factory-ref="switchConnectionProviderFactory" factory-method="newInstance">
     <argument ref="defaultSwitchConnConfig"/>
+    <argument ref="openflowPluginDiagStatusProvider"/>
   </bean>
   <service ref="defaultSwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
           odl:type="openflow-switch-connection-provider-default-impl"/>
@@ -22,6 +22,7 @@
   </odl:clustered-app-config>
   <bean id="legacySwitchConnProvider" factory-ref="switchConnectionProviderFactory" factory-method="newInstance">
     <argument ref="legacySwitchConnConfig"/>
+    <argument ref="openflowPluginDiagStatusProvider"/>
   </bean>
   <service ref="legacySwitchConnProvider" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider"
           odl:type="openflow-switch-connection-provider-legacy-impl"/>
index 4934a86aa68be3576a0d896742eb96660281968d..a37ce0267b487e35b9fd2fe1b1dbcd8f10ab2799 100644 (file)
@@ -49,6 +49,7 @@ import org.opendaylight.mdsal.binding.api.NotificationPublishService;
 import org.opendaylight.mdsal.binding.api.RpcProviderService;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
 import org.opendaylight.openflowplugin.api.openflow.OpenFlowPluginProvider;
@@ -126,8 +127,9 @@ public class OpenFlowPluginProviderImpl implements
     private ConnectionManager connectionManager;
     private ListeningExecutorService executorService;
     private ContextChainHolderImpl contextChainHolder;
-    private final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor;
+    private final OpenflowDiagStatusProvider openflowDiagStatusProvider;
     private final SettableFuture<Void> fullyStarted = SettableFuture.create();
+    private static final String OPENFLOW_SERVICE_NAME = "OPENFLOW";
 
     public static MessageIntelligenceAgency getMessageIntelligenceAgency() {
         return MESSAGE_INTELLIGENCE_AGENCY;
@@ -142,7 +144,7 @@ public class OpenFlowPluginProviderImpl implements
                                final @Reference ClusterSingletonServiceProvider singletonServiceProvider,
                                final @Reference EntityOwnershipService entityOwnershipService,
                                final MastershipChangeServiceManager mastershipChangeServiceManager,
-                               final OpenflowPluginDiagStatusProvider openflowPluginStatusMonitor,
+                               final @Reference OpenflowDiagStatusProvider openflowDiagStatusProvider,
                                final @Reference SystemReadyMonitor systemReadyMonitor) {
         this.switchConnectionProviders = switchConnectionProviders;
         this.dataBroker = pingPongDataBroker;
@@ -155,7 +157,7 @@ public class OpenFlowPluginProviderImpl implements
         deviceInitializerProvider = DeviceInitializerProviderFactory.createDefaultProvider();
         config = new OpenFlowProviderConfigImpl(configurationService);
         this.mastershipChangeServiceManager = mastershipChangeServiceManager;
-        this.openflowPluginStatusMonitor = openflowPluginStatusMonitor;
+        this.openflowDiagStatusProvider = openflowDiagStatusProvider;
         systemReadyMonitor.registerListener(this);
         LOG.info("registered onSystemBootReady() listener for deferred startSwitchConnections()");
     }
@@ -180,14 +182,14 @@ public class OpenFlowPluginProviderImpl implements
             @Override
             public void onSuccess(@Nonnull final List<Boolean> result) {
                 LOG.info("All switchConnectionProviders are up and running ({}).", result.size());
-                openflowPluginStatusMonitor.reportStatus(ServiceState.OPERATIONAL);
+                openflowDiagStatusProvider.reportStatus(OPENFLOW_SERVICE_NAME, ServiceState.OPERATIONAL);
                 fullyStarted.set(null);
             }
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
                 LOG.warn("Some switchConnectionProviders failed to start.", throwable);
-                openflowPluginStatusMonitor.reportStatus(ServiceState.ERROR, throwable);
+                openflowDiagStatusProvider.reportStatus(OPENFLOW_SERVICE_NAME, throwable);
                 fullyStarted.setException(throwable);
             }
         }, MoreExecutors.directExecutor());
@@ -311,7 +313,7 @@ public class OpenFlowPluginProviderImpl implements
         gracefulShutdown(executorService);
         gracefulShutdown(hashedWheelTimer);
         unregisterMXBean(MESSAGE_INTELLIGENCE_AGENCY_MX_BEAN_NAME);
-        openflowPluginStatusMonitor.reportStatus(ServiceState.UNREGISTERED);
+        openflowDiagStatusProvider.reportStatus(ServiceState.UNREGISTERED);
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginDiagStatusProvider.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenflowPluginDiagStatusProvider.java
deleted file mode 100644 (file)
index bdaafb2..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import org.apache.aries.blueprint.annotation.service.Reference;
-import org.opendaylight.infrautils.diagstatus.DiagStatusService;
-import org.opendaylight.infrautils.diagstatus.ServiceDescriptor;
-import org.opendaylight.infrautils.diagstatus.ServiceState;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Singleton
-public class OpenflowPluginDiagStatusProvider {
-
-    private static final Logger LOG = LoggerFactory.getLogger(OpenflowPluginDiagStatusProvider.class);
-    private static final String OPENFLOW_SERVICE_NAME = "OPENFLOW";
-
-    private final DiagStatusService diagStatusService;
-
-    @Inject
-    public OpenflowPluginDiagStatusProvider(final @Reference DiagStatusService diagStatusService) {
-        this.diagStatusService = diagStatusService;
-        diagStatusService.register(OPENFLOW_SERVICE_NAME);
-    }
-
-    public void reportStatus(ServiceState serviceState) {
-        LOG.debug("reporting status as {} for {}", serviceState, OPENFLOW_SERVICE_NAME);
-        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_NAME, serviceState));
-    }
-
-    public void reportStatus(ServiceState serviceState, Throwable throwable) {
-        LOG.debug("reporting status as {} for {}", serviceState, OPENFLOW_SERVICE_NAME);
-        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_NAME, throwable));
-    }
-
-    public void reportStatus(ServiceState serviceState, String description) {
-        LOG.debug("reporting status as {} for {}", serviceState, OPENFLOW_SERVICE_NAME);
-        diagStatusService.report(new ServiceDescriptor(OPENFLOW_SERVICE_NAME, serviceState, description));
-    }
-}
index 85726b42736438d7bf4343b7761682b688de6203..d6c0514cc86cae225fe4e074e79ef233cba9e62f 100644 (file)
@@ -30,5 +30,7 @@
 
   <reference id="switchConnectionProviderList" interface="org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList" ext:proxy-method="classes"/>
 
+  <reference id="openflowPluginDiagStatusProviderImpl" interface="org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider" ext:proxy-method="classes"/>
+
   <odl:action-provider interface="org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService"/>
 </blueprint>
index 24383c5469b2ee40979fa81d859f750de64b0b8b..a1caa8aa33af56c8e22a85d47c10e7d508659d9a 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipListenerRegistration;
 import org.opendaylight.mdsal.eos.binding.api.EntityOwnershipService;
 import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+import org.opendaylight.openflowjava.protocol.api.connection.OpenflowDiagStatusProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProviderList;
 import org.opendaylight.openflowplugin.api.openflow.configuration.ConfigurationProperty;
@@ -49,7 +50,7 @@ public class OpenFlowPluginProviderImplTest {
     NotificationPublishService notificationPublishService;
 
     @Mock
-    OpenflowPluginDiagStatusProvider ofPluginDiagstatusProvider;
+    OpenflowDiagStatusProvider ofPluginDiagstatusProvider;
 
     @Mock
     SystemReadyMonitor systemReadyMonitor;