You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Trustin Lee <tr...@gmail.com> on 2007/11/12 01:44:50 UTC

Adding an optional message priority parameter to IoSession.write()

Hi community,

First off, please take a look at the following issue:

https://issues.apache.org/jira/browse/DIRMINA-428

Adrian is asking us to add an optional message priority parameter to
IoSession.write().  For now, user can provide his own
WriteRequestQueue implementation to implement prioritized messaging.
Because most applications won't need message prioritization, the
default configuration will ignore the specified (or default) priority
value.  However, the specified priority value will exist as a property
of a WriteRequest so it could be used as a hint for the user's
WriteRequestQueue or IoFilter implementation.

I think adding this optional parameter might be very useful but I am
also not sure about adding it because it doesn't do anything in the
default configuration.

What do you think?  Any feed back is appreciated.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Mark <el...@gmail.com>.
Looking at the JIRA entry, I agree with some of your earlier points.
I would not change IoService.write().  I do like the ability to add in
a WriteRequestQueue interface.  This will make the implementation
cleaner and not require any changes to methods that many people
currently use and are familiar with.

--Mark

On Nov 11, 2007 7:44 PM, Trustin Lee <tr...@gmail.com> wrote:
> Hi community,
>
> First off, please take a look at the following issue:
>
> https://issues.apache.org/jira/browse/DIRMINA-428
>
> Adrian is asking us to add an optional message priority parameter to
> IoSession.write().  For now, user can provide his own
> WriteRequestQueue implementation to implement prioritized messaging.
> Because most applications won't need message prioritization, the
> default configuration will ignore the specified (or default) priority
> value.  However, the specified priority value will exist as a property
> of a WriteRequest so it could be used as a hint for the user's
> WriteRequestQueue or IoFilter implementation.
>
> I think adding this optional parameter might be very useful but I am
> also not sure about adding it because it doesn't do anything in the
> default configuration.
>
> What do you think?  Any feed back is appreciated.
>
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>



-- 
--------------------------------
The adjuration to be "normal" seems shockingly repellent to me; I see
neither hope nor comfort in sinking to that low level. I think it is
ignorance that makes people think of abnormality only with horror and
allows them to remain undismayed at the proximity of "normal" to
average and mediocre. For surely anyone who achieves anything is,
essentially, abnormal.
     Dr. Karl Menninger

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Trustin Lee <tr...@gmail.com>.
On Nov 14, 2007 9:39 AM, Trustin Lee <tr...@gmail.com> wrote:
> On Nov 14, 2007 5:15 AM, Mike Heath <mh...@apache.org> wrote:
> > Trustin Lee wrote:
> > > On Nov 13, 2007 2:05 PM, Mike Heath <mh...@apache.org> wrote:
> > >> I really don't see a need to change the API to support a feature that
> > >> few people will use.  Using IoSessionDataStructureFactory to produce a
> > >> priority queue provides the necessary flexibility to allow those who
> > >> need this feature to implement it for their protocol as they see fit.
> > >
> > > The problem is that WriteRequestQueue can't effectively determine the
> > > priority of the scheduled message because it will be in a binary form
> > > in most transports.  The WriteRequestQueue implementor must know the
> > > original message of the final binary form.  Should we add
> > > WriteRequest.originalMessage property instead then?
> >
> > Oh you're right.  I was thinking we would still have the original
> > message when the message was put into the WriteRequestQueue.
> >
> > WriteRequest.originalMessage could be used to solve the problem and it
> > might be useful for other types of custom WriteRequestQueue implementations.
> >
> > Is there a better solution for this?
>
> I think adding originalMessage property will fix this issue.
>
> > What if we did change the API and used a priority queue by default?  Is
> > the overhead incurred by using a priority queue over a normal queue high
> > enough that we wouldn't want to do that?  I can't see there being much
> > overhead at all if the priorities are all the same (the default case).
>
> That's also a good idea, but this doesn't mean than originalMessage
> property is not needed.  WriteRequestQueue implementors will want to
> inspect some property of the original message to determine (or
> override) the priority of the message automatically.
>
> Considering originalMessage is required anyway, we could simply end up
> with adding originalMessage property and retaining the current write()
> method.  However, having some kind of priority mechanism (i.e. high
> priority queue + low priority queue) might be useful to many users
> although it will take up some additional memory.  I'd like to know
> what others think about this issue.

I've just added WriteRequest.getOriginalRequest() which should enable
users to implement his or her own prioritized WriteRequestQueue.  I
think this change doesn't consume any additional memory because any
transformed WriteRequest has its parent request in itself already.
The default implementation doesn't consider priority at all though.
Again, any user feed back is welcome.  :)

