in mantis-common/src/main/java/io/mantisrx/runtime/MantisJobDefinition.java [118:148]
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 numStages = schedulingInfo.getStages().size();
int startingIdx = 1;
if (schedulingInfo.forStage(0) != null) {
// jobMaster stage 0 definition exists, adjust index range
startingIdx = 0;
numStages--;
}
for (int i = startingIdx; i <= numStages; i++) {
StageSchedulingInfo stage = schedulingInfo.getStages().get(i);
if (stage == null)
throw new InvalidJobException("No definition for stage " + i + " in scheduling info for " + numStages + " 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());
}
}