You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Adrian Sandor (JIRA)" <ji...@apache.org> on 2007/08/29 05:51:31 UTC

[jira] Created: (DIRMINA-428) Message priorities

Message priorities
------------------

                 Key: DIRMINA-428
                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
             Project: MINA
          Issue Type: New Feature
            Reporter: Adrian Sandor


I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)

Here's how I think this could be implemented:
- define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
- add a priority field to WriteRequest, and implement Comparable using it
- add a write(Object message, int priority) method to IoSession
- make write(message) call write(message, NORMAL)
- make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
- ensure that a higher priority message won't interrupt sending out another message (if pending)
- if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524417 ] 

Trustin Lee commented on DIRMINA-428:
-------------------------------------

I'd prefer not to modify IoSession (i.e. adding write(Object, int)) because it will be effective only when the filter is inserted.  Providing some extension point on the filter side (e.g. using Comparator interface) or making the message classes to implement Comparable might be better solution.

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>            Reporter: Adrian Sandor
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee updated DIRMINA-428:
--------------------------------

      Component/s: Core
    Fix Version/s: 2.0.0-M1

I changed my mind.  We could let user specify the internal write request queue implementation like we did for session attributes: DIRMINA-393

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Trustin Lee resolved DIRMINA-428.
---------------------------------

    Resolution: Fixed
      Assignee: Trustin Lee

I've just added IoSessionDataStructureFactory which provides session attribute map and write request queue for a session.  By implementing this interface and changing IoService.sessionDataStructureFactory property, you can use whatever queue implementation you want, as long as it's thread safe.

This means you can implement prioritization of messages very easily.  For example, you could extend DefaultIoSessionDataStructureFactory and override getWriteRequestQueue() method to return a synchronized PriorityQueue constructed with a proper Comparator.

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>            Assignee: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542323 ] 

Trustin Lee commented on DIRMINA-428:
-------------------------------------

I've just added WriteRequest.getOriginalRequest() that helps you to get the original message before any transformation is performed on.

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>            Assignee: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541201 ] 

Trustin Lee commented on DIRMINA-428:
-------------------------------------

Hmm... first off, IoSessionDataStructureFactory is not a filter.  it creates a few important fields like WriteRequestQueue when a new session is created.  It's a special extension point introduced due to user demand.  Therefore your first comment is not effective now.  I implemented as you requested mostly. :)

Implementation of comparison is up to you.  There's an interface called WriteRequestQueue, so you can do whatever you want with the message ordering.  Typically you could maintain two or more queues internally (e.g. fast lane and other lanes).

It is true that the WriteRequest doesn't contain high-level information that helps you determine the priority of the request, although you can down-cast the write request to WriteRequestWrapper and get the original message, but I'm not sure it's a good way to determine the priority.  Let me think about this issue a little bit more...

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>            Assignee: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DIRMINA-428) Message priorities

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Emmanuel Lecharny closed DIRMINA-428.
-------------------------------------


> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>            Assignee: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Adrian Sandor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536563 ] 

Adrian Sandor commented on DIRMINA-428:
---------------------------------------

Thanks for your comment. Obviously you have a very different opinion about how to implement this, and I'm not sure I really understand. For example, I didn't plan for any filter originally, but you say "it will be effective only when the filter is inserted".
Could you please elaborate on:
- where and how the priority will be attached to a message
- where the messages will be sorted by priority
- how the default priority will be handled
- at what point the Comparator/Comparable interface will be used (I think anything before the writeRequestQueue will be useless)

Thanks

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>            Reporter: Adrian Sandor
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Trustin Lee (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12536877 ] 

Trustin Lee commented on DIRMINA-428:
-------------------------------------

- where and how the priority will be attached to a message

User will implement a Comparator or make the message Comparable so MINA can determine which message is more urgent.

- where the messages will be sorted by priority

In an IoFilter's internal heap probably.

- how the default priority will be handled

Once Comparator is used, there's no default priority.  Everything is relative.

- at what point the Comparator/Comparable interface will be used (I think anything before the writeRequestQueue will be useless)

Before putting the message into writeRequestQueue.  I think it's not useless because the IoFilter implementation could maintain it's own writeRequestQueue to maintain the size of the real writeRequestQueue minimal so that high-priority messages are pushed into the real writeRequestQueue earlier than other buffered requests.  This might decrease throughput in some degrees, but the trade-off should be configurable.

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>            Reporter: Adrian Sandor
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DIRMINA-428) Message priorities

Posted by "Adrian Sandor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRMINA-428?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541084 ] 

Adrian Sandor commented on DIRMINA-428:
---------------------------------------

Hi, sorry for the late reply. I haven't looked at the changes yet, but I'd like to comment on what you said anyway.

> - at what point the Comparator/Comparable interface will be used (I think anything before the writeRequestQueue will be useless)
>
> Before putting the message into writeRequestQueue. I think it's not useless because the IoFilter implementation could maintain it's own writeRequestQueue

Well, that means the writeRequestQueue is effectively moved to the filter, and the original queue [almost] becomes a no-op. So the sorting is still not done before the queue, just that the queue changes its place. It can work, but I don't think it is very nice.

> I changed my mind. We could let user specify the internal write request queue implementation

Ok, so the queue stays in place. The question remains - how to implement the comparison?
As I understand it, at this point the message to send has to be in the form of a ByteBuffer, and there's not much else to use in the WriteRequest. Or has it changed?

> Message priorities
> ------------------
>
>                 Key: DIRMINA-428
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-428
>             Project: MINA
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Adrian Sandor
>            Assignee: Trustin Lee
>             Fix For: 2.0.0-M1
>
>
> I would like MINA to support sending messages with different priorities, so that higher-priority messages will get sent out first (in the order that they were added to the queue, if they have the same priority)
> Here's how I think this could be implemented:
> - define different priorities; I suggest using numeric constants, such as LOWEST=0, LOW=25, NORMAL=50, HIGH=75, HIGHEST=100, allowing any custom values from 0 to 100
> - add a priority field to WriteRequest, and implement Comparable using it
> - add a write(Object message, int priority) method to IoSession
> - make write(message) call write(message, NORMAL)
> - make the writeRequestQueue in the session implementations a priority queue, but one that preserves the original order of "equal" elements
> - ensure that a higher priority message won't interrupt sending out another message (if pending)
> - if desired, write an IoFilter that can manipulate the priority

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.