protected void processLinkQueue ( ) { long timeout = this . configuration . getCheckTimeout ( ) ; List < Pattern > excludedReferencePatterns = this . configuration . getExcludedReferencePatterns ( ) ; // Unqueue till we find an item that needs to be processed. We process an item if: // - it isn't present in the state map // - it is present but not enough time has elapsed since its last check time LinkQueueItem queueItem = null ; boolean shouldBeChecked = false ; while ( ! this . linkQueue . isEmpty ( ) && ! shouldBeChecked ) { queueItem = this . linkQueue . poll ( ) ; // Don't check excluded references shouldBeChecked = isExcluded ( queueItem . getContentReference ( ) , excludedReferencePatterns ) ; if ( ! shouldBeChecked ) { break ; } Map < String , LinkState > contentReferences = this . linkStateManager . getLinkStates ( ) . get ( queueItem . getLinkReference ( ) ) ; if ( contentReferences != null ) { LinkState state = contentReferences . get ( queueItem . getContentReference ( ) ) ; if ( state != null && ( System . currentTimeMillis ( ) - state . getLastCheckedTime ( ) <= timeout ) ) { shouldBeChecked = false ; } } } if ( shouldBeChecked && queueItem != null ) { checkLink ( queueItem ) ; } }
Read the queue and find links to process removing links that have already been checked out recently .