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);
}
}
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);
}
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;
}
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));
}
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;
}
Aggregations