Le 03/10/2018 à 16:25, Mondain a écrit :
> I was looking into an issue reported in our use of UDP sessions in Mina
> 2.0.19. The IoSession.getScheduledWriteMessages() seemed to give very odd
> and varying results when more than one session existed. It seems that the
> scheduledWriteMessages stat comes from the acceptor, which in our case is
> "shared" so the value will be inaccurate per individual session; stat
> updates in AbstractIoSession here:
> 
>     /**
>      * Increase the number of scheduled message to write
>      */
>     public final void increaseScheduledWriteMessages() {
>         scheduledWriteMessages.incrementAndGet();
> 
>         if (getService() instanceof AbstractIoService) {
>             ((AbstractIoService)
> getService()).getStatistics().increaseScheduledWriteMessages();
>         }
>     }
> 
>     /**
>      * Decrease the number of scheduled message written
>      */
>     private void decreaseScheduledWriteMessages() {
>         scheduledWriteMessages.decrementAndGet();
>         if (getService() instanceof AbstractIoService) {
>             ((AbstractIoService)
> getService()).getStatistics().decreaseScheduledWriteMessages();
>         }
>     }
> 
> If all this is accurate and by-design, what would be the best way to
> determine how many writes are scheduled for an individual session?


If you want a per-session scheduled writes, the best solution would
probably to write your own filter that count the number of messages
going dow the chain, and the number of messages which have actually been
sent.

You will have to process the filterWrite() event (for outgoing messages)
and the messageSent() event (for messages that have been written. Keep
those two counters in the session's attribute.

You can also do that on the IoHandler implementation, which gives you
more control, and does not require the addition of a specific filter.

-- 
Emmanuel Lecharny

Symas.com
directory.apache.org

Reply via email to