class AgentLaunchGuardConstraint implements SystemConstraint {

    @Override
    public Result evaluate(TaskRequest taskRequest, VirtualMachineCurrentState targetVM, TaskTrackerState taskTrackerState) {
        if (!schedulerConfiguration.isGlobalTaskLaunchingConstraintEvaluatorEnabled()) {
            return VALID;
        }

        int maxLaunchingTasksPerMachine = schedulerConfiguration.getMaxLaunchingTasksPerMachine();

        int assigned = targetVM.getTasksCurrentlyAssigned().size();
        if (assigned >= maxLaunchingTasksPerMachine) {
            return INVALID;
        }
        int remaining = Math.max(maxLaunchingTasksPerMachine - assigned, 0);

        return isLaunchingLessThanNumberOfTasks(taskIdMapRef.get(), targetVM, remaining) ? VALID : INVALID;
    }

    @Inject public  AgentLaunchGuardConstraint(SchedulerConfiguration schedulerConfiguration,
                                      V3JobOperations v3JobOperations);

}