public synchronized Map < TaskError , Integer > getRecentErrorCounts ( long timeWindow ) { long start = System . currentTimeMillis ( ) - timeWindow ; Map < TaskError , Integer > errorCounts = createErrorCountsMap ( ) ; Iterator < Map < TaskError , Integer > > errorCountsIter = errorCountsQueue . iterator ( ) ; Iterator < Long > startTimeIter = startTimeQueue . iterator ( ) ; while ( errorCountsIter . hasNext ( ) && start < startTimeIter . next ( ) ) { Map < TaskError , Integer > windowErrorCounts = errorCountsIter . next ( ) ; for ( Map . Entry < TaskError , Integer > entry : windowErrorCounts . entrySet ( ) ) { errorCounts . put ( entry . getKey ( ) , errorCounts . get ( entry . getKey ( ) ) + entry . getValue ( ) ) ; } } return errorCounts ; }
Get recent TaskError counts within the given window