Puzzle in org.jboss.netty.example.local.LocalServerPipelineFactory.java
Peng Fei Di
dipengfei1982 at gmail.com
Sat Apr 3 12:37:57 EDT 2010
Hi all,
As Trustin said in the api of ExecutionHandler, the executionHandler
instance must be shared in the method getPipeline(), just like below code:
public class DatabaseGatewayPipelineFactory implements
ChannelPipelineFactory {
private final ExecutionHandler executionHandler;
public DatabaseGatewayPipelineFactory(ExecutionHandler
executionHandler) {
this.executionHandler = executionHandler;
}
public ChannelPipeline getPipeline() {
return Channels.pipeline(
new DatabaseGatewayProtocolEncoder(),
new DatabaseGatewayProtocolDecoder(),
executionHandler, // Must be shared
new DatabaseQueryingHandler());
}
}
...
public static void main(String[] args) {
ServerBootstrap bootstrap = ...;
...
ExecutionHandler executionHandler = new ExecutionHandler(
new OrderedMemoryAwareThreadPoolExecutor(16, 1048576, 1048576))
bootstrap.setPipelineFactory(
new DatabaseGatewayPipelineFactory(executionHandler));
...
bootstrap.bind(...);
...
while (!isServerReadyToShutDown()) {
// ... wait ...
}
bootstrap.releaseExternalResources();
executionHandler.releaseExternalResources();
}
But in org.jboss.netty.example.local.LocalServerPipelineFactory.java(line
50), I found that the executionHandler instance will be created and added
into the pipeline everytime in the method getPipeline() althought all these
executionHandler instances will share the same eventExecutor.
So I am thinking about whether the LocalServerPipelineFactory.java is ok. I
want to know whether the executionHandler instance should be shared, or we
just only need to share the eventExecutor instance? And is there any
difference between them?
Thanks!
Best regards
--
View this message in context: http://n2.nabble.com/Puzzle-in-org-jboss-netty-example-local-LocalServerPipelineFactory-java-tp4847510p4847510.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list