From 10ad385a19ce8d8ceed884b4ef9b8ff97cf17295 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Thu, 23 May 2024 13:57:03 +0200 Subject: [PATCH] Change getIsOnlineFuture() return type Provising a Boolean is superfluous -- we are just reporting success/failure. Clean this up by using Void as the return type. Change-Id: I7e292941a59f255d27df25828f6848bfc6b8059e Signed-off-by: Robert Varga (cherry picked from commit 5a64f2402b8af587dec4c692c57b44563368b463) --- .../protocol/impl/core/OnlineProvider.java | 4 +- .../core/SwitchConnectionProviderImpl.java | 2 +- .../impl/core/TcpConnectionInitializer.java | 9 ++-- .../protocol/impl/core/TcpHandler.java | 11 ++-- .../protocol/impl/core/UdpHandler.java | 11 ++-- .../protocol/impl/core/TcpHandlerTest.java | 16 +++--- .../SwitchConnectionProviderImpl02Test.java | 21 ++++---- .../SwitchConnectionProviderImplTest.java | 15 +++--- .../impl/core/connection/UdpHandlerTest.java | 53 +++++++------------ .../connection/SwitchConnectionProvider.java | 4 +- .../impl/OpenFlowPluginProviderImpl.java | 4 +- .../impl/OpenFlowPluginProviderImplTest.java | 2 +- 12 files changed, 64 insertions(+), 88 deletions(-) diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java index c167dfb7f4..370ea160a9 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/OnlineProvider.java @@ -5,8 +5,6 @@ * 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 com.google.common.util.concurrent.ListenableFuture; @@ -18,5 +16,5 @@ import com.google.common.util.concurrent.ListenableFuture; */ public interface OnlineProvider { - ListenableFuture getIsOnlineFuture(); + ListenableFuture getIsOnlineFuture(); } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java index 0cf73dd31c..abd3af6eb8 100755 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/SwitchConnectionProviderImpl.java @@ -153,7 +153,7 @@ public class SwitchConnectionProviderImpl implements SwitchConnectionProvider, C @Override @SuppressWarnings("checkstyle:IllegalCatch") - public ListenableFuture startup() { + public ListenableFuture startup() { LOG.debug("Startup summoned"); try { serverFacade = createAndConfigureServer(); diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java index 869f92d62d..3549540889 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpConnectionInitializer.java @@ -24,12 +24,11 @@ import org.slf4j.LoggerFactory; * @author martin.uhlir */ public class TcpConnectionInitializer implements ServerFacade, ConnectionInitializer { - private static final Logger LOG = LoggerFactory.getLogger(TcpConnectionInitializer.class); + private final SettableFuture hasRun = SettableFuture.create(); private final EventLoopGroup workerGroup; private final boolean isEpollEnabled; - private final SettableFuture hasRun = SettableFuture.create(); private TcpChannelInitializer channelInitializer; private Bootstrap bootstrap; @@ -52,18 +51,18 @@ public class TcpConnectionInitializer implements ServerFacade, ConnectionInitial } else { bootstrap.group(workerGroup).channel(NioSocketChannel.class).handler(channelInitializer); } - hasRun.set(true); + hasRun.set(null); } @Override public ListenableFuture shutdown() { - final SettableFuture result = SettableFuture.create(); + final var result = SettableFuture.create(); workerGroup.shutdownGracefully(); return result; } @Override - public ListenableFuture getIsOnlineFuture() { + public ListenableFuture getIsOnlineFuture() { return hasRun; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java index f4b0e162ed..ca797a4d12 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandler.java @@ -48,13 +48,14 @@ public class TcpHandler implements ServerFacade { private static final Logger LOG = LoggerFactory.getLogger(TcpHandler.class); - private int port; - private String address; + private final SettableFuture isOnlineFuture = SettableFuture.create(); private final InetAddress startupAddress; private final Runnable readyRunnable; + + private int port; + private String address; private EventLoopGroup workerGroup; private EventLoopGroup bossGroup; - private final SettableFuture isOnlineFuture = SettableFuture.create(); private TcpChannelInitializer channelInitializer; @@ -136,7 +137,7 @@ public class TcpHandler implements ServerFacade { LOG.debug("address from tcphandler: {}", address); LOG.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port); readyRunnable.run(); - isOnlineFuture.set(true); + isOnlineFuture.set(null); // This waits until this channel is closed, and rethrows the cause of the failure if this future failed. f.channel().closeFuture().sync(); @@ -174,7 +175,7 @@ public class TcpHandler implements ServerFacade { } @Override - public ListenableFuture getIsOnlineFuture() { + public ListenableFuture getIsOnlineFuture() { return isOnlineFuture; } diff --git a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java index 2856549d48..1c59efd7cd 100644 --- a/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java +++ b/openflowjava/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/UdpHandler.java @@ -31,15 +31,14 @@ import org.slf4j.LoggerFactory; * @author michal.polkorab */ public final class UdpHandler implements ServerFacade { - private static final Logger LOG = LoggerFactory.getLogger(UdpHandler.class); - private int port; - private EventLoopGroup group; + private final SettableFuture isOnlineFuture = SettableFuture.create(); private final InetAddress startupAddress; private final Runnable readyRunnable; - private final SettableFuture isOnlineFuture = SettableFuture.create(); + private int port; + private EventLoopGroup group; private UdpChannelInitializer channelInitializer; private Class datagramChannelClass; @@ -96,7 +95,7 @@ public final class UdpHandler implements ServerFacade { LOG.debug("Address from udpHandler: {}", address); LOG.info("Switch listener started and ready to accept incoming udp connections on port: {}", port); readyRunnable.run(); - isOnlineFuture.set(true); + isOnlineFuture.set(null); // This waits until this channel is closed, and rethrows the cause of the failure if this future failed. f.channel().closeFuture().sync(); @@ -120,7 +119,7 @@ public final class UdpHandler implements ServerFacade { } @Override - public ListenableFuture getIsOnlineFuture() { + public ListenableFuture getIsOnlineFuture() { return isOnlineFuture; } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java index a767bfa8c0..700b376f20 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/TcpHandlerTest.java @@ -146,14 +146,12 @@ public class TcpHandlerTest { int serverPort = 28001; Socket firstBinder = new Socket(); - try { + try (firstBinder) { firstBinder.bind(new InetSocketAddress(serverAddress, serverPort)); tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { }); tcpHandler.setChannelInitializer(mockChannelInitializer); tcpHandler.initiateEventLoopGroups(null, false); tcpHandler.run(); - } finally { - firstBinder.close(); } } @@ -165,7 +163,7 @@ public class TcpHandlerTest { int serverPort = 28001; Socket firstBinder = new Socket(); - try { + try (firstBinder) { firstBinder.bind(new InetSocketAddress(serverAddress, serverPort)); tcpHandler = new TcpHandler(serverAddress, serverPort, () -> { }); @@ -176,8 +174,6 @@ public class TcpHandlerTest { fail("Expected BindException or Errors.NativeIoException"); } catch (BindException | Errors.NativeIoException e) { // expected - } finally { - firstBinder.close(); } } @@ -192,8 +188,8 @@ public class TcpHandlerTest { assertEquals("shutdown failed", true, shutdownRet.get()); } - private Boolean startupServer(boolean isEpollEnabled) throws InterruptedException { - ListenableFuture online = tcpHandler.getIsOnlineFuture(); + private Boolean startupServer(final boolean isEpollEnabled) throws InterruptedException { + final var online = tcpHandler.getIsOnlineFuture(); /** * Test EPoll based native transport if isEpollEnabled is true. * Else use Nio based transport. @@ -204,10 +200,10 @@ public class TcpHandlerTest { while (online.isDone() != true && retry++ < 20) { Thread.sleep(100); } - return online.isDone() ; + return online.isDone(); } - private static Boolean clientConnection(int port) throws IOException { + private static Boolean clientConnection(final int port) throws IOException { // Connect, and disconnect Socket socket = new Socket(InetAddress.getLoopbackAddress(), port); Boolean result = socket.isConnected(); diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java index 035efd39ab..a2b0daa166 100755 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImpl02Test.java @@ -7,7 +7,9 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import com.google.common.util.concurrent.ListenableFuture; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; @@ -36,7 +38,6 @@ import org.opendaylight.openflowjava.protocol.api.keys.MatchEntrySerializerKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey; import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey; import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants; -import org.opendaylight.openflowjava.protocol.impl.core.ServerFacade; import org.opendaylight.openflowjava.protocol.impl.core.SwitchConnectionProviderImpl; import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.ExperimenterActionSubType; @@ -115,9 +116,9 @@ public class SwitchConnectionProviderImpl02Test { @Test public void testServerFacade() throws UnknownHostException { startUp(TransportProtocol.TCP); - final ListenableFuture future = provider.startup(); - final ServerFacade serverFacade = provider.getServerFacade(); - Assert.assertNotNull("Wrong -- getServerFacade return null",serverFacade); + final var future = provider.startup(); + final var serverFacade = provider.getServerFacade(); + assertNotNull("Wrong -- getServerFacade return null", serverFacade); } /** @@ -135,12 +136,10 @@ public class SwitchConnectionProviderImpl02Test { @Test public void testUnregisterWrongKeys() throws UnknownHostException { startUp(TransportProtocol.TCP); - final ExperimenterInstructionSerializerKey testSerKey - = new ExperimenterInstructionSerializerKey(EncodeConstants.OF_VERSION_1_0, 42L); - Assert.assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey)); - final ExperimenterInstructionDeserializerKey tesDeserKey - = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF_VERSION_1_0, 24L); - Assert.assertFalse("Wrong -- unregisterDeserializer",provider.unregisterDeserializer(tesDeserKey)); + final var testSerKey = new ExperimenterInstructionSerializerKey(EncodeConstants.OF_VERSION_1_0, 42L); + assertFalse("Wrong -- unregisterSerializer",provider.unregisterSerializer(testSerKey)); + final var tesDeserKey = new ExperimenterInstructionDeserializerKey(EncodeConstants.OF_VERSION_1_0, 24L); + assertFalse("Wrong -- unregisterDeserializer",provider.unregisterDeserializer(tesDeserKey)); } /** diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java index 972970603a..f5fbe8bf36 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/SwitchConnectionProviderImplTest.java @@ -16,7 +16,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; -import com.google.common.util.concurrent.ListenableFuture; import java.net.InetAddress; import java.net.UnknownHostException; import java.util.List; @@ -94,7 +93,7 @@ public class SwitchConnectionProviderImplTest { @Test public void testStartup1() throws UnknownHostException { startUp(null); - final ListenableFuture future = provider.startup(); + final var future = provider.startup(); final var cause = assertThrows(ExecutionException.class, () -> future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) .getCause(); @@ -109,7 +108,7 @@ public class SwitchConnectionProviderImplTest { public void testStartup2() throws UnknownHostException { startUp(null); provider.setSwitchConnectionHandler(handler); - final ListenableFuture future = provider.startup(); + final var future = provider.startup(); final var cause = assertThrows(ExecutionException.class, () -> future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) .getCause(); @@ -123,7 +122,7 @@ public class SwitchConnectionProviderImplTest { @Test public void testStartup3() throws UnknownHostException { startUp(TransportProtocol.TCP); - final ListenableFuture future = provider.startup(); + final var future = provider.startup(); final var cause = assertThrows(ExecutionException.class, () -> future.get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)) .getCause(); @@ -139,7 +138,7 @@ public class SwitchConnectionProviderImplTest { startUp(TransportProtocol.TCP); provider.setSwitchConnectionHandler(handler); - assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } /** @@ -150,7 +149,7 @@ public class SwitchConnectionProviderImplTest { startUp(TransportProtocol.TLS); provider.setSwitchConnectionHandler(handler); - assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } /** @@ -161,7 +160,7 @@ public class SwitchConnectionProviderImplTest { startUp(TransportProtocol.UDP); provider.setSwitchConnectionHandler(handler); - assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); } /** @@ -172,7 +171,7 @@ public class SwitchConnectionProviderImplTest { startUp(TransportProtocol.TCP); provider.setSwitchConnectionHandler(handler); - assertTrue("Failed to start", provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); + provider.startup().get(WAIT_TIMEOUT, TimeUnit.MILLISECONDS); assertTrue("Failed to stop", provider.shutdown().get(5 * WAIT_TIMEOUT, TimeUnit.MILLISECONDS)); } } diff --git a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java index 871e2adf6a..cb2e53fb8c 100644 --- a/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java +++ b/openflowjava/openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/core/connection/UdpHandlerTest.java @@ -7,12 +7,14 @@ */ package org.opendaylight.openflowjava.protocol.impl.core.connection; -import com.google.common.util.concurrent.ListenableFuture; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import java.net.InetAddress; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; @@ -43,13 +45,9 @@ public class UdpHandlerTest { public void testWithEmptyAddress() throws Exception { udpHandler = new UdpHandler(null, 0, () -> { }); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer(false)); - try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500, TimeUnit.MILLISECONDS)); - } catch (TimeoutException e) { - Assert.fail("Wrong - getIsOnlineFuture timed out"); - } - Assert.assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); + assertTrue("Wrong - start server", startupServer(false)); + udpHandler.getIsOnlineFuture().get(1500, TimeUnit.MILLISECONDS); + assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); shutdownServer(); } @@ -60,13 +58,9 @@ public class UdpHandlerTest { public void testWithEmptyAddressOnEpoll() throws Exception { udpHandler = new UdpHandler(null, 0, () -> { }); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer(true)); - try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); - } catch (TimeoutException e) { - Assert.fail("Wrong - getIsOnlineFuture timed out"); - } - Assert.assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); + assertTrue("Wrong - start server", startupServer(true)); + udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS); + assertFalse("Wrong - port has been set to zero", udpHandler.getPort() == 0); shutdownServer(); } @@ -78,13 +72,9 @@ public class UdpHandlerTest { int port = 9874; udpHandler = new UdpHandler(InetAddress.getLocalHost(), port, () -> { }); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer(false)); - try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); - } catch (TimeoutException e) { - Assert.fail("Wrong - getIsOnlineFuture timed out"); - } - Assert.assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); + assertTrue("Wrong - start server", startupServer(false)); + udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS); + assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); shutdownServer(); } @@ -96,19 +86,15 @@ public class UdpHandlerTest { int port = 9874; udpHandler = new UdpHandler(InetAddress.getLocalHost(), port, () -> { }); udpHandler.setChannelInitializer(udpChannelInitializerMock); - Assert.assertTrue("Wrong - start server", startupServer(true)); - try { - Assert.assertTrue(udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS)); - } catch (TimeoutException e) { - Assert.fail("Wrong - getIsOnlineFuture timed out"); - } - Assert.assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); + assertTrue("Wrong - start server", startupServer(true)); + udpHandler.getIsOnlineFuture().get(1500,TimeUnit.MILLISECONDS); + assertEquals("Wrong - bad port number has been set", port, udpHandler.getPort()); shutdownServer(); } private Boolean startupServer(final boolean isEpollEnabled) throws InterruptedException, ExecutionException { - ListenableFuture online = udpHandler.getIsOnlineFuture(); + final var online = udpHandler.getIsOnlineFuture(); /** * Test EPoll based native transport if isEpollEnabled is true. * Else use Nio based transport. @@ -126,8 +112,7 @@ public class UdpHandlerTest { } private void shutdownServer() throws InterruptedException, ExecutionException, TimeoutException { - ListenableFuture shutdownRet = udpHandler.shutdown() ; - final Boolean shutdownSucceeded = shutdownRet.get(10, TimeUnit.SECONDS); - Assert.assertTrue("Wrong - shutdown failed", shutdownSucceeded); + final var shutdownRet = udpHandler.shutdown() ; + assertTrue("Wrong - shutdown failed", shutdownRet.get(10, TimeUnit.SECONDS)); } } diff --git a/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java b/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java index f63e21c9e8..cab8051c16 100644 --- a/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java +++ b/openflowjava/openflow-protocol-spi/src/main/java/org/opendaylight/openflowjava/protocol/spi/connection/SwitchConnectionProvider.java @@ -33,9 +33,9 @@ public interface SwitchConnectionProvider extends AutoCloseable, * Start listening to switches, but please don't forget to do * {@link #setSwitchConnectionHandler(SwitchConnectionHandler)} first. * - * @return future, triggered to true, when listening channel is up and running + * @return future completing when the channel has been resolved */ - ListenableFuture startup(); + ListenableFuture startup(); /** * Stop listening to switches. diff --git a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java index 95246cc626..b841e72c82 100644 --- a/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java +++ b/openflowplugin-impl/src/main/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImpl.java @@ -215,9 +215,9 @@ public final class OpenFlowPluginProviderImpl // Set handler of incoming connections and start switch connection provider switchConnectionProvider.setSwitchConnectionHandler(connectionManager); return switchConnectionProvider.startup(); - }).collect(Collectors.toSet())), new FutureCallback>() { + }).collect(Collectors.toSet())), new FutureCallback>() { @Override - public void onSuccess(final List result) { + public void onSuccess(final List result) { LOG.info("All switchConnectionProviders are up and running ({}).", result.size()); diagStatusProvider.reportStatus(ServiceState.OPERATIONAL); fullyStarted.set(null); diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java index 2c421e6ff4..9480822833 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/OpenFlowPluginProviderImplTest.java @@ -77,7 +77,7 @@ public class OpenFlowPluginProviderImplTest { when(dataBroker.newWriteOnlyTransaction()).thenReturn(writeTransaction); doReturn(CommitInfo.emptyFluentFuture()).when(writeTransaction).commit(); when(entityOwnershipService.registerListener(any(), any())).thenReturn(entityOwnershipListenerRegistration); - when(switchConnectionProvider.startup()).thenReturn(Futures.immediateFuture(true)); + when(switchConnectionProvider.startup()).thenReturn(Futures.immediateFuture(null)); when(switchConnectionProvider.shutdown()).thenReturn(Futures.immediateFuture(true)); when(configurationService.getProperty(eq(ConfigurationProperty.USE_SINGLE_LAYER_SERIALIZATION.toString()), any())).thenReturn(USE_SINGLE_LAYER_SERIALIZATION); -- 2.36.6