Search in sources :

Example 96 with Config

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

the class BasicKubernetesJob method main.

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    // LoggingHelper.setupLogging(null, "logs", "client");
    LOG.info("Job submission time: " + System.currentTimeMillis());
    // first load the configurations from command line and config files
    Config config = ResourceAllocator.loadConfig(new HashMap<>());
    LOG.fine("read config values: " + config.size() + "\n" + config);
    submitJob(config);
}
Also used : Config(edu.iu.dsc.tws.api.config.Config) JobConfig(edu.iu.dsc.tws.api.JobConfig)

Example 97 with Config

use of edu.iu.dsc.tws.api.config.Config 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 98 with Config

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

the class ZKJobMasterFinderExample method main.

/**
 * This class is used together with ZKJobMasterRegistrarExample.java
 * That class registers the Job Master and this class discovers it
 * <p>
 * This class tries to get the Job Master address from a ZooKeeper server
 * If the Job Master has not been registered yet,
 * it can wait for it to be registered
 */
public static void main(String[] args) {
    if (args.length != 1) {
        printUsage();
        return;
    }
    String zkAddress = args[0];
    String jobID = "test-job";
    Config cnfg = buildTestConfig(zkAddress);
    ZKJobMasterFinder finder = new ZKJobMasterFinder(cnfg, jobID);
    finder.initialize();
    String jobMasterIPandPort = finder.getJobMasterIPandPort();
    if (jobMasterIPandPort == null) {
        LOG.info("Job Master has not joined yet. Will wait and try to get the address ...");
        jobMasterIPandPort = finder.waitAndGetJobMasterIPandPort(20000);
        LOG.info("Job Master address: " + jobMasterIPandPort);
    } else {
        LOG.info("Job Master address: " + jobMasterIPandPort);
    }
    finder.close();
    LOG.info("Done, exiting ...");
}
Also used : ZKJobMasterFinder(edu.iu.dsc.tws.common.zk.ZKJobMasterFinder) Config(edu.iu.dsc.tws.api.config.Config)

Example 99 with Config

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

the class SourceTaskDataLoaderMain method main.

public static void main(String[] args) throws InvalidArguments {
    if (args.length == 3) {
        workers = Integer.parseInt(args[0]);
        parallelism = Integer.parseInt(args[1]);
        dataSource = args[2];
        Config config = ResourceAllocator.loadConfig(new HashMap<>());
        JobConfig jobConfig = new JobConfig();
        jobConfig.put(WorkerConstants.WORKERS, workers);
        jobConfig.put(WorkerConstants.PARALLELISM, parallelism);
        jobConfig.put(MLDataObjectConstants.TRAINING_DATA_DIR, dataSource);
        Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder();
        jobBuilder.setJobName("SourceTaskDataLoader");
        jobBuilder.setWorkerClass(SourceTaskDataLoader.class.getName());
        jobBuilder.addComputeResource(2, 512, 1.0, workers);
        jobBuilder.setConfig(jobConfig);
        // now submit the job
        Twister2Submitter.submitJob(jobBuilder.build(), config);
    } else {
        throw new InvalidArguments("Invalid Arguments : <workers> <parallelism> <datafile_path>");
    }
}
Also used : InvalidArguments(edu.iu.dsc.tws.examples.ml.svm.exceptions.InvalidArguments) 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 100 with Config

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

the class TaskWorkerDataLoaderMain method main.

public static void main(String[] args) throws InvalidArguments {
    if (args.length == 3) {
        workers = Integer.parseInt(args[0]);
        parallelism = Integer.parseInt(args[1]);
        dataSource = args[2];
        Config config = ResourceAllocator.loadConfig(new HashMap<>());
        JobConfig jobConfig = new JobConfig();
        jobConfig.put(WorkerConstants.WORKERS, workers);
        jobConfig.put(WorkerConstants.PARALLELISM, parallelism);
        jobConfig.put(MLDataObjectConstants.TRAINING_DATA_DIR, dataSource);
        Twister2Job.Twister2JobBuilder jobBuilder = Twister2Job.newBuilder();
        jobBuilder.setJobName("TaskWorkerDataLoader");
        jobBuilder.setWorkerClass(TaskWorkerDataLoader.class.getName());
        jobBuilder.addComputeResource(2, 512, 1.0, workers);
        jobBuilder.setConfig(jobConfig);
        // now submit the job
        Twister2Submitter.submitJob(jobBuilder.build(), config);
    } else {
        throw new InvalidArguments("Invalid Arguments : <workers> <parallelism> <datafile_path>");
    }
}
Also used : InvalidArguments(edu.iu.dsc.tws.examples.ml.svm.exceptions.InvalidArguments) 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

Config (edu.iu.dsc.tws.api.config.Config)169 JobConfig (edu.iu.dsc.tws.api.JobConfig)101 Twister2Job (edu.iu.dsc.tws.api.Twister2Job)52 CommandLine (org.apache.commons.cli.CommandLine)27 CommandLineParser (org.apache.commons.cli.CommandLineParser)27 DefaultParser (org.apache.commons.cli.DefaultParser)27 Options (org.apache.commons.cli.Options)27 HashMap (java.util.HashMap)26 ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)18 Map (java.util.Map)15 TaskSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskSchedulePlan)13 WorkerPlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerPlan)12 LinkedHashMap (java.util.LinkedHashMap)12 Test (org.junit.Test)12 Path (edu.iu.dsc.tws.api.data.Path)10 TaskInstancePlan (edu.iu.dsc.tws.api.compute.schedule.elements.TaskInstancePlan)9 WorkerSchedulePlan (edu.iu.dsc.tws.api.compute.schedule.elements.WorkerSchedulePlan)9 JobAPI (edu.iu.dsc.tws.proto.system.job.JobAPI)9 TaskSchedulerClassTest (edu.iu.dsc.tws.tsched.utils.TaskSchedulerClassTest)9 ExecutionPlan (edu.iu.dsc.tws.api.compute.executor.ExecutionPlan)8