agave-jobs/jobs-core/src/main/java/org/iplantc/service/jobs/model/Job.java
/**
	 * Calculates when a running job should have completed by.
	 * 
	 * @return
	 */
Calculates when a running job should have completed by.

@return
Calculates when a running job should have completed by . @return
public Date calculateExpirationDate() 
	{
		if (getEndTime() != null) 
		{
			return getEndTime();
		}
		else 
		{
			DateTime jobExpirationDate = null;
			if (getStartTime() != null) 
			{
				jobExpirationDate = new DateTime(getStartTime());
			} 
			else
			{
				jobExpirationDate = new DateTime(getCreated()).plusDays(7).plusDays(7);
			}
			if (StringUtils.isEmpty(getMaxRunTime())) 
			{
				return jobExpirationDate.plusHours(1000).toDate(); 
			} 
			else 
			{
				String[] runTimeTokens = getMaxRunTime().split(":");
				if (runTimeTokens.length > 2) {
					jobExpirationDate = jobExpirationDate.plusHours(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[0]), 0));
					jobExpirationDate = jobExpirationDate.plusMinutes(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[1]), 0));
					jobExpirationDate = jobExpirationDate.plusSeconds(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[2]), 0));
				}
				else if (runTimeTokens.length == 2) 
				{
					jobExpirationDate = jobExpirationDate.plusMinutes(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[0]), 0));
					jobExpirationDate = jobExpirationDate.plusSeconds(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[1]), 0));
				}
				else if (runTimeTokens.length == 1) {
					jobExpirationDate = jobExpirationDate.plusSeconds(NumberUtils.toInt(ServiceUtils.trimLeadingZeros(runTimeTokens[0]), 0));
				}
				return jobExpirationDate.plusDays(1).toDate();
			}
		}
	}
public Date calculateExpirationDate ( ) { if ( getEndTime ( ) != null ) { return getEndTime ( ) ; } else { DateTime jobExpirationDate = null ; if ( getStartTime ( ) != null ) { jobExpirationDate = new DateTime ( getStartTime ( ) ) ; } else { jobExpirationDate = new DateTime ( getCreated ( ) ) . plusDays ( 7 ) . plusDays ( 7 ) ; } if ( StringUtils . isEmpty ( getMaxRunTime ( ) ) ) { return jobExpirationDate . plusHours ( 1000 ) . toDate ( ) ; } else { String [ ] runTimeTokens = getMaxRunTime ( ) . split ( ":" ) ; if ( runTimeTokens . length > 2 ) { jobExpirationDate = jobExpirationDate . plusHours ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 0 ] ) , 0 ) ) ; jobExpirationDate = jobExpirationDate . plusMinutes ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 1 ] ) , 0 ) ) ; jobExpirationDate = jobExpirationDate . plusSeconds ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 2 ] ) , 0 ) ) ; } else if ( runTimeTokens . length == 2 ) { jobExpirationDate = jobExpirationDate . plusMinutes ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 0 ] ) , 0 ) ) ; jobExpirationDate = jobExpirationDate . plusSeconds ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 1 ] ) , 0 ) ) ; } else if ( runTimeTokens . length == 1 ) { jobExpirationDate = jobExpirationDate . plusSeconds ( NumberUtils . toInt ( ServiceUtils . trimLeadingZeros ( runTimeTokens [ 0 ] ) , 0 ) ) ; } return jobExpirationDate . plusDays ( 1 ) . toDate ( ) ; } } }
Calculates when a running job should have completed by.
Calculates when a running job should have completed by .
// if it's got an end time, return that // use when job actually started if available // otherwise use the worst case start time // created + 7 days to stage inputs + 7 days to submit // now adjust for run time. When no upper limit is given, use the max queue time // max queue length is 1000 hrs ~ 42 days // if we have a max run time, parse that and add it to the start time // give a buffer of 1 day1 just in case of something weird going on