use of edu.iu.dsc.tws.rsched.schedulers.nomad.NomadController in project twister2 by DSC-SPIDAL.
the class NomadMasterStarter method launch.
/**
* launch the job master
*
* @return false if setup fails
*/
public boolean launch() {
// get the job working directory
String jobWorkingDirectory = NomadContext.workingDirectory(config);
LOG.log(Level.INFO, "job working directory ....." + jobWorkingDirectory);
if (NomadContext.sharedFileSystem(config)) {
if (!setupWorkingDirectory(job, jobWorkingDirectory)) {
throw new RuntimeException("Failed to setup the directory");
}
}
Config newConfig = Config.newBuilder().putAll(config).put(SchedulerContext.WORKING_DIRECTORY, jobWorkingDirectory).build();
// now start the controller, which will get the resources from
// slurm and start the job
IController controller = new NomadController(true);
controller.initialize(newConfig);
// start the Job Master locally
JobMaster jobMaster = null;
Thread jmThread = null;
if (JobMasterContext.jobMasterRunsInClient(config)) {
try {
int port = JobMasterContext.jobMasterPort(config);
String hostAddress = JobMasterContext.jobMasterIP(config);
if (hostAddress == null) {
hostAddress = InetAddress.getLocalHost().getHostAddress();
}
LOG.log(Level.INFO, String.format("Starting the job manager: %s:%d", hostAddress, port));
JobMasterAPI.NodeInfo jobMasterNodeInfo = NomadContext.getNodeInfo(config, hostAddress);
IScalerPerCluster clusterScaler = new NullScaler();
JobMasterAPI.JobMasterState initialState = JobMasterAPI.JobMasterState.JM_STARTED;
NullTerminator nt = new NullTerminator();
jobMaster = new JobMaster(config, hostAddress, nt, job, jobMasterNodeInfo, clusterScaler, initialState);
jobMaster.addShutdownHook(true);
jmThread = jobMaster.startJobMasterThreaded();
} catch (UnknownHostException e) {
LOG.log(Level.SEVERE, "Exception when getting local host address: ", e);
throw new RuntimeException(e);
} catch (Twister2Exception e) {
LOG.log(Level.SEVERE, "Exception when starting Job master: ", e);
throw new RuntimeException(e);
}
}
boolean start = controller.start(job);
// now lets wait on client
if (JobMasterContext.jobMasterRunsInClient(config)) {
try {
if (jmThread != null) {
jmThread.join();
}
} catch (InterruptedException ignore) {
}
}
return start;
}
Aggregations