private void renewClaimedTasks ( ) { try { List < ClaimedTask > claimedTasks = ImmutableList . copyOf ( _claimedTasks . values ( ) ) ; List < ScanRangeTask > tasks = Lists . newArrayList ( ) ; for ( ClaimedTask claimedTask : claimedTasks ) { if ( claimedTask . isComplete ( ) ) { // Task is likely being removed in another thread. However, go ahead and remove it now // to allow other tasks to start sooner. _log . info ( "Complete claimed task found during renew: id={}" , claimedTask . getTaskId ( ) ) ; _claimedTasks . remove ( claimedTask . getTaskId ( ) ) ; } else if ( claimedTask . isStarted ( ) ) { // Task has started and is not complete. Renew it. tasks . add ( claimedTask . getTask ( ) ) ; } } if ( ! tasks . isEmpty ( ) ) { _scanWorkflow . renewScanRangeTasks ( tasks , QUEUE_RENEW_TTL ) ; for ( ScanRangeTask task : tasks ) { _log . info ( "Renewed scan range task: {}" , task ) ; } } } catch ( Exception e ) { _log . error ( "Failed to renew scan ranges" , e ) ; } }
Renews all claimed scan range tasks that have not been released . Unless this is called periodically the scan workflow will make this task available to be claimed again .