Package org.springframework.yarn.batch.support.YarnBatchProperties

Examples of org.springframework.yarn.batch.support.YarnBatchProperties.JobProperties


  }

  @Test
  public void incrementExistingExecution() throws Exception {
    YarnBatchProperties yarnBatchProperties = new YarnBatchProperties();
    JobProperties jobProperties = new JobProperties();
    jobProperties.setName("job");
    jobProperties.setNext(true);
    yarnBatchProperties.setJobs(new ArrayList<YarnBatchProperties.JobProperties>(Arrays.asList(jobProperties)));
    runner.setYarnBatchProperties(yarnBatchProperties);

    job = jobs.get("job").start(step).incrementer(new RunIdIncrementer()).build();
    runner.executeJob(job, new JobParameters());
View Full Code Here


    return false;
  }

  protected void executeJob(Job job, JobParameters jobParameters) throws JobExecutionException {
    String jobIdentifier = job.getName();
    JobProperties jobProperties = yarnBatchProperties != null ? yarnBatchProperties.getJobProperties(jobIdentifier) : null;
    boolean restart = false;

    // re-create by adding props from a boot JobProperties
    if (jobProperties != null && jobProperties.getParameters() != null) {
      log.info("Job parameters from boot properties, parameters" + jobProperties.getParameters());
      Properties tmpProperties = new Properties();
      Map<String, Object> tmpParameters = jobProperties.getParameters();
      tmpProperties.putAll(tmpParameters);
      JobParameters tmpJobParameters = this.converter.getJobParameters(tmpProperties);
      Map<String, JobParameter> map1 = new HashMap<String, JobParameter>(tmpJobParameters.getParameters());
      map1.putAll(jobParameters.getParameters());
      jobParameters = new JobParameters(map1);
      log.info("Modified jobParameters=" + jobParameters);
    }

    if (jobProperties != null && jobProperties.isRestart()) {
      if (jobExplorer == null) {
        throw new JobExecutionException("A JobExplorer must be provided for a restart or start next operation.");
      }
      JobExecution jobExecution = getLastFailedJobExecution(jobIdentifier);
      if (log.isDebugEnabled()) {
        log.info("Last failed JobExecution: " + jobExecution);
      }
      if (jobExecution == null && jobProperties.isFailRestart()) {
        throw new JobExecutionNotFailedException("No failed or stopped execution found for job="
            + jobIdentifier);
      } else {
        log.info("No failed or stopped execution found for job=" + jobIdentifier
            + ", batch properties flag for failRestart=" + jobProperties.isFailRestart()
            + " so we don't fail restart.");
      }
      if (jobExecution != null) {
        restart = true;
        jobParameters = jobExecution.getJobParameters();
      }
    }

    if (jobProperties != null && jobProperties.isNext() && !restart) {
      if (jobExplorer == null) {
        throw new JobExecutionException("A JobExplorer must be provided for a restart or start next operation.");
      }
      JobParameters nextParameters = getNextJobParameters(job, false);
      Map<String, JobParameter> map = new HashMap<String, JobParameter>(nextParameters.getParameters());
View Full Code Here

    assertThat(properties.getJobs(), notNullValue());
    assertThat(properties.getJobs().size(), is(1));
    assertThat(properties.getJobProperties("jobsName1"), notNullValue());

    JobProperties jobProperties = properties.getJobProperties("jobsName1");
    assertThat(jobProperties.isEnabled(), is(true));
    assertThat(jobProperties.isFailNext(), is(true));
    assertThat(jobProperties.isFailRestart(), is(true));
    assertThat(jobProperties.isNext(), is(true));
    assertThat(jobProperties.isRestart(), is(true));
    assertThat(jobProperties.getParameters(), notNullValue());
    assertThat(jobProperties.getParameters().size(), is(2));
    assertThat((String)jobProperties.getParameters().get("job1key1"), is("job1val1"));
    assertThat((String)jobProperties.getParameters().get("job1key2"), is("job1val2"));
    context.close();
  }
View Full Code Here

TOP

Related Classes of org.springframework.yarn.batch.support.YarnBatchProperties.JobProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.