Examples of JobParameters


Examples of org.springframework.batch.core.JobParameters

        }
      } else if(parameterType == ParameterType.STRING) {
        map.put(entry.getKey(), new JobParameter((String)entry.getValue().parameter));
      }
    }
    JobParameters jobParameters = new JobParameters(map);

    JobExecution lastJobExecution = jobRepository.getLastJobExecution(jobName, jobParameters);

    response = new GetLastJobExecutionRes();
    response.jobExecution = JobRepositoryRpcFactory.convertJobExecutionType(lastJobExecution);
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

        job.setRestartable(true);

        JobParametersBuilder builder = new JobParametersBuilder();
        builder.addString("stringKey", "stringValue").addLong("longKey", 1L).addDouble("doubleKey", 1.1).addDate(
                "dateKey", new Date(1L));
        JobParameters jobParams = builder.toJobParameters();

        JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParams);
        firstExecution.setStartTime(new Date());
        assertNotNull(firstExecution.getLastUpdated());
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

    context.getBean(BatchConfiguration.class).clear();
  }

  @Test
  public void basicExecution() throws Exception {
    runner.executeJob(job, new JobParameters());
    assertEquals(1, jobExplorer.getJobInstances("job", 0, 100).size());
    runner.executeJob(job, new JobParametersBuilder().addLong("id", 1L).toJobParameters());
    assertEquals(2, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

    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());
    runner.executeJob(job, new JobParameters());
    assertEquals(2, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

      @Override
      public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        throw new RuntimeException("Planned");
      }
    }).build()).incrementer(new RunIdIncrementer()).build();
    runner.executeJob(job, new JobParameters());
    runner.executeJob(job, new JobParameters());
    assertEquals(1, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

      @Override
      public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
        throw new RuntimeException("Planned");
      }
    }).build()).incrementer(new RunIdIncrementer()).build();
    JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false).toJobParameters();
    runner.executeJob(job, jobParameters);
    runner.executeJob(job, jobParameters);
    assertEquals(1, jobExplorer.getJobInstances("job", 0, 100).size());
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

   *
   * @param properties the properties
   * @throws JobExecutionException the job execution exception
   */
  protected void launchJobFromProperties(Properties properties) throws JobExecutionException {
    JobParameters jobParameters = this.converter.getJobParameters(properties);
    executeRegisteredJobs(jobParameters);
    executeLocalJobs(jobParameters);
  }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

    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());
      map.putAll(jobParameters.getParameters());
      jobParameters = new JobParameters(map);
      if (log.isDebugEnabled()) {
        log.info("JobParameter for job=[" + job + "] next=" + nextParameters + " used=" + jobParameters);
      }
    }
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

   * @return the next job parameters if they can be located
   * @throws JobParametersNotFoundException if there is a problem
   */
  private JobParameters getNextJobParameters(Job job, boolean fail) throws JobParametersNotFoundException {
    String jobIdentifier = job.getName();
    JobParameters jobParameters;
    List<JobInstance> lastInstances = jobExplorer.getJobInstances(jobIdentifier, 0, 1);

    JobParametersIncrementer incrementer = job.getJobParametersIncrementer();
    if (incrementer == null) {
      throw new JobParametersNotFoundException("No job parameters incrementer found for job=" + jobIdentifier);
    }

    if (lastInstances.isEmpty()) {
      jobParameters = incrementer.getNext(new JobParameters());
      if (jobParameters == null) {
        throw new JobParametersNotFoundException("No bootstrap parameters found from incrementer for job="
            + jobIdentifier);
      }
    } else {
View Full Code Here

Examples of org.springframework.batch.core.JobParameters

   * @param type the job execution type
   * @return converted job execution
   */
  public static JobExecution convertJobExecutionType(JobExecutionType type) {
    JobInstance jobInstance = convertJobInstanceType(type.jobInstance);
    JobParameters jobParameters = convertJobParametersType(type.jobParameters);

    JobExecution jobExecution = new JobExecution(jobInstance, type.id, jobParameters, type.jobConfigurationLocation);

    jobExecution.setVersion(type.version);
    jobExecution.setStatus(type.status);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.