Search in sources :

Example 11 with Twister2JobState

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;
}
Also used : Twister2JobState(edu.iu.dsc.tws.api.scheduler.Twister2JobState) NomadMasterStarter(edu.iu.dsc.tws.rsched.schedulers.nomad.master.NomadMasterStarter)

Example 12 with Twister2JobState

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;
}
Also used : Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) Twister2JobState(edu.iu.dsc.tws.api.scheduler.Twister2JobState) Config(edu.iu.dsc.tws.api.config.Config) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CyclicBarrier(java.util.concurrent.CyclicBarrier)

Aggregations

Twister2JobState (edu.iu.dsc.tws.api.scheduler.Twister2JobState)12 Config (edu.iu.dsc.tws.api.config.Config)4 Twister2Job (edu.iu.dsc.tws.api.Twister2Job)3 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)3 IOException (java.io.IOException)3 JobConfig (edu.iu.dsc.tws.api.JobConfig)2 ILauncher (edu.iu.dsc.tws.api.scheduler.ILauncher)2 IUploader (edu.iu.dsc.tws.api.scheduler.IUploader)2 JobAPI (edu.iu.dsc.tws.proto.system.job.JobAPI)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 IScalerPerCluster (edu.iu.dsc.tws.api.driver.IScalerPerCluster)1 NullScaler (edu.iu.dsc.tws.api.driver.NullScaler)1 Twister2Exception (edu.iu.dsc.tws.api.exceptions.Twister2Exception)1 IController (edu.iu.dsc.tws.api.scheduler.IController)1 JobMaster (edu.iu.dsc.tws.master.server.JobMaster)1 JobMasterAPI (edu.iu.dsc.tws.proto.jobmaster.JobMasterAPI)1 ResourceAllocator (edu.iu.dsc.tws.rsched.core.ResourceAllocator)1