Search in sources :

Example 1 with JobPlanner

use of org.apache.samza.execution.JobPlanner in project samza by apache.

the class RemoteApplicationRunner method run.

@Override
public void run(ExternalContext externalContext) {
    if (new JobConfig(config).getConfigLoaderFactory().isPresent()) {
        JobRunner runner = new JobRunner(JobPlanner.generateSingleJobConfig(config));
        runner.submit();
        return;
    }
    // TODO SAMZA-2432: Clean this up once SAMZA-2405 is completed when legacy flow is removed.
    try {
        JobPlanner planner = new RemoteJobPlanner(ApplicationDescriptorUtil.getAppDescriptor(app, config));
        List<JobConfig> jobConfigs = planner.prepareJobs();
        if (jobConfigs.isEmpty()) {
            throw new SamzaException("No jobs to run.");
        }
        // 3. submit jobs for remote execution
        jobConfigs.forEach(jobConfig -> {
            LOG.info("Starting job {} with config {}", jobConfig.getName(), jobConfig);
            JobRunner runner = new JobRunner(jobConfig);
            runner.run(true);
        });
    } catch (Throwable t) {
        throw new SamzaException("Failed to run application", t);
    }
}
Also used : JobRunner(org.apache.samza.job.JobRunner) JobPlanner(org.apache.samza.execution.JobPlanner) RemoteJobPlanner(org.apache.samza.execution.RemoteJobPlanner) SamzaException(org.apache.samza.SamzaException) JobConfig(org.apache.samza.config.JobConfig) RemoteJobPlanner(org.apache.samza.execution.RemoteJobPlanner)

Aggregations

SamzaException (org.apache.samza.SamzaException)1 JobConfig (org.apache.samza.config.JobConfig)1 JobPlanner (org.apache.samza.execution.JobPlanner)1 RemoteJobPlanner (org.apache.samza.execution.RemoteJobPlanner)1 JobRunner (org.apache.samza.job.JobRunner)1