* @return seed for {@link SSLEngine}
*/
public Object getSslContext();
-
-}
+
+ /**
+ * @return thread numbers for TcpHandler's eventloopGroups
+ */
+ public ThreadConfiguration getThreadConfiguration();
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2014 Pantheon Technologies s.r.o. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+\r
+package org.opendaylight.openflowjava.protocol.api.connection;\r
+\r
+/**\r
+ * @author michal.polkorab\r
+ *\r
+ */\r
+public interface ThreadConfiguration {\r
+\r
+ /**\r
+ * @return desired number of workerThreads processing the Openflow I/O\r
+ */\r
+ public int getWorkerThreadCount();\r
+\r
+ /**\r
+ * @return desired number of bossThreads registering incomming Openflow connections\r
+ */\r
+ public int getBossThreadCount();\r
+}\r
factory.setSerializationFactory(serializationFactory);
factory.setDeserializationFactory(deserializationFactory);
server.setChannelInitializer(factory.createPublishingChannelInitializer());
+ server.setThreadConfig(connConfig.getThreadConfiguration());
return server;
}
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
import org.opendaylight.openflowjava.protocol.impl.connection.ServerFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private NioEventLoopGroup workerGroup;
private NioEventLoopGroup bossGroup;
private final SettableFuture<Boolean> isOnlineFuture;
+ private ThreadConfiguration threadConfig;
private PublishingChannelInitializer channelInitializer;
*/
@Override
public void run() {
- bossGroup = new NioEventLoopGroup();
- workerGroup = new NioEventLoopGroup();
+ if (threadConfig != null) {
+ bossGroup = new NioEventLoopGroup(threadConfig.getBossThreadCount());
+ workerGroup = new NioEventLoopGroup(threadConfig.getWorkerThreadCount());
+ } else {
+ bossGroup = new NioEventLoopGroup();
+ workerGroup = new NioEventLoopGroup();
+ }
/*
* We generally do not perform IO-unrelated tasks, so we want to have
this.channelInitializer = channelInitializer;
}
+ /**
+ * @param threadConfig EventLoopGroup configuration
+ */
+ public void setThreadConfig(ThreadConfiguration threadConfig) {
+ this.threadConfig = threadConfig;
+ }
}
import java.net.UnknownHostException;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
import org.opendaylight.openflowjava.protocol.impl.connection.SwitchConnectionProviderImpl;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
final Integer port = getPort();
final long switchIdleTimeout = getSwitchIdleTimeout();
final Tls tlsConfig = getTls();
+ final Threads threads = getThreads();
return new ConnectionConfiguration() {
@Override
// TODO Auto-generated method stub
return null;
}
+ @Override
+ public ThreadConfiguration getThreadConfiguration() {
+ if (threads == null) {
+ return null;
+ }
+ return new ThreadConfiguration() {
+
+ @Override
+ public int getWorkerThreadCount() {
+ return threads.getWorkerThreads();
+ }
+
+ @Override
+ public int getBossThreadCount() {
+ return threads.getBossThreads();
+ }
+ };
+ }
};
}
type string;
}
}
+ container threads {
+ leaf boss-threads {
+ type uint16;
+ }
+ leaf worker-threads {
+ type uint16;
+ }
+ }
}
}
}
\ No newline at end of file
import java.net.InetAddress;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionConfiguration;
+import org.opendaylight.openflowjava.protocol.api.connection.ThreadConfiguration;
import org.opendaylight.openflowjava.protocol.api.connection.TlsConfiguration;
/**
private Object transferProtocol;
private TlsConfiguration tlsConfig;
private long switchIdleTimeout;
+ private ThreadConfiguration threadConfig;
/**
* Creates {@link ConnectionConfigurationImpl}
return tlsConfig;
}
-}
+ @Override
+ public ThreadConfiguration getThreadConfiguration() {
+ return threadConfig;
+ }
+
+ /**
+ * @param threadConfig thread model configuration (configures threads used)
+ */
+ public void setThreadConfiguration(ThreadConfiguration threadConfig) {
+ this.threadConfig = threadConfig;
+ }
+}
\ No newline at end of file