@Override public ConstraintResult check(ProgramSchedule schedule, ConstraintContext context) { int numRunning = context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.RUNNING, maxConcurrency).size(); if (numRunning >= maxConcurrency) { LOG.debug("Skipping run of program {} from schedule {} because there are at least {} running runs.", schedule.getProgramId(), schedule.getName(), maxConcurrency); return notSatisfied(context); } int numSuspended = context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.SUSPENDED, maxConcurrency).size(); if (numRunning + numSuspended >= maxConcurrency) { LOG.debug("Skipping run of program {} from schedule {} because there are at least" + "{} running runs and at least {} suspended runs.", schedule.getProgramId(), schedule.getName(), numRunning, numSuspended); return notSatisfied(context); } return ConstraintResult.SATISFIED; }
@Override public ConstraintResult check(ProgramSchedule schedule, ConstraintContext context) { int numRunning = context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.RUNNING, maxConcurrency).size(); if (numRunning >= maxConcurrency) { LOG.debug("Skipping run of program {} from schedule {} because there are at least {} running runs.", schedule.getProgramId(), schedule.getName(), maxConcurrency); return notSatisfied(context); } int numSuspended = context.getProgramRuns(schedule.getProgramId(), ProgramRunStatus.SUSPENDED, maxConcurrency).size(); if (numRunning + numSuspended >= maxConcurrency) { LOG.debug("Skipping run of program {} from schedule {} because there are at least" + "{} running runs and at least {} suspended runs.", schedule.getProgramId(), schedule.getName(), numRunning, numSuspended); return notSatisfied(context); } return ConstraintResult.SATISFIED; }