我尝试了以下关于连接和工作人员的组合
我的软件配置 使用NioServerSocket的Netty 3.2.6
管道摘要
public void startServer(int numWorkerThreads, String openFlowHost, int openFlowPort, OFChannelHandler ofchan){
this.workerThreads = numWorkerThreads;
try {
final ServerBootstrap bootstrap = createServerBootStrap();
bootstrap.setOption("reuseAddr", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.receiveBufferSize", EnhancedController.RECEIVE_BUFFER_SIZE);
bootstrap.setOption("child.sendBufferSize", EnhancedController.SEND_BUFFER_SIZE);
// better to have an receive buffer predictor
//bootstrap.setOption("receiveBufferSizePredictorFactory",
// new AdaptiveReceiveBufferSizePredictorFactory());
//if the server is sending 1000 messages per sec, optimum write buffer water marks will
//prevent unnecessary throttling, Check NioSocketChannelConfig doc
//bootstrap.setOption("writeBufferLowWaterMark", WRITE_BUFFER_LOW_WATERMARK);
//bootstrap.setOption("writeBufferHighWaterMark", WRITE_BUFFER_HIGH_WATERMARK);
// TODO: IMPORTANT: If the threadpool is supplied as null, ExecutionHandler would
// not be present in pipeline. If the load increases and ordering is required ,
// use OrderedMemoryAwareThreadPoolExecutor as argument instead of null
execHandler = new OrderedMemoryAwareThreadPoolExecutor(
OMATPE_CORE_POOL_SIZE,
OMATPE_PER_CHANNEL_SIZE,
OMATPE_POOL_WIDE_SIZE,
OMATPE_THREAD_KEEP_ALIVE_IN_MILLISECONDS,
TimeUnit.MILLISECONDS);
ChannelPipelineFactory pfact =
new OpenflowPipelineFactory(controller, execHandler);
bootstrap.setPipelineFactory(pfact);
InetSocketAddress sa =
(openFlowHost == null)
? new InetSocketAddress(openFlowPort)
: new InetSocketAddress(openFlowHost, openFlowPort);
final ChannelGroup cg = new DefaultChannelGroup();
cg.add(bootstrap.bind(sa));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
private ServerBootstrap createServerBootStrap() {
if (workerThreads == 0) {
return new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool()));
} else {
return new ServerBootstrap(
new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool(), workerThreads));
}
}
硬件配置 采用Ubuntu 11.x的四核英特尔i5 vPro
如果我遗漏了一些明显的东西,请告诉我