Search in sources :

Example 1 with MyriadOperations

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);
    }
}
Also used : ServiceProfileManager(org.apache.myriad.scheduler.ServiceProfileManager) SchedulerState(org.apache.myriad.state.SchedulerState) MyriadConfiguration(org.apache.myriad.configuration.MyriadConfiguration) Map(java.util.Map) MyriadOperations(org.apache.myriad.scheduler.MyriadOperations) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)1 Map (java.util.Map)1 MyriadConfiguration (org.apache.myriad.configuration.MyriadConfiguration)1 MyriadOperations (org.apache.myriad.scheduler.MyriadOperations)1 ServiceProfileManager (org.apache.myriad.scheduler.ServiceProfileManager)1 SchedulerState (org.apache.myriad.state.SchedulerState)1