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