report diagstatus from UdpHandler/TcpHandler on Netty thread terminate 77/78677/11
authorMichael Vorburger <vorburger@redhat.com>
Wed, 12 Dec 2018 11:41:56 +0000 (12:41 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Thu, 20 Dec 2018 23:10:17 +0000 (00:10 +0100)
This introduces new OPENFLOW_SERVER-{address}:{port} diagstatus service
names in SwitchConnectionProviderImpl, where UdpHandler/TcpHandler
start.

The Thread is now named including the same -{address}:{port} suffix.

This is a counter-proposal to the idea of "add a channelFuture to
listen for when the channel is closed and then update diagstatus"
originally proposed in Ieb78f225c1fcdd2ebf72ad1a99a49d4993a6a5b6,
because if/when that channel is closed, the UdpHandler/TcpHandler
Runnable thread exits, so this will achieve the same result in a
more general safer way.

This may (TBC) indirectly also fix OPNFLPLUG-1057.

JIRA: OPNFLWPLUG-1053
Change-Id: I5af740faa55ee55fbbe55acc34ea62905869fe35
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
openflowjava/features-openflowjava-aggregator/odl-openflowjava-protocol/pom.xml
openflowjava/openflow-protocol-impl/pom.xml
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/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java
openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java
openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.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-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java
openflowjava/openflow-protocol-it/src/test/java/org/opendaylight/openflowjava/protocol/it/integration/IntegrationTest.java

index 5d0da1d20487375de4794dd8af1ea7b18c74900e..d17e3ace9451d50c9404ebb72d6a0456298b426a 100644 (file)
             <type>xml</type>
             <classifier>features</classifier>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>odl-infrautils-diagstatus</artifactId>
+            <version>1.5.0-SNAPSHOT</version>
+            <type>xml</type>
+            <classifier>features</classifier>
+        </dependency>
         <!-- bundle dependencies -->
         <dependency>
             <groupId>${project.groupId}</groupId>
index 7494807fcda857df7128b5d6dee1bd006492997b..83da0b655b9e18e826082f11aaa1a739a19c80fb 100644 (file)
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.infrautils</groupId>
+            <artifactId>diagstatus-api</artifactId>
+            <version>${infrautils.version}</version>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
index 1cc8a15e443d4bdc69613b8a8460a9ae15f855ed..319c5b9622c9043dc55a745ef99a68966c69b59f 100644 (file)
@@ -11,8 +11,11 @@ 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.ThreadConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
@@ -32,9 +35,16 @@ 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));
+        return new SwitchConnectionProviderImpl(new ConnectionConfigurationImpl(config), diagStatusService);
     }
 
     private static InetAddress getInetAddress(final IpAddress address) throws UnknownHostException {
index d2318df679aeb7d85aba3a4f0c9b55290d22754a..5d135be153f61a51bddcfa44a9ed505820a5dd9f 100755 (executable)
@@ -9,11 +9,18 @@
 
 package org.opendaylight.openflowjava.protocol.impl.core;
 
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
 import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
 import com.google.common.util.concurrent.SettableFuture;
 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.SwitchConnectionHandler;
@@ -63,6 +70,8 @@ import org.slf4j.LoggerFactory;
 public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, ConnectionInitializer {
 
     private static final Logger LOG = LoggerFactory.getLogger(SwitchConnectionProviderImpl.class);
+    private static final String THREAD_NAME_PREFIX = "OFP-SwitchConnectionProvider-Udp/TcpHandler";
+    private static final String OPENFLOW_JAVA_SERVICE_NAME_PREFIX = "OPENFLOW_SERVER";
 
     private SwitchConnectionHandler switchConnectionHandler;
     private ServerFacade serverFacade;
@@ -72,12 +81,23 @@ 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;
 
-    public SwitchConnectionProviderImpl(ConnectionConfiguration connConfig) {
-        this.listeningExecutorService = Executors
-                .newListeningSingleThreadExecutor("OFP-SwitchConnectionProvider-Udp/TcpHandler", LOG);
+    public SwitchConnectionProviderImpl(
+            @Nullable ConnectionConfiguration connConfig, DiagStatusService diagStatusService) {
         this.connConfig = connConfig;
+        String connectionSuffix = createConnectionSuffix(connConfig);
+
+        this.diagStatusService = diagStatusService;
+        this.diagStatusIdentifier = OPENFLOW_JAVA_SERVICE_NAME_PREFIX + connectionSuffix;
+        diagStatusService.register(diagStatusIdentifier);
+
+        this.threadName = THREAD_NAME_PREFIX + connectionSuffix;
+        this.listeningExecutorService = Executors.newListeningSingleThreadExecutor(threadName, LOG);
+
         serializerRegistry = new SerializerRegistryImpl();
         if (connConfig != null) {
             serializerRegistry.setGroupAddModConfig(connConfig.isGroupAddModEnabled());
@@ -89,6 +109,17 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         deserializationFactory = new DeserializationFactory(deserializerRegistry);
     }
 
+    // ID based, on configuration, used for diagstatus serviceIdentifier (ServiceDescriptor moduleServiceName)
+    private static String createConnectionSuffix(@Nullable ConnectionConfiguration config) {
+        if (config != null && config.getAddress() != null) {
+            return "-" + config.getAddress().toString() + "_" + config.getPort();
+        } else if (config != null) {
+            return "_" + config.getPort();
+        } else {
+            return "-null-config";
+        }
+    }
+
     @Override
     public void setSwitchConnectionHandler(final SwitchConnectionHandler switchConnectionHandler) {
         LOG.debug("setSwitchConnectionHandler");
@@ -117,7 +148,19 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
             if (switchConnectionHandler == null) {
                 throw new IllegalStateException("SwitchConnectionHandler is not set");
             }
-            listeningExecutorService.submit(serverFacade);
+            Futures.addCallback(listeningExecutorService.submit(serverFacade), new FutureCallback<Object>() {
+
+                @Override
+                public void onFailure(Throwable throwable) {
+                    diagStatusService.report(new ServiceDescriptor(diagStatusIdentifier, throwable));
+                }
+
+                @Override
+                public void onSuccess(@Nullable Object nullResult) {
+                    diagStatusService.report(new ServiceDescriptor(
+                            diagStatusIdentifier, ServiceState.ERROR, threadName + " terminated"));
+                }
+            } , MoreExecutors.directExecutor());
             result = serverFacade.getIsOnlineFuture();
         } catch (RuntimeException e) {
             final SettableFuture<Boolean> exResult = SettableFuture.create();
@@ -129,7 +172,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
 
     private ServerFacade createAndConfigureServer() {
         LOG.debug("Configuring ..");
-        ServerFacade server = null;
+        ServerFacade server;
         final ChannelInitializerFactory factory = new ChannelInitializerFactory();
         factory.setSwitchConnectionHandler(switchConnectionHandler);
         factory.setSwitchIdleTimeout(connConfig.getSwitchIdleTimeout());
@@ -145,7 +188,8 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
         boolean isEpollEnabled = Epoll.isAvailable();
 
         if (TransportProtocol.TCP.equals(transportProtocol) || TransportProtocol.TLS.equals(transportProtocol)) {
-            server = new TcpHandler(connConfig.getAddress(), connConfig.getPort());
+            server = new TcpHandler(connConfig.getAddress(), connConfig.getPort(), () -> diagStatusService
+                            .report(new ServiceDescriptor(diagStatusIdentifier, ServiceState.OPERATIONAL)));
             final TcpChannelInitializer channelInitializer = factory.createPublishingChannelInitializer();
             ((TcpHandler) server).setChannelInitializer(channelInitializer);
             ((TcpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
@@ -155,7 +199,8 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C
             connectionInitializer.setChannelInitializer(channelInitializer);
             connectionInitializer.run();
         } else if (TransportProtocol.UDP.equals(transportProtocol)) {
-            server = new UdpHandler(connConfig.getAddress(), connConfig.getPort());
+            server = new UdpHandler(connConfig.getAddress(), connConfig.getPort(), () -> diagStatusService
+                    .report(new ServiceDescriptor(diagStatusIdentifier, ServiceState.OPERATIONAL)));
             ((UdpHandler) server).initiateEventLoopGroups(connConfig.getThreadConfiguration(), isEpollEnabled);
             ((UdpHandler) server).setChannelInitializer(factory.createUdpChannelInitializer());
         } else {
index 0a48de11c2d37db1d14513091c39a53a7da7a001..46dfd14d40cbec1b26c3407f8ac3ac04af3d25d4 100644 (file)
@@ -51,6 +51,7 @@ public class TcpHandler implements ServerFacade {
     private int port;
     private String address;
     private final InetAddress startupAddress;
+    private final Runnable readyRunnable;
     private EventLoopGroup workerGroup;
     private EventLoopGroup bossGroup;
     private final SettableFuture<Boolean> isOnlineFuture;
@@ -65,8 +66,8 @@ public class TcpHandler implements ServerFacade {
      *
      * @param port listening port of TCPHandler server
      */
-    public TcpHandler(final int port) {
-        this(null, port);
+    public TcpHandler(final int port, Runnable readyRunnable) {
+        this(null, port, readyRunnable);
     }
 
     /**
@@ -74,10 +75,11 @@ public class TcpHandler implements ServerFacade {
      * @param address listening address of TCPHandler server
      * @param port listening port of TCPHandler server
      */
-    public TcpHandler(final InetAddress address, final int port) {
+    public TcpHandler(final InetAddress address, final int port, Runnable readyRunnable) {
         this.port = port;
         this.startupAddress = address;
         isOnlineFuture = SettableFuture.create();
+        this.readyRunnable = readyRunnable;
     }
 
     /**
@@ -131,6 +133,10 @@ public class TcpHandler implements ServerFacade {
             LOG.debug("address from tcphandler: {}", address);
             isOnlineFuture.set(true);
             LOG.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port);
+
+            readyRunnable.run();
+
+            // This waits until this channel is closed, and rethrows the cause of the failure if this future failed.
             f.channel().closeFuture().sync();
         } catch (InterruptedException e) {
             LOG.error("Interrupted while waiting for port {} shutdown", port, e);
index 144037dab7e8be32d94904024adb53e9e886e5fc..32f164be9c8b5342c43eacdef9f5f58e74ab50ce 100644 (file)
@@ -32,11 +32,12 @@ import org.slf4j.LoggerFactory;
  */
 public final class UdpHandler implements ServerFacade {
 
-    private static final Logger LOG = LoggerFactory
-            .getLogger(UdpHandler.class);
+    private static final Logger LOG = LoggerFactory.getLogger(UdpHandler.class);
+
     private int port;
     private EventLoopGroup group;
     private final InetAddress startupAddress;
+    private final Runnable readyRunnable;
     private final SettableFuture<Boolean> isOnlineFuture;
     private UdpChannelInitializer channelInitializer;
     private ThreadConfiguration threadConfig;
@@ -47,8 +48,8 @@ public final class UdpHandler implements ServerFacade {
      *
      * @param port listening port of UdpHandler server
      */
-    public UdpHandler(final int port) {
-        this(null, port);
+    public UdpHandler(final int port, Runnable readyRunnable) {
+        this(null, port, readyRunnable);
     }
 
     /**
@@ -56,10 +57,11 @@ public final class UdpHandler implements ServerFacade {
      * @param address listening address of UdpHandler server
      * @param port listening port of UdpHandler server
      */
-    public UdpHandler(final InetAddress address, final int port) {
+    public UdpHandler(final InetAddress address, final int port, Runnable readyRunnable) {
         this.port = port;
         this.startupAddress = address;
         isOnlineFuture = SettableFuture.create();
+        this.readyRunnable = readyRunnable;
     }
 
     @Override
@@ -90,6 +92,8 @@ public final class UdpHandler implements ServerFacade {
             LOG.debug("Address from udpHandler: {}", address);
             isOnlineFuture.set(true);
             LOG.info("Switch listener started and ready to accept incoming udp connections on port: {}", port);
+            readyRunnable.run();
+            // This waits until this channel is closed, and rethrows the cause of the failure if this future failed.
             f.channel().closeFuture().sync();
         } catch (InterruptedException e) {
             LOG.error("Interrupted while waiting for port {} shutdown", port, e);
index 3e284dd55181bb33db7fbd662640f82fffdf2164..8bbb0bc58558d4b4871de2fa13c97db2fe2bcaff 100644 (file)
@@ -55,8 +55,7 @@ public class TcpHandlerTest {
      */
     @Test
     public void testRunWithNullAddress() throws IOException, InterruptedException, ExecutionException  {
-
-        tcpHandler = new TcpHandler(null, 0);
+        tcpHandler = new TcpHandler(null, 0, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         assertEquals("failed to start server", true, startupServer(false)) ;
@@ -69,8 +68,7 @@ public class TcpHandlerTest {
      */
     @Test
     public void testRunWithNullAddressOnEpoll() throws IOException, InterruptedException, ExecutionException  {
-
-        tcpHandler = new TcpHandler(null, 0);
+        tcpHandler = new TcpHandler(null, 0, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         //Use Epoll native transport
@@ -84,8 +82,7 @@ public class TcpHandlerTest {
      */
     @Test
     public void testRunWithAddress() throws IOException, InterruptedException, ExecutionException  {
-
-        tcpHandler = new TcpHandler(serverAddress, 0);
+        tcpHandler = new TcpHandler(serverAddress, 0, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         assertEquals("failed to start server", true, startupServer(false)) ;
@@ -98,8 +95,7 @@ public class TcpHandlerTest {
      */
     @Test
     public void testRunWithAddressOnEpoll() throws IOException, InterruptedException, ExecutionException  {
-
-        tcpHandler = new TcpHandler(serverAddress, 0);
+        tcpHandler = new TcpHandler(serverAddress, 0, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         //Use Epoll native transport
@@ -114,7 +110,7 @@ public class TcpHandlerTest {
     @Test
     public void testRunWithEncryption() throws InterruptedException, IOException, ExecutionException {
         int serverPort = 28001;
-        tcpHandler = new TcpHandler(serverAddress, serverPort);
+        tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         assertEquals("failed to start server", true, startupServer(false));
@@ -133,7 +129,7 @@ public class TcpHandlerTest {
     @Test
     public void testRunWithEncryptionOnEpoll() throws InterruptedException, IOException, ExecutionException {
         int serverPort = 28001;
-        tcpHandler = new TcpHandler(serverAddress, serverPort);
+        tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { });
         tcpHandler.setChannelInitializer(mockChannelInitializer);
 
         //Use Epoll native transport
@@ -157,7 +153,7 @@ public class TcpHandlerTest {
 
         try {
             firstBinder.bind(new InetSocketAddress(serverAddress, serverPort));
-            tcpHandler = new TcpHandler(serverAddress, serverPort);
+            tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { });
             tcpHandler.setChannelInitializer(mockChannelInitializer);
             tcpHandler.initiateEventLoopGroups(null, false);
             tcpHandler.run();
@@ -177,7 +173,7 @@ public class TcpHandlerTest {
         try {
             firstBinder.bind(new InetSocketAddress(serverAddress, serverPort));
 
-            tcpHandler = new TcpHandler(serverAddress, serverPort);
+            tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { });
             tcpHandler.setChannelInitializer(mockChannelInitializer);
             //Use Epoll native transport
             tcpHandler.initiateEventLoopGroups(null, true);
index ee39fd33ceffa08b9af7eec4ed8a49802a119902..e43e93b3ff16f73664eb0b27cb86c3598c9fa77d 100755 (executable)
@@ -15,6 +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.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
@@ -58,6 +59,7 @@ 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;
@@ -86,7 +88,7 @@ public class SwitchConnectionProviderImpl02Test {
         if (protocol != null) {
             createConfig(protocol);
         }
-        provider = new SwitchConnectionProviderImpl(config);
+        provider = new SwitchConnectionProviderImpl(config, diagStatusService);
     }
 
     private void createConfig(final TransportProtocol protocol) throws UnknownHostException {
index 54bcfa304c9d1f380cf9208586eca60802ee9933..4ebdd969838c5c1b763240a206ecbe01a51ce367 100644 (file)
@@ -19,6 +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.SwitchConnectionHandler;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
@@ -37,6 +38,7 @@ import org.slf4j.LoggerFactory;
 public class SwitchConnectionProviderImplTest {
 
     @Mock SwitchConnectionHandler handler;
+    @Mock DiagStatusService diagStatusService;
 
     private static final int SWITCH_IDLE_TIMEOUT = 2000;
     private static final int WAIT_TIMEOUT = 2000;
@@ -55,7 +57,7 @@ public class SwitchConnectionProviderImplTest {
         if (protocol != null) {
             createConfig(protocol);
         }
-        provider = new SwitchConnectionProviderImpl(config);
+        provider = new SwitchConnectionProviderImpl(config, diagStatusService);
     }
 
     private void createConfig(final TransportProtocol protocol) throws UnknownHostException {
@@ -77,8 +79,8 @@ public class SwitchConnectionProviderImplTest {
      * Tests provider startup - without configuration and {@link SwitchConnectionHandler}.
      */
     @Test
-    public void testStartup1() {
-        provider = new SwitchConnectionProviderImpl(config);
+    public void testStartup1() throws UnknownHostException {
+        startUp(null);
         final ListenableFuture<Boolean> future = provider.startup();
         try {
             future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS);
index b22530b91bf7f0e7d7dba6b9d337db92d196ebf4..feeef65b4179898e34d6e3e67642dfc2d427cd59 100644 (file)
@@ -49,7 +49,7 @@ public class UdpHandlerTest {
      */
     @Test
     public void testWithEmptyAddress() throws Exception {
-        udpHandler = new UdpHandler(null, 0);
+        udpHandler = new UdpHandler(null, 0, () -> { });
         udpHandler.setChannelInitializer(udpChannelInitializerMock);
         Assert.assertTrue("Wrong - start server", startupServer(false));
         try {
@@ -66,7 +66,7 @@ public class UdpHandlerTest {
      */
     @Test
     public void testWithEmptyAddressOnEpoll() throws Exception {
-        udpHandler = new UdpHandler(null, 0);
+        udpHandler = new UdpHandler(null, 0, () -> { });
         udpHandler.setChannelInitializer(udpChannelInitializerMock);
         Assert.assertTrue("Wrong - start server", startupServer(true));
         try {
@@ -84,7 +84,7 @@ public class UdpHandlerTest {
     @Test
     public void testWithAddressAndPort() throws Exception {
         int port = 9874;
-        udpHandler = new UdpHandler(InetAddress.getLocalHost(), port);
+        udpHandler = new UdpHandler(InetAddress.getLocalHost(), port, () -> { });
         udpHandler.setChannelInitializer(udpChannelInitializerMock);
         Assert.assertTrue("Wrong - start server", startupServer(false));
         try {
@@ -102,7 +102,7 @@ public class UdpHandlerTest {
     @Test
     public void testWithAddressAndPortOnEpoll() throws Exception {
         int port = 9874;
-        udpHandler = new UdpHandler(InetAddress.getLocalHost(), port);
+        udpHandler = new UdpHandler(InetAddress.getLocalHost(), port, () -> { });
         udpHandler.setChannelInitializer(udpChannelInitializerMock);
         Assert.assertTrue("Wrong - start server", startupServer(true));
         try {
index 31d366fea1aa040d9161a05392cd86457aa0447e..92c9d64bc9df7089c15431e000ec6a0e6d5d556c 100644 (file)
@@ -17,6 +17,8 @@ import java.util.concurrent.TimeUnit;
 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.TlsConfiguration;
 import org.opendaylight.openflowjava.protocol.api.connection.TlsConfigurationImpl;
 import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
@@ -86,7 +88,7 @@ public class IntegrationTest {
         connConfig.setTransferProtocol(protocol);
         mockPlugin = new MockPlugin();
 
-        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig);
+        switchConnectionProvider = new SwitchConnectionProviderImpl(connConfig, Mockito.mock(DiagStatusService.class));
         switchConnectionProvider.setSwitchConnectionHandler(mockPlugin);
         switchConnectionProvider.startup().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
         if (protocol.equals(TransportProtocol.TCP) || protocol.equals(TransportProtocol.TLS)) {