in myriad-scheduler/src/main/java/org/apache/myriad/Main.java [175:199]
private void validateNMInstances(Injector injector) {
LOGGER.info("Validating nmInstances..");
Map<String, Integer> nmInstances = injector.getInstance(MyriadConfiguration.class).getNmInstances();
ServiceProfileManager profileManager = injector.getInstance(ServiceProfileManager.class);
long maxCpu = Long.MIN_VALUE;
long maxMem = Long.MIN_VALUE;
for (Map.Entry<String, Integer> entry : nmInstances.entrySet()) {
String profile = entry.getKey();
ServiceResourceProfile nodeManager = profileManager.get(profile);
if (nodeManager == null) {
throw new IllegalArgumentException("Invalid profile name '" + profile + "' specified in 'nmInstances'");
}
if (entry.getValue() > 0) {
if (nodeManager.getCpus() > maxCpu) { // find the profile with largest number of cpus
maxCpu = nodeManager.getCpus().longValue();
maxMem = nodeManager.getMemory().longValue(); // use the memory from the same profile
}
}
}
if (maxCpu <= 0 || maxMem <= 0) {
throw new IllegalStateException(
"Please configure 'nmInstances' with at least one instance/profile " + "with non-zero cpu/mem resources.");
}
}