@Test public void slaMinInvalidArgTest() { int min = 2; int max = 0; try { SLA sla = new SLA(min,max, null, null); SLAEnforcer slaEnf = new SLAEnforcer(sla); slaEnf.enforceSLAMin(-1, 0); fail(); } catch(Exception e) {} }
public int enforceSLAMin(int activeJobsCount, int acceptedJobsCount) { Preconditions.checkArgument(activeJobsCount >=0, "Invalid activeJobsCount " + activeJobsCount); Preconditions.checkArgument(acceptedJobsCount >=0, "Invalid acceptedJobsCount " + activeJobsCount); if(!sla.isPresent() || sla.get().getMin() == 0) { logger.debug("SLA min not set nothing to enforce"); return 0; } int jobsInActiveOrSubmittedState = activeJobsCount + acceptedJobsCount; if(jobsInActiveOrSubmittedState < sla.get().getMin()) { int jobsToLaunch = sla.get().getMin()-jobsInActiveOrSubmittedState; logger.info("Submit {} jobs per sla min of {}", jobsToLaunch, sla.get().getMin()); return jobsToLaunch; } logger.debug("SLA min already satisfied"); return 0; }
SLAEnforcer { public int enforceSLAMin(int activeJobsCount, int acceptedJobsCount) { Preconditions.checkArgument(activeJobsCount >=0, "Invalid activeJobsCount " + activeJobsCount); Preconditions.checkArgument(acceptedJobsCount >=0, "Invalid acceptedJobsCount " + activeJobsCount); if(!sla.isPresent() || sla.get().getMin() == 0) { logger.debug("SLA min not set nothing to enforce"); return 0; } int jobsInActiveOrSubmittedState = activeJobsCount + acceptedJobsCount; if(jobsInActiveOrSubmittedState < sla.get().getMin()) { int jobsToLaunch = sla.get().getMin()-jobsInActiveOrSubmittedState; logger.info("Submit {} jobs per sla min of {}", jobsToLaunch, sla.get().getMin()); return jobsToLaunch; } logger.debug("SLA min already satisfied"); return 0; } }
SLAEnforcer { public int enforceSLAMin(int activeJobsCount, int acceptedJobsCount) { Preconditions.checkArgument(activeJobsCount >=0, "Invalid activeJobsCount " + activeJobsCount); Preconditions.checkArgument(acceptedJobsCount >=0, "Invalid acceptedJobsCount " + activeJobsCount); if(!sla.isPresent() || sla.get().getMin() == 0) { logger.debug("SLA min not set nothing to enforce"); return 0; } int jobsInActiveOrSubmittedState = activeJobsCount + acceptedJobsCount; if(jobsInActiveOrSubmittedState < sla.get().getMin()) { int jobsToLaunch = sla.get().getMin()-jobsInActiveOrSubmittedState; logger.info("Submit {} jobs per sla min of {}", jobsToLaunch, sla.get().getMin()); return jobsToLaunch; } logger.debug("SLA min already satisfied"); return 0; } SLAEnforcer(SLA sla); }
SLAEnforcer { public int enforceSLAMin(int activeJobsCount, int acceptedJobsCount) { Preconditions.checkArgument(activeJobsCount >=0, "Invalid activeJobsCount " + activeJobsCount); Preconditions.checkArgument(acceptedJobsCount >=0, "Invalid acceptedJobsCount " + activeJobsCount); if(!sla.isPresent() || sla.get().getMin() == 0) { logger.debug("SLA min not set nothing to enforce"); return 0; } int jobsInActiveOrSubmittedState = activeJobsCount + acceptedJobsCount; if(jobsInActiveOrSubmittedState < sla.get().getMin()) { int jobsToLaunch = sla.get().getMin()-jobsInActiveOrSubmittedState; logger.info("Submit {} jobs per sla min of {}", jobsToLaunch, sla.get().getMin()); return jobsToLaunch; } logger.debug("SLA min already satisfied"); return 0; } SLAEnforcer(SLA sla); int enforceSLAMin(int activeJobsCount, int acceptedJobsCount); List<JobId> enforceSLAMax(List<JobInfo> list); boolean hasSLA(); }
SLAEnforcer { public int enforceSLAMin(int activeJobsCount, int acceptedJobsCount) { Preconditions.checkArgument(activeJobsCount >=0, "Invalid activeJobsCount " + activeJobsCount); Preconditions.checkArgument(acceptedJobsCount >=0, "Invalid acceptedJobsCount " + activeJobsCount); if(!sla.isPresent() || sla.get().getMin() == 0) { logger.debug("SLA min not set nothing to enforce"); return 0; } int jobsInActiveOrSubmittedState = activeJobsCount + acceptedJobsCount; if(jobsInActiveOrSubmittedState < sla.get().getMin()) { int jobsToLaunch = sla.get().getMin()-jobsInActiveOrSubmittedState; logger.info("Submit {} jobs per sla min of {}", jobsToLaunch, sla.get().getMin()); return jobsToLaunch; } logger.debug("SLA min already satisfied"); return 0; } SLAEnforcer(SLA sla); int enforceSLAMin(int activeJobsCount, int acceptedJobsCount); List<JobId> enforceSLAMax(List<JobInfo> list); boolean hasSLA();  }