question: static private void scanDeadlineQueue ( final long nowNanos , final PriorityBlockingQueue < QueryDeadline > deadlineQueue ) { final List < QueryDeadline > c = new ArrayList < QueryDeadline > ( DEADLINE_QUEUE_SCAN_SIZE ) ; deadlineQueue . drainTo ( c , DEADLINE_QUEUE_SCAN_SIZE ) ; int ndropped = 0 , nrunning = 0 ; for ( QueryDeadline x : c ) { if ( x . checkDeadline ( nowNanos ) != null ) { deadlineQueue . add ( x ) ; nrunning ++ ; } else { ndropped ++ ; } } if ( log . isInfoEnabled ( ) ) log . info ( "Scan: threadhold=" + DEADLINE_QUEUE_SCAN_SIZE + ", ndropped=" + ndropped + ", nrunning=" + nrunning + ", deadlineQueueSize=" + deadlineQueue . size ( ) ) ; }
target:  Queries with a deadline that lies significantly in the future can lie around in the priority queue until that deadline is reached if there are other queries in front of them that are not terminated and whose deadline has not be reached. Therefore, periodically, we need to scan the queue and clear out entries for terminated queries.