use of edu.iu.dsc.tws.api.scheduler.Twister2JobState in project twister2 by DSC-SPIDAL.
the class NomadLauncher method launch.
@Override
public Twister2JobState launch(JobAPI.Job job) {
LOG.log(Level.INFO, "Launching job for cluster {0}", NomadContext.clusterType(config));
Twister2JobState state = new Twister2JobState(false);
NomadMasterStarter master = new NomadMasterStarter();
master.initialize(job, config);
boolean start = master.launch();
// now we need to terminate the job
if (!killJob(job.getJobId())) {
LOG.log(Level.INFO, "Failed to terminate job: " + job.getJobId());
}
state.setRequestGranted(start);
return state;
}
use of edu.iu.dsc.tws.api.scheduler.Twister2JobState in project twister2 by DSC-SPIDAL.
the class LocalSubmitter method submitJob.
/**
* This method can be used to run a {@link Twister2Job} with default configurations.
* Additional configurations can be defined/overridden by passing the {@link Config} object.
*/
public static Twister2JobState submitJob(Twister2Job twister2Job, Config config) {
Twister2JobState state = new Twister2JobState(false);
if (!prepared) {
prepare();
}
Config newConfig = overrideConfigs(config);
CyclicBarrier cyclicBarrier = new CyclicBarrier(twister2Job.getNumberOfWorkers());
List<Thread> threads = new ArrayList<>();
for (int i = 0; i < twister2Job.getNumberOfWorkers(); i++) {
Thread thread = startWorker(twister2Job, newConfig, i, cyclicBarrier);
threads.add(thread);
}
for (Thread workerThred : threads) {
try {
workerThred.join();
} catch (InterruptedException e) {
failed = true;
fault = e;
}
}
if (failed) {
LOG.log(Level.SEVERE, "Job failed unexpectedly", fault);
state.setJobstate(DriverJobState.FAILED);
if (fault instanceof Exception) {
state.setCause((Exception) fault);
} else {
state.setCause(new Twister2RuntimeException(fault));
}
} else {
state.setJobstate(DriverJobState.COMPLETED);
}
// reset the local state for next job
failed = false;
fault = null;
return state;
}
Aggregations