ChannelPipeline question

Mike McGrady mmcgrady at topiatechnology.com
Wed Sep 9 23:28:02 EDT 2009


I think that "all" and "one" are plenty as long as people understand  
that they must maintain state consistent with concurrent access when  
it is "all".  There are many ways this can happen.

Sent from my iPhone

On Sep 9, 2009, at 8:19 PM, 이희승 (Trustin Lee) <trustin at gmail.com>  
wrote:

> If you do maintain the state of the handler for each
> ChannelHandlerContext, then it could be annotated with
> ChannelPipelineCoverage("all").
>
> The KarmaDecoder seems to maintain the map with the key type  
> 'Channel',
> which means the same handler instance cannot be added to the same
> pipeline.  That is, it's somewhere between 'all' and 'one'.
>
> This ambiguity can be resolve by using ChannelHandlerContext as a key
> instead of Channel.
>
> I will revise the Javadoc that a handler with 'all' scope should be
> able to handle this case.  I'm not sure if we need to add another
> annotation value such as 'somewhere between all and one' ('channel'?).
> Any idea?
>
> On Tue, 1 Sep 2009 22:31:32 +0900 (KST)
> Michael McGrady <mmcgrady at topiatechnology.com> wrote:
>> 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
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>
>
>
> -- 
> Trustin Lee, http://gleamynode.net/
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users



More information about the netty-users mailing list