use of org.apache.myriad.scheduler.MyriadOperations in project incubator-myriad by apache.
the class Main method startNMInstances.
private void startNMInstances(Injector injector) {
Map<String, Integer> nmInstances = injector.getInstance(MyriadConfiguration.class).getNmInstances();
MyriadOperations myriadOperations = injector.getInstance(MyriadOperations.class);
ServiceProfileManager profileManager = injector.getInstance(ServiceProfileManager.class);
SchedulerState schedulerState = injector.getInstance(SchedulerState.class);
Set<org.apache.myriad.state.NodeTask> launchedNMTasks = new HashSet<>();
launchedNMTasks.addAll(schedulerState.getPendingTasksByType(NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX));
if (!launchedNMTasks.isEmpty()) {
LOGGER.info("{} NM(s) in pending state. Not launching additional NMs", launchedNMTasks.size());
return;
}
launchedNMTasks.addAll(schedulerState.getStagingTasksByType(NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX));
if (!launchedNMTasks.isEmpty()) {
LOGGER.info("{} NM(s) in staging state. Not launching additional NMs", launchedNMTasks.size());
return;
}
launchedNMTasks.addAll(schedulerState.getActiveTasksByType(NodeManagerConfiguration.DEFAULT_NM_TASK_PREFIX));
if (!launchedNMTasks.isEmpty()) {
LOGGER.info("{} NM(s) in active state. Not launching additional NMs", launchedNMTasks.size());
return;
}
for (Map.Entry<String, Integer> entry : nmInstances.entrySet()) {
LOGGER.info("Launching {} NM(s) with profile {}", entry.getValue(), entry.getKey());
myriadOperations.flexUpCluster(profileManager.get(entry.getKey()), entry.getValue(), null);
}
}
Aggregations