Search in sources :

Example 1 with SchedulerState

use of org.apache.myriad.state.SchedulerState 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)

Example 2 with SchedulerState

use of org.apache.myriad.state.SchedulerState in project incubator-myriad by apache.

the class MyriadModule method providesSchedulerState.

@Provides
@Singleton
SchedulerState providesSchedulerState(MyriadConfiguration cfg) {
    LOGGER.debug("Configuring SchedulerState provider");
    MyriadStateStore myriadStateStore = null;
    if (cfg.isHAEnabled()) {
        myriadStateStore = providesMyriadStateStore();
        if (myriadStateStore == null) {
            throw new RuntimeException("Could not find a state store" + " implementation for Myriad. The 'yarn.resourcemanager.store.class'" + " property should be set to a class implementing the" + " MyriadStateStore interface. For e.g." + " org.apache.hadoop.yarn.server.resourcemanager.recovery.MyriadFileSystemRMStateStore");
        }
    }
    return new SchedulerState(myriadStateStore);
}
Also used : MyriadStateStore(org.apache.myriad.state.MyriadStateStore) SchedulerState(org.apache.myriad.state.SchedulerState) Singleton(com.google.inject.Singleton) Provides(com.google.inject.Provides)

Example 3 with SchedulerState

use of org.apache.myriad.state.SchedulerState in project incubator-myriad by apache.

the class SchedulerStateResourceTest method getSchedulerState.

private SchedulerState getSchedulerState() throws Exception {
    SchedulerState state = new SchedulerState(new MyriadFileSystemRMStateStore());
    idOne = Protos.TaskID.newBuilder().setValue("nt-1").build();
    idTwo = Protos.TaskID.newBuilder().setValue("nt-2").build();
    idThree = Protos.TaskID.newBuilder().setValue("nt-3").build();
    TreeMap<String, Long> ports = new TreeMap<>();
    state.addTask(idOne, new NodeTask(new ServiceResourceProfile("profile1", 0.2, 1024.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
    state.addTask(idTwo, new NodeTask(new ServiceResourceProfile("profile2", 0.4, 2048.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
    state.addTask(idThree, new NodeTask(new ServiceResourceProfile("profile3", 0.6, 3072.0, ports), new LikeConstraint("localhost", "host-[0-9]*.example.com")));
    state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
    state.makeTaskActive(idOne);
    state.makeTaskPending(idTwo);
    state.makeTaskStaging(idThree);
    return state;
}
Also used : SchedulerState(org.apache.myriad.state.SchedulerState) MyriadFileSystemRMStateStore(org.apache.hadoop.yarn.server.resourcemanager.recovery.MyriadFileSystemRMStateStore) ServiceResourceProfile(org.apache.myriad.scheduler.ServiceResourceProfile) TreeMap(java.util.TreeMap) NodeTask(org.apache.myriad.state.NodeTask) LikeConstraint(org.apache.myriad.scheduler.constraints.LikeConstraint)

Example 4 with SchedulerState

use of org.apache.myriad.state.SchedulerState in project incubator-myriad by apache.

the class MyriadOperationsTest method initialize.

private MyriadOperations initialize() throws Exception {
    resetStoreState();
    SchedulerState sState = TestObjectFactory.getSchedulerState(cfg, "tmp/myriad-operations-test");
    sState.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
    AbstractYarnScheduler<FiCaSchedulerApp, FiCaSchedulerNode> scheduler = TestObjectFactory.getYarnScheduler();
    MyriadDriverManager manager = TestObjectFactory.getMyriadDriverManager();
    MyriadWebServer webServer = TestObjectFactory.getMyriadWebServer(cfg);
    CompositeInterceptor registry = new CompositeInterceptor();
    LeastAMNodesFirstPolicy policy = new LeastAMNodesFirstPolicy(registry, scheduler, sState);
    manager.startDriver();
    return new MyriadOperations(cfg, sState, policy, manager, webServer, generateRMContext(scheduler));
}
Also used : CompositeInterceptor(org.apache.myriad.scheduler.yarn.interceptor.CompositeInterceptor) MyriadWebServer(org.apache.myriad.webapp.MyriadWebServer) SchedulerState(org.apache.myriad.state.SchedulerState) FiCaSchedulerNode(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode) FiCaSchedulerApp(org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp) LeastAMNodesFirstPolicy(org.apache.myriad.policy.LeastAMNodesFirstPolicy)

Example 5 with SchedulerState

use of org.apache.myriad.state.SchedulerState in project incubator-myriad by apache.

the class TestObjectFactory method getSchedulerState.

public static SchedulerState getSchedulerState(MyriadConfiguration cfg, String baseDir) throws Exception {
    MyriadStateStore store = TestObjectFactory.getStateStore(new Configuration(), baseDir);
    SchedulerState state = new SchedulerState(store);
    state.setFrameworkId(FrameworkID.newBuilder().setValue("mock-framework").build());
    return state;
}
Also used : MyriadStateStore(org.apache.myriad.state.MyriadStateStore) SchedulerState(org.apache.myriad.state.SchedulerState) Configuration(org.apache.hadoop.conf.Configuration) MyriadConfiguration(org.apache.myriad.configuration.MyriadConfiguration)

Aggregations

SchedulerState (org.apache.myriad.state.SchedulerState)5 MyriadConfiguration (org.apache.myriad.configuration.MyriadConfiguration)2 MyriadStateStore (org.apache.myriad.state.MyriadStateStore)2 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Configuration (org.apache.hadoop.conf.Configuration)1 MyriadFileSystemRMStateStore (org.apache.hadoop.yarn.server.resourcemanager.recovery.MyriadFileSystemRMStateStore)1 FiCaSchedulerApp (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerApp)1 FiCaSchedulerNode (org.apache.hadoop.yarn.server.resourcemanager.scheduler.common.fica.FiCaSchedulerNode)1 LeastAMNodesFirstPolicy (org.apache.myriad.policy.LeastAMNodesFirstPolicy)1 MyriadOperations (org.apache.myriad.scheduler.MyriadOperations)1 ServiceProfileManager (org.apache.myriad.scheduler.ServiceProfileManager)1 ServiceResourceProfile (org.apache.myriad.scheduler.ServiceResourceProfile)1 LikeConstraint (org.apache.myriad.scheduler.constraints.LikeConstraint)1 CompositeInterceptor (org.apache.myriad.scheduler.yarn.interceptor.CompositeInterceptor)1 NodeTask (org.apache.myriad.state.NodeTask)1 MyriadWebServer (org.apache.myriad.webapp.MyriadWebServer)1