{
while ( !stop )
{
for ( Iterator iter = polledSessions.iterator(); iter.hasNext(); )
{
IoSession session = ( IoSession ) iter.next();
IoSessionStat sessStat = ( IoSessionStat ) session.getAttribute( KEY );
sessStat.lastByteRead = session.getReadBytes();
sessStat.lastByteWrite = session.getWrittenBytes();
sessStat.lastMessageRead = session.getReadMessages();
sessStat.lastMessageWrite = session.getWrittenMessages();
}
// wait polling time
try
{
Thread.sleep( pollingInterval );
}
catch ( InterruptedException e )
{
}
float tmpMsgWrittenThroughput = 0f;
float tmpMsgReadThroughput = 0f;
float tmpBytesWrittenThroughput = 0f;
float tmpBytesReadThroughput = 0f;
for ( Iterator iter = polledSessions.iterator(); iter.hasNext(); )
{
// upadating individual session statistics
IoSession session = ( IoSession ) iter.next();
IoSessionStat sessStat = ( IoSessionStat ) session.getAttribute( KEY );
sessStat.byteReadThroughput = ( session.getReadBytes() - sessStat.lastByteRead )
/ ( pollingInterval / 1000f );
tmpBytesReadThroughput += sessStat.byteReadThroughput;
sessStat.byteWrittenThroughput = ( session.getWrittenBytes() - sessStat.lastByteWrite )
/ ( pollingInterval / 1000f );
tmpBytesWrittenThroughput += sessStat.byteWrittenThroughput;
sessStat.messageReadThroughput = ( session.getReadMessages() - sessStat.lastMessageRead )
/ ( pollingInterval / 1000f );
tmpMsgReadThroughput += sessStat.messageReadThroughput;
sessStat.messageWrittenThroughput = ( session.getWrittenMessages() - sessStat.lastMessageWrite )
/ ( pollingInterval / 1000f );
tmpMsgWrittenThroughput += sessStat.messageWrittenThroughput;
synchronized( StatCollector.this )
{