use of edu.iu.dsc.tws.api.config.Config in project twister2 by DSC-SPIDAL.
the class ConstraintTaskExample method main.
public static void main(String[] args) throws ParseException {
LOG.log(Level.INFO, "Constraint Task Graph Example");
// 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(DataObjectConstants.WORKERS, true, "Workers");
options.addOption(DataObjectConstants.PARALLELISM_VALUE, true, "parallelism");
options.addOption(DataObjectConstants.DSIZE, true, "dsize");
options.addOption(DataObjectConstants.DIMENSIONS, true, "dim");
options.addOption(Utils.createOption(DataObjectConstants.DINPUT_DIRECTORY, true, "Data points Input directory", true));
CommandLineParser commandLineParser = new DefaultParser();
CommandLine cmd = commandLineParser.parse(options, args);
int workers = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.WORKERS));
int parallelismValue = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.PARALLELISM_VALUE));
int dsize = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.DSIZE));
int dimension = Integer.parseInt(cmd.getOptionValue(DataObjectConstants.DIMENSIONS));
String dinput = cmd.getOptionValue(DataObjectConstants.DINPUT_DIRECTORY);
// build JobConfig
configurations.put(DataObjectConstants.WORKERS, Integer.toString(workers));
configurations.put(DataObjectConstants.DSIZE, Integer.toString(dsize));
configurations.put(DataObjectConstants.DIMENSIONS, Integer.toString(dimension));
configurations.put(DataObjectConstants.PARALLELISM_VALUE, Integer.toString(parallelismValue));
configurations.put(DataObjectConstants.DINPUT_DIRECTORY, dinput);
// build JobConfig
JobConfig jobConfig = new JobConfig();
jobConfig.putAll(configurations);
Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder();
jobBuilder.setJobName("Constraint-Example");
jobBuilder.setWorkerClass(ConstraintTaskExample.class.getName());
jobBuilder.addComputeResource(2, 2048, 1.0, workers);
jobBuilder.setConfig(jobConfig);
// now submit the job
Twister2Submitter.submitJob(jobBuilder.build(), config);
}
use of edu.iu.dsc.tws.api.config.Config in project twister2 by DSC-SPIDAL.
the class MultiSpoutTopology method main.
public static void main(String[] args) {
Config config = ResourceAllocator.loadConfig(Collections.emptyMap());
JobConfig jobConfig = new JobConfig();
Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder();
jobBuilder.setJobName("multi-source-example");
jobBuilder.setWorkerClass(MultiSpoutTopology.class.getName());
jobBuilder.setConfig(jobConfig);
jobBuilder.addComputeResource(1, 512, 1);
// now submit the job
Twister2Submitter.submitJob(jobBuilder.build(), config);
}
use of edu.iu.dsc.tws.api.config.Config in project twister2 by DSC-SPIDAL.
the class HelloExample 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");
@SuppressWarnings("deprecation") CommandLineParser commandLineParser = new DefaultParser();
CommandLine commandLine = commandLineParser.parse(options, args);
int instances = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_WORKERS));
int parallelismValue = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_PARALLELISM_VALUE));
configurations.put(CDFConstants.ARGS_WORKERS, Integer.toString(instances));
configurations.put(CDFConstants.ARGS_PARALLELISM_VALUE, Integer.toString(parallelismValue));
// build JobConfig
JobConfig jobConfig = new JobConfig();
jobConfig.putAll(configurations);
config = Config.newBuilder().putAll(config).put(SchedulerContext.DRIVER_CLASS, null).build();
Twister2Job twister2Job;
twister2Job = Twister2Job.newBuilder().setWorkerClass(CDFWWorker.class).setJobName(HelloExample.class.getName()).setDriverClass(HelloDriver.class.getName()).addComputeResource(1, 512, instances).setConfig(jobConfig).build();
// now submit the job
Twister2Submitter.submitJob(twister2Job, config);
}
use of edu.iu.dsc.tws.api.config.Config in project twister2 by DSC-SPIDAL.
the class ParallelDataFlowsExample 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");
@SuppressWarnings("deprecation") CommandLineParser commandLineParser = new DefaultParser();
CommandLine commandLine = commandLineParser.parse(options, args);
int instances = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_WORKERS));
int parallelismValue = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_PARALLELISM_VALUE));
configurations.put(CDFConstants.ARGS_WORKERS, Integer.toString(instances));
configurations.put(CDFConstants.ARGS_PARALLELISM_VALUE, Integer.toString(parallelismValue));
// build JobConfig
JobConfig jobConfig = new JobConfig();
jobConfig.putAll(configurations);
config = Config.newBuilder().putAll(config).put(SchedulerContext.DRIVER_CLASS, null).build();
Twister2Job twister2Job;
twister2Job = Twister2Job.newBuilder().setJobName(ParallelDataFlowsExample.class.getName()).setWorkerClass(CDFWWorker.class).setDriverClass(ParallelDataflowsDriver.class.getName()).addComputeResource(1, 512, instances, true).setConfig(jobConfig).build();
// now submit the job
Twister2Submitter.submitJob(twister2Job, config);
}
use of edu.iu.dsc.tws.api.config.Config in project twister2 by DSC-SPIDAL.
the class TwoDataFlowsExample 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");
@SuppressWarnings("deprecation") CommandLineParser commandLineParser = new DefaultParser();
CommandLine commandLine = commandLineParser.parse(options, args);
int instances = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_WORKERS));
int parallelismValue = Integer.parseInt(commandLine.getOptionValue(CDFConstants.ARGS_PARALLELISM_VALUE));
configurations.put(CDFConstants.ARGS_WORKERS, Integer.toString(instances));
configurations.put(CDFConstants.ARGS_PARALLELISM_VALUE, Integer.toString(parallelismValue));
// build JobConfig
JobConfig jobConfig = new JobConfig();
jobConfig.putAll(configurations);
config = Config.newBuilder().putAll(config).put(SchedulerContext.DRIVER_CLASS, null).build();
Twister2Job twister2Job;
twister2Job = Twister2Job.newBuilder().setJobName(HelloExample.class.getName()).setWorkerClass(CDFWWorker.class).setDriverClass(TwoDataFlowsDriver.class.getName()).addComputeResource(1, 512, instances).setConfig(jobConfig).build();
// now submit the job
Twister2Submitter.submitJob(twister2Job, config);
}
Aggregations