private boolean isJobSchedulingNeeded(URI id,String type,boolean inProgress,boolean isError,boolean scheduler,long lastTime,long nextTime){
  long systemTime=System.currentTimeMillis();
  long tolerance=Long.parseLong(_configInfo.get(TOLERANCE)) * 1000;
  _logger.info("Next Run Time {} , Last Run Time {}",nextTime,lastTime);
  long refreshInterval=getRefreshInterval(type);
  if (!inProgress) {
    if (scheduler) {
      if (systemTime < nextTime - tolerance) {
        _logger.info("Skipping Job {} ; attempt to schedule it before the next run time  :{}",id + "of type " + type,new Date(nextTime));
        _logger.info("Current system time {}; tolerance time allowed {}.",new Date(systemTime),tolerance);
        return false;
      }
    }
    if (!scheduler && isError && lastTime > 0) {
      _logger.info("User triggered {} Job for {} whose discovery status is error. Reschedule the job",type,id);
      return true;
    }
    if (systemTime - lastTime < refreshInterval * 1000) {
      _logger.info("Skipping Job {} of type {}; attempt to schedule faster than refresh interval allows",id,type);
      return false;
    }
  }
 else   if (!scheduler && (systemTime - lastTime > refreshInterval * 1000) && lastTime > 0) {
    _logger.info("User triggered {} Job for {} attempted to schedule later than refresh interval allows. Reschedule the job",type,id);
  }
 else   if (scheduler && (systemTime - lastTime > refreshInterval * 1000) && nextTime > 0 && System.currentTimeMillis() - nextTime >= JobIntervals.getMaxIdleInterval() * 1000) {
    _logger.info("Scheduled {} Job for {} was idle for too long. Reschedule the job",type,id);
  }
 else {
    _logger.info("{} Job for {} is in Progress",type,id);
    return false;
  }
  return true;
}

private boolean isJobSchedulingNeeded ( URI id , String type , boolean inProgress , boolean isError , boolean scheduler , long lastTime , long nextTime ) { long systemTime = System . currentTimeMillis ( ) ; long tolerance = Long . parseLong ( _configInfo . get ( TOLERANCE ) ) * 1000 ; _logger . info ( "Next Run Time {} , Last Run Time {}" , nextTime , lastTime ) ; long refreshInterval = getRefreshInterval ( type ) ; if ( ! inProgress ) { if ( scheduler ) { if ( systemTime < nextTime - tolerance ) { _logger . info ( "Skipping Job {} ; attempt to schedule it before the next run time  :{}" , id + "of type " + type , new Date ( nextTime ) ) ; _logger . info ( "Current system time {}; tolerance time allowed {}." , new Date ( systemTime ) , tolerance ) ; return false ; } } if ( ! scheduler && isError && lastTime > 0 ) { _logger . info ( "User triggered {} Job for {} whose discovery status is error. Reschedule the job" , type , id ) ; return true ; } if ( systemTime - lastTime < refreshInterval * 1000 ) { _logger . info ( "Skipping Job {} of type {}; attempt to schedule faster than refresh interval allows" , id , type ) ; return false ; } } else if ( ! scheduler && ( systemTime - lastTime > refreshInterval * 1000 ) && lastTime > 0 ) { _logger . info ( "User triggered {} Job for {} attempted to schedule later than refresh interval allows. Reschedule the job" , type , id ) ; } else if ( scheduler && ( systemTime - lastTime > refreshInterval * 1000 ) && nextTime > 0 && System . currentTimeMillis ( ) - nextTime >= JobIntervals . getMaxIdleInterval ( ) * 1000 ) { _logger . info ( "Scheduled {} Job for {} was idle for too long. Reschedule the job" , type , id ) ; } else { _logger . info ( "{} Job for {} is in Progress" , type , id ) ; return false ; } return true ; }
if current time - lastruntime is > refreshinterval , then schedule
