You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Ashish <pa...@gmail.com> on 2013/07/28 13:30:14 UTC

Read/Write Filterchain

Folks,

I am a little lost in this section. How to set IoFilter/Codecs for
Read/Write chain. I need different sequence for Read and Write path at
Server side for the examples I am working on.

Any suggestions/examples that I can use.

-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Read/Write Filterchain

Posted by Julien Vermillard <jv...@gmail.com>.
On Mon, Jul 29, 2013 at 3:01 PM, Ashish <pa...@gmail.com> wrote:
> On Mon, Jul 29, 2013 at 6:24 PM, Julien Vermillard <jv...@gmail.com>wrote:
>
>> On Mon, Jul 29, 2013 at 11:52 AM, Ashish <pa...@gmail.com> wrote:
>> > On Mon, Jul 29, 2013 at 3:15 PM, Julien Vermillard <
>> jvermillard@gmail.com>wrote:
>> >
>> >> On Sun, Jul 28, 2013 at 4:20 PM, Ashish <pa...@gmail.com>
>> wrote:
>> >> > On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <
>> >> jvermillard@gmail.com>wrote:
>> >> >
>> >> >> Hi,
>> >> >> Just  make a filter handling read,but bypass for write
>> >> >> and a filter handling write but bypass for read.
>> >> >>
>> >> >> If you extends AbstractIoFilter you just need to implement the needed
>> >> >> event for each filter.
>> >> >>
>> >> >>
>> >> > Got it.. Did we dropped the idea of having different filter chains for
>> >> > read/write?
>> >> >
>> >>
>> >> Yes, for the sake of simplicity: most of time if you transform in one
>> >> way, you need to do
>> >> it in the other way.
>> >>
>> >
>> > I might have missed the discussion for this. I am getting older :)
>> > What about the order in which it would be executed? Is it same as added
>> in
>> > chain like in MINA 2.0 or the other way round.
>>
>> The order is the same as MINA 2: read/open/close/idle/exception left
>> to right, write right to left.
>>
>
> I meant, if I have a Filter chain like
>
> Filter 1 -> Filter 2 - > IoHandler
>
> So a Read chain would be same as filter chain above. So when I write from
> IoHandler, would the sequence of processing be Filter 1 -> Filter 2
>
> or IoHandler -> Filter 2 -> Filter 1

this one :)
read/close/open/idle/exception : f1->f2->IoHandler
write : f2(messagewriting)->f1(messagewriting)-> socket then IoHandler
messageSent
>
>
>
>>
>> >
>> > We also need an example with Codecs. Would you have bandwidth to create
>> one?
>>
>> You have the CoAP codec for a datagram based codec (no accumulation).
>>
>> I'm working on a MQTT codec
>> :https://github.com/jvermillard/mqtt-experiment/tree/master/mqtt-codec/
>> but this one is a state machine with no accumulation, it's quite
>> tedious to understand.
>>
>> You are right, some simpler example is needed, probably using IoBuffer
>> for accumulation.
>> I'm not sure I'm willing to do it in the next days :)
>>
>
> No worries :)
>
>
>>
>> >>
>> >> By the way, after implementing a lot of protocols using mina, I learnt
>> >> something about IoFilter:
>> >> too much logic in IoFilters is a design smell. Each time I try to do
>> >> that it's ending in a big  refactoring for putting this logic in the
>> >> IoHandler :)
>> >>
>> >
>> > Avro codec is light, just want to understand the flow correctly to get a
>> > working example.
>>
>> The real PITA is when from a filter read event you want to write a
>> message, using session.write(..)
>> in a read message handling. And you are intermixing read chain walk
>> with a walk of the write chain.
>> It can raise some weird question like : do I partially bypass the
>> write filter in the end of the filter chain?
>>
>
> Hmm I just want understand it so that I can configure the codecs properly
> :) Not doing anything jazzy here ;)
>
>
>>
>> Julien
>>
>
>
>
> --
> thanks
> ashish
>
> Blog: http://www.ashishpaliwal.com/blog
> My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Read/Write Filterchain

Posted by Ashish <pa...@gmail.com>.
On Mon, Jul 29, 2013 at 6:24 PM, Julien Vermillard <jv...@gmail.com>wrote:

