Refine search
@Override public String getJobName() { return this.execution.getJobInstance().getJobName(); }
@Test public void testNullNameIsIllegal() throws Exception { try { new StepExecution(null, new JobExecution(new JobInstance(null, "job"), null)); fail(); } catch (IllegalArgumentException e) { // expected } }
@Override public long getInstanceId() { return jobExecution.getJobInstance().getId(); }
@Override public JobInstance mapRow(ResultSet rs, int rowNum) throws SQLException { JobInstance jobInstance = new JobInstance(rs.getLong(1), rs.getString(2)); // should always be at version=0 because they never get updated jobInstance.incrementVersion(); return jobInstance; } }
/** * In this JDBC implementation a job id is obtained by asking the * jobIncrementer (which is likely a sequence) for the next long value, and * then passing the Id and parameter values into an INSERT statement. * * @see JobInstanceDao#createJobInstance(String, JobParameters) * @throws IllegalArgumentException * if any {@link JobParameters} fields are null. */ @Override public JobInstance createJobInstance(String jobName, JobParameters jobParameters) { Assert.notNull(jobName, "Job name must not be null."); Assert.notNull(jobParameters, "JobParameters must not be null."); Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist"); Long jobId = jobIncrementer.nextLongValue(); JobInstance jobInstance = new JobInstance(jobId, jobName); jobInstance.incrementVersion(); Object[] parameters = new Object[] { jobId, jobName, jobKeyGenerator.generateKey(jobParameters), jobInstance.getVersion() }; getJdbcTemplate().update( getQuery(CREATE_JOB_INSTANCE), parameters, new int[] { Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER }); return jobInstance; }
/** * Test method for * {@link org.springframework.batch.core.JobInstance#getJobName()}. */ @Test public void testGetName() { instance = new JobInstance(new Long(1), "foo"); assertEquals("foo", instance.getJobName()); }
modelBuilder.addRow().addValue("Task Execution Id ").addValue(jobExecutionResource.getTaskExecutionId()); modelBuilder.addRow().addValue("Task Instance Id ") .addValue(jobExecutionResource.getJobExecution().getJobInstance().getInstanceId()); modelBuilder.addRow().addValue("Job Name ") .addValue(jobExecutionResource.getJobExecution().getJobInstance().getJobName()); modelBuilder.addRow().addValue("Create Time ").addValue(jobExecutionResource.getJobExecution().getCreateTime()); modelBuilder.addRow().addValue("Start Time ").addValue(jobExecutionResource.getJobExecution().getStartTime()); modelBuilder.addRow().addValue("End Time ").addValue(jobExecutionResource.getJobExecution().getEndTime());
private void checkRepository(BatchStatus status, ExitStatus exitStatus) { // because map dao stores in memory, it can be checked directly JobInstance jobInstance = jobExecution.getJobInstance(); JobExecution other = jobExecutionDao.findJobExecutions(jobInstance).get(0); assertEquals(jobInstance.getId(), other.getJobId()); assertEquals(status, other.getStatus()); if (exitStatus != null) { assertEquals(exitStatus.getExitCode(), other.getExitStatus().getExitCode()); } }
JobExecution jobExecution = taskJobExecution.getJobExecution(); this.timeZone = timeZone; this.executionId = jobExecution.getId(); this.jobId = jobExecution.getJobId(); this.stepExecutionCount = taskJobExecution.getStepExecutionCount(); this.jobParameters =converter.getProperties(jobExecution.getJobParameters()); this.jobParametersString = fromJobParameters( this.argumentSanitizer.sanitizeJobParameters(jobExecution.getJobParameters())); this.status = taskJobExecution.getJobExecution().getStatus(); if (jobInstance != null) { this.name = jobInstance.getJobName(); this.restartable = JobUtils.isJobExecutionRestartable(jobExecution); this.abandonable = JobUtils.isJobExecutionAbandonable(jobExecution); this.stoppable = JobUtils.isJobExecutionStoppable(jobExecution); this.instanceId = jobExecution.getJobInstance().getInstanceId();
@Override public JobExecution getLastJobExecution(@Nullable JobInstance jobInstance) { JobExecution lastExec = null; for (JobExecution exec : executionsById.values()) { if (!exec.getJobInstance().equals(jobInstance)) { continue; } if (lastExec == null) { lastExec = exec; } if (lastExec.getCreateTime().before(exec.getCreateTime())) { lastExec = exec; } } return copy(lastExec); }
@Override public Set<JobExecution> findRunningJobExecutions(String jobName) { Set<JobExecution> result = new HashSet<>(); for (JobExecution exec : executionsById.values()) { if (!exec.getJobInstance().getJobName().equals(jobName) || !exec.isRunning()) { continue; } result.add(copy(exec)); } return result; }
@Transactional @Test public void testCreateAndFindWithNoStartDate() throws Exception { job.setRestartable(true); JobExecution firstExecution = jobRepository.createJobExecution(job.getName(), jobParameters); firstExecution.setStartTime(new Date(0)); firstExecution.setEndTime(new Date(1)); jobRepository.update(firstExecution); JobExecution secondExecution = jobRepository.createJobExecution(job.getName(), jobParameters); assertEquals(firstExecution.getJobInstance(), secondExecution.getJobInstance()); assertEquals(job.getName(), secondExecution.getJobInstance().getJobName()); }
public JobInstanceInfoResource(JobInstance jobInstance, List<JobExecutionInfoResource> jobExecutionInfoResources) { this.jobName = jobInstance.getJobName(); this.instanceId = jobInstance.getInstanceId(); this.jobExecutions = jobExecutionInfoResources; }
@Override public void beforeStep(StepExecution stepExecution) { this.jobName = stepExecution.getJobExecution().getJobInstance().getJobName().trim(); this.stepName = (String) stepExecution.getJobExecution().getExecutionContext().get("stepName"); this.stepExecution = stepExecution; stepExecution.getJobExecution().getExecutionContext().remove("stepName"); }
@Test(expected = JobExecutionAlreadyRunningException.class) public void testAbortNonStopping() throws Exception { JobInstance jobInstance = new JobInstance(123L, job.getName()); JobExecution jobExecution = new JobExecution(jobInstance, 111L, jobParameters, null); jobExecution.setStatus(BatchStatus.STARTED); when(jobExplorer.getJobExecution(123L)).thenReturn(jobExecution); jobRepository.update(jobExecution); jobOperator.abandon(123L); }
@Override public List<JobExecution> findJobExecutions(JobInstance jobInstance) { List<JobExecution> executions = new ArrayList<>(); for (JobExecution exec : executionsById.values()) { if (exec.getJobInstance().equals(jobInstance)) { executions.add(copy(exec)); } } Collections.sort(executions, new Comparator<JobExecution>() { @Override public int compare(JobExecution e1, JobExecution e2) { long result = (e1.getId() - e2.getId()); if (result > 0) { return -1; } else if (result < 0) { return 1; } else { return 0; } } }); return executions; }
@Before public void setUp() { jobExecution = new JobExecution(1L); JobInstance jobInstance = new JobInstance(2L, "job"); jobExecution.setJobInstance(jobInstance); context = new JobContext(jobExecution); list = new ArrayList<>(); }
@Test public void testGetJobExecutionsRoseyScenario() { org.springframework.batch.core.JobInstance jobInstance = new org.springframework.batch.core.JobInstance(5L, "my job"); List<JobExecution> executions = new ArrayList<>(); executions.add(new JobExecution(2L)); when(jobExplorer.getJobExecutions(jobInstance)).thenReturn(executions); List<javax.batch.runtime.JobExecution> jobExecutions = jsrJobOperator.getJobExecutions(jobInstance); assertEquals(1, jobExecutions.size()); assertEquals(2L, executions.get(0).getId().longValue()); }
@Transactional @Test public void testCreateAndGetById() throws Exception { JobInstance fooInstance = dao.createJobInstance(fooJob, fooParams); assertNotNull(fooInstance.getId()); assertEquals(fooJob, fooInstance.getJobName()); JobInstance retrievedInstance = dao.getJobInstance(fooInstance.getId()); assertEquals(fooInstance, retrievedInstance); assertEquals(fooJob, retrievedInstance.getJobName()); }
/** * Test method for * {@link org.springframework.batch.core.JobExecution#getJobId()}. */ @Test public void testGetJobId() { assertEquals(11, execution.getJobId().longValue()); execution = new JobExecution(new JobInstance(new Long(23), "testJob"), null, new JobParameters(), null); assertEquals(23, execution.getJobId().longValue()); }