Search in sources :

Example 31 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class TSetFTExample method main.

public static void main(String[] args) {
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    JobConfig jobConfig = new JobConfig();
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("TSetFTExample").setWorkerClass(TSetFTExample.class).addComputeResource(1, 512, 2).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 32 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class TSetCheckptExample method main.

public static void main(String[] args) {
    JobConfig jobConfig = new JobConfig();
    Twister2Job job = Twister2Job.newBuilder().setJobName(TSetCheckptExample.class.getName()).setConfig(jobConfig).setWorkerClass(TSetCheckptExample.class).addComputeResource(1, 512, 4).build();
    Twister2Submitter.submitJob(job);
}
Also used : JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 33 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class TSetComputeExample method main.

public static void main(String[] args) {
    JobConfig jobConfig = new JobConfig();
    Twister2Job job = Twister2Job.newBuilder().setJobName(TSetComputeExample.class.getName()).setConfig(jobConfig).setWorkerClass(TSetComputeExample.class).addComputeResource(1, 512, 4).build();
    Twister2Submitter.submitJob(job);
}
Also used : JobConfig(edu.iu.dsc.tws.api.JobConfig) Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Example 34 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class LocalSubmitter method startWorker.

/**
 * This method starts a new worker instance on a separate thread.
 */
private static Thread startWorker(Twister2Job twister2Job, Config config, int workerId, CyclicBarrier cyclicBarrier) {
    Thread.UncaughtExceptionHandler hndler = (th, ex) -> {
        failed = true;
        fault = ex;
    };
    LocalClassLoader localClassLoader = new LocalClassLoader(LocalSubmitter.class.getClassLoader());
    localClassLoader.addJobClass(twister2Job.getWorkerClass());
    try {
        Object o = localClassLoader.loadClass(MockWorker.class.getName()).getConstructor(twister2Job.getClass(), config.getClass(), Integer.class, CyclicBarrier.class).newInstance(twister2Job, config, workerId, cyclicBarrier);
        Thread thread = new Thread((Runnable) o);
        thread.setName("worker-" + workerId);
        thread.setUncaughtExceptionHandler(hndler);
        thread.start();
        return thread;
    } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
        throw new Twister2RuntimeException("Failed to start the worker thread", e);
    }
}
Also used : Twister2Job(edu.iu.dsc.tws.api.Twister2Job) CyclicBarrier(java.util.concurrent.CyclicBarrier) Files(java.nio.file.Files) Twister2JobState(edu.iu.dsc.tws.api.scheduler.Twister2JobState) LogManager(java.util.logging.LogManager) IOException(java.io.IOException) Config(edu.iu.dsc.tws.api.config.Config) FileInputStream(java.io.FileInputStream) UUID(java.util.UUID) Logger(java.util.logging.Logger) File(java.io.File) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) List(java.util.List) DriverJobState(edu.iu.dsc.tws.api.driver.DriverJobState) LocalClassLoader(edu.iu.dsc.tws.local.util.LocalClassLoader) FileConstants(edu.iu.dsc.tws.local.util.FileConstants) MockWorker(edu.iu.dsc.tws.local.mock.MockWorker) Twister2RuntimeException(edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CyclicBarrier(java.util.concurrent.CyclicBarrier) MockWorker(edu.iu.dsc.tws.local.mock.MockWorker) LocalClassLoader(edu.iu.dsc.tws.local.util.LocalClassLoader)

Example 35 with Twister2Job

use of edu.iu.dsc.tws.api.Twister2Job in project twister2 by DSC-SPIDAL.

the class DataParallelJob method submitJob.

private static void submitJob(Config config, int containers, JobConfig jobConfig, String clazz) {
    LOG.info("Submitting Job ...");
    Twister2Job twister2Job;
    twister2Job = Twister2Job.newBuilder().setJobName(clazz).setWorkerClass(clazz).addComputeResource(1, 512, containers).setConfig(jobConfig).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Twister2Job(edu.iu.dsc.tws.api.Twister2Job)

Aggregations

Twister2Job (edu.iu.dsc.tws.api.Twister2Job)39 JobConfig (edu.iu.dsc.tws.api.JobConfig)27 Config (edu.iu.dsc.tws.api.config.Config)23 HashMap (java.util.HashMap)11 CommandLine (org.apache.commons.cli.CommandLine)8 CommandLineParser (org.apache.commons.cli.CommandLineParser)7 DefaultParser (org.apache.commons.cli.DefaultParser)7 Options (org.apache.commons.cli.Options)7 Twister2JobState (edu.iu.dsc.tws.api.scheduler.Twister2JobState)4 DataFlowJobConfig (edu.iu.dsc.tws.task.cdfw.DataFlowJobConfig)4 JobAPI (edu.iu.dsc.tws.proto.system.job.JobAPI)3 CDFWWorker (edu.iu.dsc.tws.task.impl.cdfw.CDFWWorker)3 Twister2RuntimeException (edu.iu.dsc.tws.api.exceptions.Twister2RuntimeException)2 KubernetesController (edu.iu.dsc.tws.rsched.schedulers.k8s.KubernetesController)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 DataObject (edu.iu.dsc.tws.api.dataset.DataObject)1 DriverJobState (edu.iu.dsc.tws.api.driver.DriverJobState)1 Twister2Exception (edu.iu.dsc.tws.api.exceptions.Twister2Exception)1 HelloWorld (edu.iu.dsc.tws.examples.basic.HelloWorld)1