ChannelPipeline question

Michael McGrady mmcgrady at topiatechnology.com
Tue Sep 1 09:31:32 EDT 2009


Just a more detailed thought, Fredric, on this matter.  I think you  
can use "all" with stateful handlers so long as the state is handled  
consistent with concurrent access.  I do this with my first Netty  
application, if I am understanding you correctly.  What do you think?

Mike


On Sep 1, 2009, at 3:32 AM, Frederic Bregier wrote:

>
> Hi Mike,
>
> If I made some mistake, please correct me of course ;-)
>
> "all" means that several channels can shared this handler (stateless).
> "one" means that this handler is for one and only one channel  
> (stateful).
>
> bootstrap.getPipeline() => if you add handlers there, they should be  
> "all"
> since the pipeline will be shared by all channels that will connect  
> or be
> connected through this bootstrap.
>
> In a ChannelPipelineFactory, you can mixed "all" and "one" handlers.  
> For
> instance, if you have a handler that can be shared among all  
> channels, then
> even included from the factory, it could be "all". On the opposite,  
> usualy
> you have at least 1 handler that is "one" in such a construction  
> (generally
> the codecd that is a stateful one).
> The pipeline will be new for each new channel, but the handlers you  
> put in
> it can be shared (statically created in the Factory and reused so  
> "all") or
> unique by channel (created in the getPipeline() method so "one").
> If all handlers are "all", then I think it is better to use the  
> bootstrap
> version since there will be only one Pipeline shared among all  
> channels with
> the same handlers. But if you have at least one "one" handler  
> (stateful),
> then it is preferable to use the ChannelPipelineFactory.
>
> Or you can added it at runtime (in channelConnected for instance)  
> manually.
> Again, the added handler can be "all" (static and reused) or  
> "one" (new one
> created).
> I feel like, even if it is correct, it somehow less easy to read  
> such a code
> since the we don't know where such handlers are added or not. But in  
> some
> occasion, you don't have the choice (for instance, a new handler is  
> needed
> once the channel is connected for some specific behaviour).
>
> HTH,
>
> Cheers,
> Frederic
>
>
> MikeQ wrote:
>>
>> Hi all,
>>
>> Quick q about @ChannelPipelineCoverage and setup of handlers.
>>
>> As far as I can tell when setting up a new pipeline you have a  
>> couple of
>> options.
>>
>> - Adding handlers using bootstrap.getPipeline()
>>    - I believe in this instance all the handlers are singletons (one
>> shared by all channels) and must therefore be
>> @ChannelPipelineCoverage("all")
>>
>> - Adding handlers using a ChannelPipelineFactory
>>    - I believe the ChannelPipelineFactory.getPipeline() is called for
>> each new channel.  The handlers can therefore be one/all depending on
>> whether the getPipeline() implementation creates a new instance  
>> each time
>> (one) or uses a shared instance (all)
>>
>> - Adding handlers during execution of another handler
>>    - Similar to ChannelPipelineFactory in that a new instance or  
>> shared
>> instance can be used
>>
>> If someone could confirm/correct the above that would be useful for  
>> my own
>> understanding.
>>
>> Cheers.
>>
>
>
> -----
> Hardware/Software Architect
> -- 
> View this message in context: http://n2.nabble.com/ChannelPipeline-question-tp3559391p3559650.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

Mike McGrady
Principal Investigator AF081-028 AFRL SBIR
Senior Engineer
Topia Technology, Inc
1.253.720.3365
mmcgrady at topiatechnology.com









More information about the netty-users mailing list