class SLAEnforcer {

	public List<JobId> enforceSLAMax(List<JobInfo> list) {
		Preconditions.checkNotNull(list, "runningOrAcceptedJobSet is null");
		
		List<JobId> jobsToDelete = Lists.newArrayList();
		// if no max sla defined;
		if(!sla.isPresent() || sla.get().getMax() ==0 ) {
			return jobsToDelete;
		}
		
		SortedSet<JobInfo> sortedJobSet = new TreeSet<>(comparator);
		sortedJobSet.addAll(list);

		JobInfo [] jobIdArray = sortedJobSet.toArray(new JobInfo[list.size()]);

		int activeJobCount = 0;
		int slaMax = sla.get().getMax();
        boolean addToDeleteList = false;
		for(int i=jobIdArray.length-1; i>=0; i--) {
		    JobInfo jInfo = jobIdArray[i];
		    if(addToDeleteList) {
		        jobsToDelete.add(jInfo.jobId);
            } else {
                if (jInfo.state.equals(JobState.Launched)) {
                    activeJobCount++;
                    if (activeJobCount == slaMax) {
                        addToDeleteList = true;
                    }
                }
            }
        }

		return jobsToDelete;
		
	}

	public  SLAEnforcer(SLA sla);

}