private void validateSchedulingInfo()

in mantis-control-plane/mantis-control-plane-server/src/main/java/io/mantisrx/server/master/domain/JobDefinition.java [191:221]


    private void validateSchedulingInfo(boolean schedulingInfoOptional) throws InvalidJobException {
        if (schedulingInfoOptional && schedulingInfo == null)
            return;
        if (schedulingInfo == null)
            throw new InvalidJobException("No scheduling info provided");
        if (schedulingInfo.getStages() == null)
            throw new InvalidJobException("No stages defined in scheduling info");
        int withNumberOfStages = schedulingInfo.getStages().size();
        int startingIdx = 1;
        if (schedulingInfo.forStage(0) != null) {
            // jobMaster stage 0 definition exists, adjust index range
            startingIdx = 0;
            withNumberOfStages--;
        }
        for (int i = startingIdx; i <= withNumberOfStages; i++) {
            StageSchedulingInfo stage = schedulingInfo.getStages().get(i);
            if (stage == null)
                throw new InvalidJobException("No definition for stage " + i + " in scheduling info for " + withNumberOfStages + " stage job");
            if (stage.getNumberOfInstances() < 1)
                throw new InvalidJobException("Number of instance for stage " + i + " must be >0, not " + stage.getNumberOfInstances());
            MachineDefinition machineDefinition = stage.getMachineDefinition();
            if (machineDefinition.getCpuCores() <= 0)
                throw new InvalidJobException("cpuCores must be >0.0, not " + machineDefinition.getCpuCores());
            if (machineDefinition.getMemoryMB() <= 0)
                throw new InvalidJobException("memory must be <0.0, not " + machineDefinition.getMemoryMB());
            if (machineDefinition.getDiskMB() < 0)
                throw new InvalidJobException("disk must be >=0, not " + machineDefinition.getDiskMB());
            if (machineDefinition.getNumPorts() < 0)
                throw new InvalidJobException("numPorts must be >=0, not " + machineDefinition.getNumPorts());
        }
    }