> On Mon, Jul 29, 2013 at 11:52 AM, Ashish <pa...@gmail.com> wrote:
> > On Mon, Jul 29, 2013 at 3:15 PM, Julien Vermillard <
> jvermillard@gmail.com>wrote:
> >
> >> On Sun, Jul 28, 2013 at 4:20 PM, Ashish <pa...@gmail.com>
> wrote:
> >> > On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <
> >> jvermillard@gmail.com>wrote:
> >> >
> >> >> Hi,
> >> >> Just  make a filter handling read,but bypass for write
> >> >> and a filter handling write but bypass for read.
> >> >>
> >> >> If you extends AbstractIoFilter you just need to implement the needed
> >> >> event for each filter.
> >> >>
> >> >>
> >> > Got it.. Did we dropped the idea of having different filter chains for
> >> > read/write?
> >> >
> >>
> >> Yes, for the sake of simplicity: most of time if you transform in one
> >> way, you need to do
> >> it in the other way.
> >>
> >
> > I might have missed the discussion for this. I am getting older :)
> > What about the order in which it would be executed? Is it same as added
> in
> > chain like in MINA 2.0 or the other way round.
>
> The order is the same as MINA 2: read/open/close/idle/exception left
> to right, write right to left.
>

I meant, if I have a Filter chain like

Filter 1 -> Filter 2 - > IoHandler

So a Read chain would be same as filter chain above. So when I write from
IoHandler, would the sequence of processing be Filter 1 -> Filter 2

or IoHandler -> Filter 2 -> Filter 1



>
> >
> > We also need an example with Codecs. Would you have bandwidth to create
> one?
>
> You have the CoAP codec for a datagram based codec (no accumulation).
>
> I'm working on a MQTT codec
> :https://github.com/jvermillard/mqtt-experiment/tree/master/mqtt-codec/
> but this one is a state machine with no accumulation, it's quite
> tedious to understand.
>
> You are right, some simpler example is needed, probably using IoBuffer
> for accumulation.
> I'm not sure I'm willing to do it in the next days :)
>

No worries :)


>
> >>
> >> By the way, after implementing a lot of protocols using mina, I learnt
> >> something about IoFilter:
> >> too much logic in IoFilters is a design smell. Each time I try to do
> >> that it's ending in a big  refactoring for putting this logic in the
> >> IoHandler :)
> >>
> >
> > Avro codec is light, just want to understand the flow correctly to get a
> > working example.
>
> The real PITA is when from a filter read event you want to write a
> message, using session.write(..)
> in a read message handling. And you are intermixing read chain walk
> with a walk of the write chain.
> It can raise some weird question like : do I partially bypass the
> write filter in the end of the filter chain?
>

Hmm I just want understand it so that I can configure the codecs properly
:) Not doing anything jazzy here ;)


>
> Julien
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Read/Write Filterchain

Posted by Julien Vermillard <jv...@gmail.com>.
On Mon, Jul 29, 2013 at 11:52 AM, Ashish <pa...@gmail.com> wrote:
> On Mon, Jul 29, 2013 at 3:15 PM, Julien Vermillard <jv...@gmail.com>wrote:
>
>> On Sun, Jul 28, 2013 at 4:20 PM, Ashish <pa...@gmail.com> wrote:
>> > On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <
>> jvermillard@gmail.com>wrote:
>> >
>> >> Hi,
>> >> Just  make a filter handling read,but bypass for write
>> >> and a filter handling write but bypass for read.
>> >>
>> >> If you extends AbstractIoFilter you just need to implement the needed
>> >> event for each filter.
>> >>
>> >>
>> > Got it.. Did we dropped the idea of having different filter chains for
>> > read/write?
>> >
>>
>> Yes, for the sake of simplicity: most of time if you transform in one
>> way, you need to do
>> it in the other way.
>>
>
> I might have missed the discussion for this. I am getting older :)
> What about the order in which it would be executed? Is it same as added in
> chain like in MINA 2.0 or the other way round.

The order is the same as MINA 2: read/open/close/idle/exception left
to right, write right to left.

>
> We also need an example with Codecs. Would you have bandwidth to create one?

You have the CoAP codec for a datagram based codec (no accumulation).

I'm working on a MQTT codec
:https://github.com/jvermillard/mqtt-experiment/tree/master/mqtt-codec/
but this one is a state machine with no accumulation, it's quite
tedious to understand.

You are right, some simpler example is needed, probably using IoBuffer
for accumulation.
I'm not sure I'm willing to do it in the next days :)

>>
>> By the way, after implementing a lot of protocols using mina, I learnt
>> something about IoFilter:
>> too much logic in IoFilters is a design smell. Each time I try to do
>> that it's ending in a big  refactoring for putting this logic in the
>> IoHandler :)
>>
>
> Avro codec is light, just want to understand the flow correctly to get a
> working example.

