import java.net.InetAddress;
import java.net.InetSocketAddress;
-import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade;
+import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.util.concurrent.SettableFuture;
/**
- * Class implementing server over TCP for handling incoming connections.
+ * Class implementing server over TCP / TLS for handling incoming connections.
*
* @author michal.polkorab
*/
private NioEventLoopGroup workerGroup;
private NioEventLoopGroup bossGroup;
private final SettableFuture<Boolean> isOnlineFuture;
+ private ThreadConfiguration threadConfig;
- private PublishingChannelInitializer channelInitializer;
+ private TcpChannelInitializer channelInitializer;
/**
* Constructor of TCPHandler that listens on selected port.
*/
@Override
public void run() {
- bossGroup = new NioEventLoopGroup();
- workerGroup = new NioEventLoopGroup();
-
/*
* We generally do not perform IO-unrelated tasks, so we want to have
* all outstanding tasks completed before the executing thread goes
LOGGER.debug("address from tcphandler: {}", address);
isOnlineFuture.set(true);
- LOGGER.info("Switch listener started and ready to accept incoming connections on port: {}", port);
+ LOGGER.info("Switch listener started and ready to accept incoming tcp/tls connections on port: {}", port);
f.channel().closeFuture().sync();
} catch (InterruptedException e) {
LOGGER.error("Interrupted while waiting for port {} shutdown", port, e);
/**
* @param channelInitializer
*/
- public void setChannelInitializer(PublishingChannelInitializer channelInitializer) {
+ public void setChannelInitializer(TcpChannelInitializer channelInitializer) {
this.channelInitializer = channelInitializer;
}
+ @Override
+ public void setThreadConfig(ThreadConfiguration threadConfig) {
+ this.threadConfig = threadConfig;
+ }
+
+ /**
+ * Initiate event loop groups
+ * @param threadConfiguration number of threads to be created, if not specified in threadConfig
+ */
+ public void initiateEventLoopGroups(ThreadConfiguration threadConfiguration) {
+ if (threadConfiguration != null) {
+ bossGroup = new NioEventLoopGroup(threadConfiguration.getBossThreadCount());
+ workerGroup = new NioEventLoopGroup(threadConfiguration.getWorkerThreadCount());
+ } else {
+ bossGroup = new NioEventLoopGroup();
+ workerGroup = new NioEventLoopGroup();
+ }
+ }
+
+ /**
+ * @return workerGroup
+ */
+ public NioEventLoopGroup getWorkerGroup() {
+ return workerGroup;
+ }
+
}