Hi Trustin and all Mina fans,

Well, I come back with a proposal of addition in IoHandler.
Doing this will prevent me to use a specific Timer to do the same.
The objective are to get some statistics value on long term,
whatever the sessions are still running or not.
I think that only throughput are relevant, since others could be problematic
(risk of overflow) and could be not so relevant in general way.
Here is the proposal :

//NEW FIELDS
    private double largestReadBytesThroughput = 0.0;
    private double largestWrittenBytesThroughput = 0.0;
    private double largestReadMessagesThroughput = 0.0;
    private double largestWrittenMessagesThroughput = 0.0;
 
    private void updateThroughput(long currentTime) {
        synchronized (throughputCalculationLock) {
            int interval = (int) (currentTime - lastThroughputCalculationTime);
            long minInterval = getThroughputCalculationIntervalInMillis();
            if (minInterval == 0 || interval < minInterval) {
                return;
            }
            
            long readBytes = this.readBytes.get();
            long writtenBytes = this.writtenBytes.get();
            long readMessages = this.readMessages.get();
            long writtenMessages = this.writtenMessages.get();
            
            readBytesThroughput = (readBytes - lastReadBytes) * 1000.0 / 
interval;
            writtenBytesThroughput = (writtenBytes - lastWrittenBytes) * 1000.0 
/ interval;
            readMessagesThroughput = (readMessages - lastReadMessages) * 1000.0 
/ interval;
            writtenMessagesThroughput = (writtenMessages - lastWrittenMessages) 
* 1000.0 / interval;
            
// NEW FIELDS FOR LARGEST VALUES WHATEVER THE LIFE OF SESSIONS
            if (readBytesThroughput > largestReadBytesThroughput)
                largestReadBytesThroughput = readBytesThroughput;
           if (writtenBytesThroughput > largestWrittenBytesThroughput)
                largestWrittenBytesThroughput = writtenBytesThroughput;
           if (readMessagesThroughput > largestReadMessagesThroughput)
                largestReadMessagesThroughput = readMessagesThroughput;
           if (writtenMessagesThroughput > largestWrittenMessagesThroughput)
                largestWrittenMessagesThroughput = writtenMessagesThroughput;
// END OF ADDON
    
            lastReadBytes = readBytes;
            lastWrittenBytes = writtenBytes;
            lastReadMessages = readMessages;
            lastWrittenMessages = writtenMessages;
            
            lastThroughputCalculationTime = currentTime;
        }
    }
// NEW METHODS
    public final double getLargestReadBytesThroughput() {
        return largestReadBytesThroughput;
    }
    public final double getLargestWrittenBytesThroughput() {
        return largestWrittenBytesThroughput;
    }
    public final double getLargestReadMessagesThroughput() {
        return largestReadMessagesThroughput;
    }
    public final double getLargestWrittenMessagesThroughput() {
        return largestWrittenMessagesThroughput;
    }
Could it be something added to Mina ?

Also I really don't know why Read Messages (max throughput or cumulative)
are still 0 in my code, but should not be since bytes are not null as below.
Is this relative to the use of DemuxingIoHandler ? WDYT ?
I look at the code and see nothing particular that should produce this 
behaviour.

Active since: Wed Dec 12 17:23:57 CET 2007
Cumulative Sessions: 106
Maximum Concurrent Sessions: 106
Current Active Sessions: 106
Bytes read by Second: 113200.9900990099
Messages read by Second: 0.0
Cumulative Read Messages: 0
Bytes written by Second: 5700083.168316832
Messages written by Second: 1079.8679867986798
Cumulative Written Messages: 51780

Frederic

Reply via email to