Cheers,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Trustin Lee <tr...@gmail.com>.
On Nov 14, 2007 5:15 AM, Mike Heath <mh...@apache.org> wrote:
> Trustin Lee wrote:
> > On Nov 13, 2007 2:05 PM, Mike Heath <mh...@apache.org> wrote:
> >> I really don't see a need to change the API to support a feature that
> >> few people will use.  Using IoSessionDataStructureFactory to produce a
> >> priority queue provides the necessary flexibility to allow those who
> >> need this feature to implement it for their protocol as they see fit.
> >
> > The problem is that WriteRequestQueue can't effectively determine the
> > priority of the scheduled message because it will be in a binary form
> > in most transports.  The WriteRequestQueue implementor must know the
> > original message of the final binary form.  Should we add
> > WriteRequest.originalMessage property instead then?
>
> Oh you're right.  I was thinking we would still have the original
> message when the message was put into the WriteRequestQueue.
>
> WriteRequest.originalMessage could be used to solve the problem and it
> might be useful for other types of custom WriteRequestQueue implementations.
>
> Is there a better solution for this?

I think adding originalMessage property will fix this issue.

> What if we did change the API and used a priority queue by default?  Is
> the overhead incurred by using a priority queue over a normal queue high
> enough that we wouldn't want to do that?  I can't see there being much
> overhead at all if the priorities are all the same (the default case).

That's also a good idea, but this doesn't mean than originalMessage
property is not needed.  WriteRequestQueue implementors will want to
inspect some property of the original message to determine (or
override) the priority of the message automatically.

Considering originalMessage is required anyway, we could simply end up
with adding originalMessage property and retaining the current write()
method.  However, having some kind of priority mechanism (i.e. high
priority queue + low priority queue) might be useful to many users
although it will take up some additional memory.  I'd like to know
what others think about this issue.

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Mike Heath <mh...@apache.org>.
Trustin Lee wrote:
> On Nov 13, 2007 2:05 PM, Mike Heath <mh...@apache.org> wrote:
>> I really don't see a need to change the API to support a feature that
>> few people will use.  Using IoSessionDataStructureFactory to produce a
>> priority queue provides the necessary flexibility to allow those who
>> need this feature to implement it for their protocol as they see fit.
> 
> The problem is that WriteRequestQueue can't effectively determine the
> priority of the scheduled message because it will be in a binary form
> in most transports.  The WriteRequestQueue implementor must know the
> original message of the final binary form.  Should we add
> WriteRequest.originalMessage property instead then?

Oh you're right.  I was thinking we would still have the original
message when the message was put into the WriteRequestQueue.

WriteRequest.originalMessage could be used to solve the problem and it
might be useful for other types of custom WriteRequestQueue implementations.

Is there a better solution for this?

What if we did change the API and used a priority queue by default?  Is
the overhead incurred by using a priority queue over a normal queue high
enough that we wouldn't want to do that?  I can't see there being much
overhead at all if the priorities are all the same (the default case).

-Mike

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Trustin Lee <tr...@gmail.com>.
On Nov 13, 2007 2:05 PM, Mike Heath <mh...@apache.org> wrote:
> I really don't see a need to change the API to support a feature that
> few people will use.  Using IoSessionDataStructureFactory to produce a
> priority queue provides the necessary flexibility to allow those who
> need this feature to implement it for their protocol as they see fit.

The problem is that WriteRequestQueue can't effectively determine the
priority of the scheduled message because it will be in a binary form
in most transports.  The WriteRequestQueue implementor must know the
original message of the final binary form.  Should we add
WriteRequest.originalMessage property instead then?

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Re: Adding an optional message priority parameter to IoSession.write()

Posted by Mike Heath <mh...@apache.org>.
I really don't see a need to change the API to support a feature that
few people will use.  Using IoSessionDataStructureFactory to produce a
priority queue provides the necessary flexibility to allow those who
need this feature to implement it for their protocol as they see fit.

-Mike

Trustin Lee wrote:
> Hi community,
> 
> First off, please take a look at the following issue:
> 
> https://issues.apache.org/jira/browse/DIRMINA-428
> 
> Adrian is asking us to add an optional message priority parameter to
> IoSession.write().  For now, user can provide his own
> WriteRequestQueue implementation to implement prioritized messaging.
> Because most applications won't need message prioritization, the
> default configuration will ignore the specified (or default) priority
> value.  However, the specified priority value will exist as a property
> of a WriteRequest so it could be used as a hint for the user's
> WriteRequestQueue or IoFilter implementation.
> 
> I think adding this optional parameter might be very useful but I am
> also not sure about adding it because it doesn't do anything in the
> default configuration.
> 
> What do you think?  Any feed back is appreciated.
> 
> Trustin