private void calcChannelsStats ( List < TaskRec > tasks ) { for ( ChannelWorkContext wc : channelContextMap . values ( ) ) { wc . lastGotCount = 0 ; } for ( TaskRec taskRec : tasks ) { ChannelWorkContext wc = channelContextMap . get ( taskRec . channel ) ; if ( wc == null ) { wc = new ChannelWorkContext ( taskRec . channel ) ; channelContextMap . put ( taskRec . channel , wc ) ; } wc . lastGotCount ++ ; } // update next portion - double if found something, clear to minimum if not for ( ChannelWorkContext wc : channelContextMap . values ( ) ) { if ( wc . lastGotCount > 0 ) { wc . nextSlowLimit = Math . min ( wc . nextSlowLimit * 2 , MAX_TASK_COUNT ) ; logger . debug ( "Channel " + wc . channelName + " nextSlowLimit=" + wc . nextSlowLimit ) ; } else { wc . dropNextSlowLimit ( ) ; } } }
refresh channels work info . is not thread safe