You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Steven E. Harris" <se...@panix.com> on 2007/01/15 18:58:51 UTC

Where in a filter chain does an ExecutorFilter belong?

I can't keep the first/last or head/tail sense straight for IoFilter
processing. Does the first/last labeling refer to the sending/outbound
perspective, with the first filter being the first to filter a write
and the last to filter a read, or is the first filter the last to
filter a write and the first to filter a read?

I ask because I'm not sure whether to put my ExecutorFilter at the
beginning or end of my filter chain. Right now I'm using this
arrangement (with some names changed):

,----
| // TODO: Figure out the ordering here:
| //       Should the thread pool be first or last?
| connector.getFilterChain().addLast( "my-codec",
|                                      new ProtocolCodecFilter(
|                                            new MyCodecFactory()) );
| connector.getFilterChain().addLast( "thread-pool",
|                                     new ExecutorFilter( executor ) );
| connector.setHandler( new MyProtocolHandler() );
`----

That makes the ExecutorFilter the "last" filter. But what does that
mean? Please advise.

-- 
Steven E. Harris

Re: Where in a filter chain does an ExecutorFilter belong?

Posted by Trustin Lee <tr...@gmail.com>.
On 1/16/07, Steven E. Harris <se...@panix.com> wrote:
>
> Niklas Therning <ni...@trillian.se> writes:
>
> > I hope that explanation made any sense to you! :-)
>
> Yes, it does, but unfortunately the explanation could have just as
> easily gone the other way. It would be nice if the naming conventions
> used imparted a better sense order with respect to traffic flow, such
> as "lowest" and "highest".
>
> Now, for my main question, I think this means that I want the
> ExecutorFilter to be the first filter, or at least to come /before/ my
> ProtocolCodecFilter, if I want the codecs to run concurrently for
> different sessions.


Then it's before.  You will find IoFilter is very similar to Servlet filter.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Re: Where in a filter chain does an ExecutorFilter belong?

Posted by "Steven E. Harris" <se...@panix.com>.
Niklas Therning <ni...@trillian.se> writes:

> I hope that explanation made any sense to you! :-)

Yes, it does, but unfortunately the explanation could have just as
easily gone the other way. It would be nice if the naming conventions
used imparted a better sense order with respect to traffic flow, such
as "lowest" and "highest".

Now, for my main question, I think this means that I want the
ExecutorFilter to be the first filter, or at least to come /before/ my
ProtocolCodecFilter, if I want the codecs to run concurrently for
different sessions.

-- 
Steven E. Harris

Re: Where in a filter chain does an ExecutorFilter belong?

Posted by Niklas Therning <ni...@trillian.se>.
The ordering of the filters (first, last) refers to the order in which
they "see" incoming data (i.e. data read from a socket). When data is
coming in (from the network) the first filter is the first to "see" the
data. The last filter "sees" this data right before it is delivered to
your IoHandler. When you write data to an IoSession the ordering is
reversed; the last filter in the chain is the first one to "see" the data.

I hope that explanation made any sense to you! :-)

/Niklas


Steven E. Harris wrote:
> I can't keep the first/last or head/tail sense straight for IoFilter
> processing. Does the first/last labeling refer to the sending/outbound
> perspective, with the first filter being the first to filter a write
> and the last to filter a read, or is the first filter the last to
> filter a write and the first to filter a read?
>
> I ask because I'm not sure whether to put my ExecutorFilter at the
> beginning or end of my filter chain. Right now I'm using this
> arrangement (with some names changed):
>
> ,----
> | // TODO: Figure out the ordering here:
> | //       Should the thread pool be first or last?
> | connector.getFilterChain().addLast( "my-codec",
> |                                      new ProtocolCodecFilter(
> |                                            new MyCodecFactory()) );
> | connector.getFilterChain().addLast( "thread-pool",
> |                                     new ExecutorFilter( executor ) );
> | connector.setHandler( new MyProtocolHandler() );
> `----
>
> That makes the ExecutorFilter the "last" filter. But what does that
> mean? Please advise.
>
>