Search in sources :

Example 26 with Twister2Job

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

the class BasicMesosJob method main.

public static void main(String[] args) {
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    System.out.println("read config values: " + config.size());
    System.out.println(config);
    String jobName = SchedulerContext.jobName(config);
    jobName += "-" + System.currentTimeMillis();
    System.out.println("job name is " + jobName);
    // build JobConfig
    HashMap<String, Object> configurations = new HashMap<>();
    configurations.put(SchedulerContext.THREADS_PER_WORKER, 8);
    JobConfig jobConfig = new JobConfig();
    jobConfig.putAll(configurations);
    // build the job
    Twister2Job twister2Job = Twister2Job.loadTwister2Job(config, jobConfig);
    twister2Job.setJobName(jobName);
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
    System.out.println("now terminating...");
    Twister2Submitter.terminateJob(twister2Job.getJobName(), config);
}
Also used : HashMap(java.util.HashMap) 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 27 with Twister2Job

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

the class K8sControllerExample method main.

public static void main(String[] args) throws InterruptedException {
    KubernetesController controller = KubernetesController.init("default");
    if (args.length != 1) {
        LOG.severe("Provide jobID as a parameter.");
        return;
    }
    String jobID = args[0];
    String configDir = "";
    String twister2Home = Paths.get(configDir).toAbsolutePath().toString();
    Config config = ConfigLoader.loadConfig(twister2Home, "conf", "kubernetes");
    LOG.info("Loaded: " + config.size() + " configuration parameters.");
    testUploader(config, controller, jobID);
    if (config != null) {
        controller.close();
        return;
    }
    int numberOfWorkers = 4;
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("hello-world-job").setWorkerClass(HelloWorld.class).addComputeResource(.2, 128, numberOfWorkers).setConfig(new JobConfig()).build();
    twister2Job.setUserName("au");
    JobAPI.Job job = twister2Job.serialize();
    LOG.info("jobID: " + job.getJobId());
    V1ConfigMap cm = controller.getJobConfigMap(job.getJobId());
    if (cm == null) {
        LOG.info("there is no cm for this job on k8s");
    } else {
        LOG.info("cm: " + cm.getMetadata().getName());
    }
    // testPVC(config, controller, jobID);
    createCM(controller, job);
    getJobFromConfigMap(controller, job.getJobId());
    // testWorker(controller, jobID, 0);
    // testWorker(controller, jobID, 1);
    // testWorker(controller, jobID, 3);
    // testJM(controller, jobID);
    // controller.addParamToConfigMap(jobID, "KILL_JOB", "true");
    // Thread.sleep(5000);
    // createCMWatcher(controller, jobID);
    // Thread.sleep(5000);
    controller.deleteConfigMap(job.getJobId());
    controller.close();
}
Also used : KubernetesController(edu.iu.dsc.tws.rsched.schedulers.k8s.KubernetesController) Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig) JobAPI(edu.iu.dsc.tws.proto.system.job.JobAPI) Twister2Job(edu.iu.dsc.tws.api.Twister2Job) JobConfig(edu.iu.dsc.tws.api.JobConfig) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) HelloWorld(edu.iu.dsc.tws.examples.basic.HelloWorld)

Example 28 with Twister2Job

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

the class TSetCommunicationExample method main.

public static void main(String[] args) {
    JobConfig jobConfig = new JobConfig();
    Twister2Job job = Twister2Job.newBuilder().setJobName(TSetCommunicationExample.class.getName()).setConfig(jobConfig).setWorkerClass(TSetCommunicationExample.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 29 with Twister2Job

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

the class HelloTwister2 method main.

public static void main(String[] args) {
    JobConfig jobConfig = new JobConfig();
    Twister2Job job = Twister2Job.newBuilder().setJobName("hello-twister2").setConfig(jobConfig).setWorkerClass(HelloTwister2.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 30 with Twister2Job

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

the class TSetTeraSort method main.

public static void main(String[] args) {
    if (args.length < 2) {
        LOG.warning("Missing arguments. Expected <parallelism> <data size>");
    }
    int parallelism = Integer.parseInt(args[0]);
    int dataSize = Integer.parseInt(args[1]);
    LOG.info(String.format("Data Size : %d, Parallelism : %d", dataSize, parallelism));
    JobConfig jobConfig = new JobConfig();
    jobConfig.put(PARAM_PARALLELISM, parallelism);
    jobConfig.put(PARAM_DATA_SIZE_GB, dataSize);
    Twister2Job job = Twister2Job.newBuilder().setJobName(TSetTeraSort.class.getName()).setConfig(jobConfig).setWorkerClass(TSetTeraSort.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)

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