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);
}
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);
}
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);
}
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);
}
Aggregations