Search in sources :

Example 36 with Twister2Job

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

the class ExampleTaskMain method submitJob.

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

Example 37 with Twister2Job

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

the class HelloWorld method main.

public static void main(String[] args) {
    // lets take number of workers as an command line argument
    int numberOfWorkers = 4;
    if (args.length == 1) {
        numberOfWorkers = Integer.valueOf(args[0]);
    }
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // lets put a configuration here
    JobConfig jobConfig = new JobConfig();
    jobConfig.put("hello-key", "Twister2-Hello");
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("hello-world-job").setWorkerClass(HelloWorld.class).addComputeResource(.2, 128, numberOfWorkers).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 38 with Twister2Job

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

the class KMeansConnectedDataflowExample method main.

public static void main(String[] args) throws ParseException {
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // build JobConfig
    HashMap<String, Object> configurations = new HashMap<>();
    configurations.put(SchedulerContext.THREADS_PER_WORKER, 1);
    Options options = new Options();
    options.addOption(CDFConstants.ARGS_PARALLELISM_VALUE, true, "2");
    options.addOption(CDFConstants.ARGS_WORKERS, true, "2");
    options.addOption(CDFConstants.ARGS_DIMENSIONS, true, "2");
    options.addOption(CDFConstants.ARGS_DSIZE, true, "2");
    options.addOption(CDFConstants.ARGS_CSIZE, true, "2");
    options.addOption(CDFConstants.ARGS_DINPUT, true, "2");
    options.addOption(CDFConstants.ARGS_CINPUT, true, "2");
    options.addOption(CDFConstants.ARGS_ITERATIONS, true, "2");
    @SuppressWarnings("deprecation") CommandLineParser commandLineParser = new DefaultParser();
    CommandLine commandLine = commandLineParser.parse(options, args);
    String dataDirectory = commandLine.getOptionValue(CDFConstants.ARGS_DINPUT);
    String centroidDirectory = commandLine.getOptionValue(CDFConstants.ARGS_CINPUT);
    int instances = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_WORKERS));
    int parallelism = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_PARALLELISM_VALUE));
    int dimension = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_DIMENSIONS));
    int dsize = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_DSIZE));
    int csize = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_CSIZE));
    int iterations = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_ITERATIONS));
    config = Config.newBuilder().putAll(config).put(CDFConstants.ARGS_WORKERS, Integer.toString(instances)).put(CDFConstants.ARGS_PARALLELISM_VALUE, Integer.toString(parallelism)).put(CDFConstants.ARGS_DIMENSIONS, Integer.toString(dimension)).put(CDFConstants.ARGS_CSIZE, Integer.toString(csize)).put(CDFConstants.ARGS_DSIZE, Integer.toString(dsize)).put(CDFConstants.ARGS_DINPUT, dataDirectory).put(CDFConstants.ARGS_CINPUT, centroidDirectory).put(CDFConstants.ARGS_ITERATIONS, Integer.toString(iterations)).put(SchedulerContext.DRIVER_CLASS, null).build();
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("kmeans-connected-dataflow").setWorkerClass(CDFWWorker.class).setDriverClass(KMeansDriver.class.getName()).addComputeResource(1, 2048, instances, true).build();
    // now submit the job
    Twister2Submitter.submitJob(twister2Job, config);
}
Also used : Options(org.apache.commons.cli.Options) HashMap(java.util.HashMap) Config(edu.iu.dsc.tws.api.config.Config) DataFlowJobConfig(edu.iu.dsc.tws.task.cdfw.DataFlowJobConfig) CDFWWorker(edu.iu.dsc.tws.task.impl.cdfw.CDFWWorker) Twister2Job(edu.iu.dsc.tws.api.Twister2Job) CommandLine(org.apache.commons.cli.CommandLine) DataObject(edu.iu.dsc.tws.api.dataset.DataObject) CommandLineParser(org.apache.commons.cli.CommandLineParser) DefaultParser(org.apache.commons.cli.DefaultParser)

Example 39 with Twister2Job

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

the class HelloHarp method main.

public static void main(String[] args) {
    // lets take number of workers as an command line argument
    int numberOfWorkers = 4;
    if (args.length == 1) {
        numberOfWorkers = Integer.valueOf(args[0]);
    }
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    // lets put a configuration here
    JobConfig jobConfig = new JobConfig();
    jobConfig.put("hello-harp-key", "Twister2-Hello-Harp");
    Twister2Job twister2Job = Twister2Job.newBuilder().setJobName("hello-harp-job").setWorkerClass(HelloHarp.class).addComputeResource(1, 512, numberOfWorkers).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)

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