@Test public void testFreeSlot() { final Task task = mock(Task.class); when(task.getPropertyValue(ResourceSlotProperty.class)).thenReturn(Optional.of(true)); final Set<ExecutorRepresenter> executorRepresenterList = new HashSet<>(Arrays.asList(a0, a1)); final Set<ExecutorRepresenter> candidateExecutors = executorRepresenterList.stream() .filter(e -> schedulingConstraint.testSchedulability(e, task)) .collect(Collectors.toSet()); final Set<ExecutorRepresenter> expectedExecutors = Collections.singleton(a1); assertEquals(expectedExecutors, candidateExecutors); }
@Override public boolean testSchedulability(final ExecutorRepresenter executor, final Task task) { if (!task.getPropertyValue(ResourceSlotProperty.class).orElse(false)) { return true; } return executor.getNumOfComplyingRunningTasks() < executor.getExecutorCapacity(); }
FreeSlotSchedulingConstraint implements SchedulingConstraint { @Override public boolean testSchedulability(final ExecutorRepresenter executor, final Task task) { if (!task.getPropertyValue(ResourceSlotProperty.class).orElse(false)) { return true; } return executor.getNumOfComplyingRunningTasks() < executor.getExecutorCapacity(); } }
FreeSlotSchedulingConstraint implements SchedulingConstraint { @Override public boolean testSchedulability(final ExecutorRepresenter executor, final Task task) { if (!task.getPropertyValue(ResourceSlotProperty.class).orElse(false)) { return true; } return executor.getNumOfComplyingRunningTasks() < executor.getExecutorCapacity(); } @Inject private  FreeSlotSchedulingConstraint(); }
FreeSlotSchedulingConstraint implements SchedulingConstraint { @Override public boolean testSchedulability(final ExecutorRepresenter executor, final Task task) { if (!task.getPropertyValue(ResourceSlotProperty.class).orElse(false)) { return true; } return executor.getNumOfComplyingRunningTasks() < executor.getExecutorCapacity(); } @Inject private  FreeSlotSchedulingConstraint(); @Override boolean testSchedulability(final ExecutorRepresenter executor, final Task task); }
FreeSlotSchedulingConstraint implements SchedulingConstraint { @Override public boolean testSchedulability(final ExecutorRepresenter executor, final Task task) { if (!task.getPropertyValue(ResourceSlotProperty.class).orElse(false)) { return true; } return executor.getNumOfComplyingRunningTasks() < executor.getExecutorCapacity(); } @Inject private  FreeSlotSchedulingConstraint(); @Override boolean testSchedulability(final ExecutorRepresenter executor, final Task task);  }