The real PITA is when from a filter read event you want to write a
message, using session.write(..)
in a read message handling. And you are intermixing read chain walk
with a walk of the write chain.
It can raise some weird question like : do I partially bypass the
write filter in the end of the filter chain?

Julien

Re: Read/Write Filterchain

Posted by Ashish <pa...@gmail.com>.
On Mon, Jul 29, 2013 at 3:15 PM, Julien Vermillard <jv...@gmail.com>wrote:

> On Sun, Jul 28, 2013 at 4:20 PM, Ashish <pa...@gmail.com> wrote:
> > On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <
> jvermillard@gmail.com>wrote:
> >
> >> Hi,
> >> Just  make a filter handling read,but bypass for write
> >> and a filter handling write but bypass for read.
> >>
> >> If you extends AbstractIoFilter you just need to implement the needed
> >> event for each filter.
> >>
> >>
> > Got it.. Did we dropped the idea of having different filter chains for
> > read/write?
> >
>
> Yes, for the sake of simplicity: most of time if you transform in one
> way, you need to do
> it in the other way.
>

I might have missed the discussion for this. I am getting older :)
What about the order in which it would be executed? Is it same as added in
chain like in MINA 2.0 or the other way round.

We also need an example with Codecs. Would you have bandwidth to create one?



>
> By the way, after implementing a lot of protocols using mina, I learnt
> something about IoFilter:
> too much logic in IoFilters is a design smell. Each time I try to do
> that it's ending in a big  refactoring for putting this logic in the
> IoHandler :)
>

Avro codec is light, just want to understand the flow correctly to get a
working example.


>
> Julien
>

Re: Read/Write Filterchain

Posted by Julien Vermillard <jv...@gmail.com>.
On Sun, Jul 28, 2013 at 4:20 PM, Ashish <pa...@gmail.com> wrote:
> On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <jv...@gmail.com>wrote:
>
>> Hi,
>> Just  make a filter handling read,but bypass for write
>> and a filter handling write but bypass for read.
>>
>> If you extends AbstractIoFilter you just need to implement the needed
>> event for each filter.
>>
>>
> Got it.. Did we dropped the idea of having different filter chains for
> read/write?
>

Yes, for the sake of simplicity: most of time if you transform in one
way, you need to do
it in the other way.

By the way, after implementing a lot of protocols using mina, I learnt
something about IoFilter:
too much logic in IoFilters is a design smell. Each time I try to do
that it's ending in a big  refactoring for putting this logic in the
IoHandler :)

Julien

Re: Read/Write Filterchain

Posted by Ashish <pa...@gmail.com>.
On Sun, Jul 28, 2013 at 5:18 PM, Julien Vermillard <jv...@gmail.com>wrote:

> Hi,
> Just  make a filter handling read,but bypass for write
> and a filter handling write but bypass for read.
>
> If you extends AbstractIoFilter you just need to implement the needed
> event for each filter.
>
>
Got it.. Did we dropped the idea of having different filter chains for
read/write?


> --
> Julien Vermillard :::: http://people.apache.org/~jvermillard/
>
>
> On Sun, Jul 28, 2013 at 1:30 PM, Ashish <pa...@gmail.com> wrote:
> > Folks,
> >
> > I am a little lost in this section. How to set IoFilter/Codecs for
> > Read/Write chain. I need different sequence for Read and Write path at
> > Server side for the examples I am working on.
> >
> > Any suggestions/examples that I can use.
> >
> > --
> > thanks
> > ashish
> >
> > Blog: http://www.ashishpaliwal.com/blog
> > My Photo Galleries: http://www.pbase.com/ashishpaliwal
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog
My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Read/Write Filterchain

Posted by Julien Vermillard <jv...@gmail.com>.
Hi,
Just  make a filter handling read,but bypass for write
and a filter handling write but bypass for read.

If you extends AbstractIoFilter you just need to implement the needed
event for each filter.

--
Julien Vermillard :::: http://people.apache.org/~jvermillard/


On Sun, Jul 28, 2013 at 1:30 PM, Ashish <pa...@gmail.com> wrote:
> Folks,
>
> I am a little lost in this section. How to set IoFilter/Codecs for
> Read/Write chain. I need different sequence for Read and Write path at
> Server side for the examples I am working on.
>
> Any suggestions/examples that I can use.
>
> --
> thanks
> ashish
>
> Blog: http://www.ashishpaliwal.com/blog
> My Photo Galleries: http://www.pbase.com/ashishpaliwal