Change the return type of counting methods in various DAOs from int to long
This is required for job repository/explorer implementations that use the Long type to count records in the database. Resolves #4227
This commit is contained in:
@@ -153,6 +153,6 @@ public interface JobExplorer {
|
||||
* @throws NoSuchJobException thrown when there is no {@link JobInstance} for the
|
||||
* jobName specified.
|
||||
*/
|
||||
int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
|
||||
long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
|
||||
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ public class SimpleJobExplorer implements JobExplorer {
|
||||
* String)
|
||||
*/
|
||||
@Override
|
||||
public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
public long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
return jobInstanceDao.getJobInstanceCount(jobName);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2018 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -84,7 +84,7 @@ public class JobFlowExecutor implements FlowExecutor {
|
||||
}
|
||||
|
||||
private boolean isStepRestart(Step step) {
|
||||
int count = jobRepository.getStepExecutionCount(execution.getJobInstance(), step.getName());
|
||||
long count = jobRepository.getStepExecutionCount(execution.getJobInstance(), step.getName());
|
||||
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ public interface JobRepository {
|
||||
* @param stepName the name of the step execution that might have run.
|
||||
* @return the execution count of the step within the given job instance.
|
||||
*/
|
||||
int getStepExecutionCount(JobInstance jobInstance, String stepName);
|
||||
long getStepExecutionCount(JobInstance jobInstance, String stepName);
|
||||
|
||||
/**
|
||||
* @param jobName the name of the job that might have run
|
||||
|
||||
@@ -268,10 +268,10 @@ public class JdbcJobInstanceDao extends AbstractJdbcBatchMetadataDao implements
|
||||
* java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
public long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
|
||||
try {
|
||||
return getJdbcTemplate().queryForObject(getQuery(COUNT_JOBS_WITH_NAME), Integer.class, jobName);
|
||||
return getJdbcTemplate().queryForObject(getQuery(COUNT_JOBS_WITH_NAME), Long.class, jobName);
|
||||
}
|
||||
catch (EmptyResultDataAccessException e) {
|
||||
throw new NoSuchJobException("No job instances were found for job name " + jobName);
|
||||
|
||||
@@ -358,8 +358,8 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countStepExecutions(JobInstance jobInstance, String stepName) {
|
||||
return getJdbcTemplate().queryForObject(getQuery(COUNT_STEP_EXECUTIONS), Integer.class,
|
||||
public long countStepExecutions(JobInstance jobInstance, String stepName) {
|
||||
return getJdbcTemplate().queryForObject(getQuery(COUNT_STEP_EXECUTIONS), Long.class,
|
||||
jobInstance.getInstanceId(), stepName);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ public interface JobInstanceDao {
|
||||
* repository
|
||||
* @throws NoSuchJobException thrown if no Job has the jobName specified.
|
||||
*/
|
||||
int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
|
||||
long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException;
|
||||
|
||||
/**
|
||||
* Delete the job instance.
|
||||
|
||||
@@ -87,7 +87,7 @@ public interface StepExecutionDao {
|
||||
* @since 4.3
|
||||
* @return the count of {@link StepExecution}s for a given step
|
||||
*/
|
||||
default int countStepExecutions(JobInstance jobInstance, String stepName) {
|
||||
default long countStepExecutions(JobInstance jobInstance, String stepName) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ public class SimpleJobRepository implements JobRepository {
|
||||
* @return number of executions of the step within given job instance
|
||||
*/
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return stepExecutionDao.countStepExecutions(jobInstance, stepName);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public class DummyJobRepository implements JobRepository, BeanNameAware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class TaskletStepAllowStartIfCompleteTests {
|
||||
jobExecution = jobRepository.createJobExecution(job.getName(), paramBuilder.toJobParameters());
|
||||
job.execute(jobExecution);
|
||||
|
||||
int count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1");
|
||||
long count = jobRepository.getStepExecutionCount(jobExecution.getJobInstance(), "simpleJob.step1");
|
||||
assertEquals(2, count);
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ class SimpleJobExplorerTests {
|
||||
|
||||
@Test
|
||||
void testGetJobInstanceCount() throws Exception {
|
||||
when(jobInstanceDao.getJobInstanceCount("myJob")).thenReturn(4);
|
||||
when(jobInstanceDao.getJobInstanceCount("myJob")).thenReturn(4L);
|
||||
|
||||
assertEquals(4, jobExplorer.getJobInstanceCount("myJob"));
|
||||
}
|
||||
|
||||
@@ -554,8 +554,8 @@ class CommandLineJobRunnerTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
int count = 0;
|
||||
public long getJobInstanceCount(@Nullable String jobName) throws NoSuchJobException {
|
||||
long count = 0;
|
||||
|
||||
for (JobInstance jobInstance : jobInstances) {
|
||||
if (jobInstance.getJobName().equals(jobName)) {
|
||||
|
||||
@@ -81,7 +81,7 @@ class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
|
||||
dao.saveStepExecution(stepExecution);
|
||||
|
||||
// When
|
||||
int result = dao.countStepExecutions(jobInstance, stepExecution.getStepName());
|
||||
long result = dao.countStepExecutions(jobInstance, stepExecution.getStepName());
|
||||
|
||||
// Then
|
||||
assertEquals(1, result);
|
||||
|
||||
@@ -277,11 +277,11 @@ class SimpleJobRepositoryTests {
|
||||
@Test
|
||||
void testGetStepExecutionCount() {
|
||||
// Given
|
||||
int expectedResult = 1;
|
||||
long expectedResult = 1;
|
||||
when(stepExecutionDao.countStepExecutions(jobInstance, "stepName")).thenReturn(expectedResult);
|
||||
|
||||
// When
|
||||
int actualResult = jobRepository.getStepExecutionCount(jobInstance, "stepName");
|
||||
long actualResult = jobRepository.getStepExecutionCount(jobInstance, "stepName");
|
||||
|
||||
// Then
|
||||
assertEquals(expectedResult, actualResult);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -73,7 +73,7 @@ public class JobRepositorySupport implements JobRepository {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -527,7 +527,7 @@ class TaskletStepExceptionTests {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006-2021 the original author or authors.
|
||||
* Copyright 2006-2022 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,7 +65,7 @@ public class JobRepositorySupport implements JobRepository {
|
||||
* org.springframework.batch.core.repository.JobRepository#getStepExecutionCount(org.
|
||||
* springframework.batch.core.JobInstance, org.springframework.batch.core.Step)
|
||||
*/
|
||||
public int getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
public long getStepExecutionCount(JobInstance jobInstance, String stepName) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user