@Test public void testSaveStepExecutionSetsLastUpdated(){ StepExecution stepExecution = new StepExecution("stepName", jobExecution); long before = System.currentTimeMillis(); jobRepository.add(stepExecution); assertNotNull(stepExecution.getLastUpdated()); long lastUpdated = stepExecution.getLastUpdated().getTime(); assertTrue(lastUpdated > (before - 1000)); }
@Test public void testUpdateStepExecutionSetsLastUpdated(){ StepExecution stepExecution = new StepExecution("stepName", jobExecution); stepExecution.setId(2343L); long before = System.currentTimeMillis(); jobRepository.update(stepExecution); assertNotNull(stepExecution.getLastUpdated()); long lastUpdated = stepExecution.getLastUpdated().getTime(); assertTrue(lastUpdated > (before - 1000)); }
/** * Update and retrieve updated StepExecution - make sure the update is * reflected as expected and version number has been incremented */ @Transactional @Test public void testUpdateExecution() { stepExecution.setStatus(BatchStatus.STARTED); dao.saveStepExecution(stepExecution); Integer versionAfterSave = stepExecution.getVersion(); stepExecution.setStatus(BatchStatus.ABANDONED); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); dao.updateStepExecution(stepExecution); assertEquals(versionAfterSave + 1, stepExecution.getVersion().intValue()); StepExecution retrieved = dao.getStepExecution(jobExecution, stepExecution.getId()); assertEquals(stepExecution, retrieved); assertEquals(stepExecution.getLastUpdated(), retrieved.getLastUpdated()); assertEquals(BatchStatus.ABANDONED, retrieved.getStatus()); }
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; }
stepExecution.getReadSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; int count = getJdbcTemplate() .update(getQuery(UPDATE_STEP_EXECUTION),
private void assertStepExecutionsAreEqual(StepExecution expected, StepExecution actual) { assertEquals(expected.getId(), actual.getId()); assertEquals(expected.getStartTime(), actual.getStartTime()); assertEquals(expected.getEndTime(), actual.getEndTime()); assertEquals(expected.getSkipCount(), actual.getSkipCount()); assertEquals(expected.getCommitCount(), actual.getCommitCount()); assertEquals(expected.getReadCount(), actual.getReadCount()); assertEquals(expected.getWriteCount(), actual.getWriteCount()); assertEquals(expected.getFilterCount(), actual.getFilterCount()); assertEquals(expected.getWriteSkipCount(), actual.getWriteSkipCount()); assertEquals(expected.getReadSkipCount(), actual.getReadSkipCount()); assertEquals(expected.getProcessSkipCount(), actual.getProcessSkipCount()); assertEquals(expected.getRollbackCount(), actual.getRollbackCount()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertEquals(expected.getLastUpdated(), actual.getLastUpdated()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertEquals(expected.getJobExecutionId(), actual.getJobExecutionId()); }
private void assertStepExecutionsAreEqual(StepExecution expected, StepExecution actual) { assertEquals(expected.getId(), actual.getId()); assertEquals(expected.getStartTime(), actual.getStartTime()); assertEquals(expected.getEndTime(), actual.getEndTime()); assertEquals(expected.getSkipCount(), actual.getSkipCount()); assertEquals(expected.getCommitCount(), actual.getCommitCount()); assertEquals(expected.getReadCount(), actual.getReadCount()); assertEquals(expected.getWriteCount(), actual.getWriteCount()); assertEquals(expected.getFilterCount(), actual.getFilterCount()); assertEquals(expected.getWriteSkipCount(), actual.getWriteSkipCount()); assertEquals(expected.getReadSkipCount(), actual.getReadSkipCount()); assertEquals(expected.getProcessSkipCount(), actual.getProcessSkipCount()); assertEquals(expected.getRollbackCount(), actual.getRollbackCount()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertEquals(expected.getLastUpdated(), actual.getLastUpdated()); assertEquals(expected.getExitStatus(), actual.getExitStatus()); assertEquals(expected.getJobExecutionId(), actual.getJobExecutionId()); } }
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; }
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; }
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; }
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues,parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes,parameterTypes.length)); return parameters; }
this.lastUpdated = stepExecution.getLastUpdated(); this.startTime = stepExecution.getStartTime();
stepExecution.getReadSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; int count = getJdbcTemplate() .update(getQuery(UPDATE_STEP_EXECUTION),
stepExecution.getReadSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; int count = getJdbcTemplate() .update(getQuery(UPDATE_STEP_EXECUTION),
stepExecution.getReadSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; int count = getJdbcTemplate().getJdbcOperations() .update(
@Override public SimpleStep convert(StepExecution source, SimpleStep simpleStep) { SimpleStep target = simpleStep != null ? simpleStep : new SimpleStep(); target.stepName(source.getStepName()) .status(source.getStatus().toString()) .readCount(source.getReadCount()) .writeCount(source.getWriteCount()) .commitCount(source.getCommitCount()) .rollbackCount(source.getRollbackCount()) .readSkipCount(source.getReadSkipCount()) .processSkipCount(source.getProcessSkipCount()) .writeSkipCount(source.getWriteSkipCount()) .startTime(source.getStartTime()) .endTime(source.getEndTime()) .exitStatus(source.getExitStatus().toString()) .lastUpdated(source.getLastUpdated()) .exitStatus(source.getExitStatus().toString()); return target; } }
stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; getJdbcTemplate().getJdbcOperations().update( getQuery(SAVE_STEP_EXECUTION),
public static StepExecution map(final org.springframework.batch.core.StepExecution stepExecution) { final StepExecution response = new StepExecution(); response.setId(stepExecution.getId()); response.setVersion(stepExecution.getVersion()); response.setJobExecutionId(stepExecution.getJobExecutionId()); response.setStepName(stepExecution.getStepName()); response.setStatus(map(stepExecution.getStatus())); response.setReadCount(stepExecution.getReadCount()); response.setWriteCount(stepExecution.getWriteCount()); response.setCommitCount(stepExecution.getCommitCount()); response.setRollbackCount(stepExecution.getRollbackCount()); response.setReadSkipCount(stepExecution.getReadSkipCount()); response.setProcessSkipCount(stepExecution.getProcessSkipCount()); response.setWriteSkipCount(stepExecution.getWriteSkipCount()); response.setStartTime(stepExecution.getStartTime()); response.setEndTime(stepExecution.getEndTime()); response.setLastUpdated(stepExecution.getLastUpdated()); response.setExitStatus(map(stepExecution.getExitStatus())); response.setTerminateOnly(stepExecution.isTerminateOnly()); response.setFilterCount(stepExecution.getFilterCount()); response.setFailureExceptions(stepExecution.getFailureExceptions()); return response; }
public AdaptedStepExecution(StepExecution stepExec) { this.setId(stepExec.getId()); this.setJobInstanceId(stepExec.getJobExecution().getJobInstance().getId()); this.setStepName(stepExec.getStepName()); this.setStatus(stepExec.getStatus()); this.setReadSkipCount(stepExec.getReadSkipCount()); this.setWriteSkipCount(stepExec.getWriteSkipCount()); this.setProcessSkipCount(stepExec.getProcessSkipCount()); this.setRollbackCount(stepExec.getRollbackCount()); this.setJobExecutionId(stepExec.getJobExecutionId()); this.setReadCount(stepExec.getReadCount()); this.setWriteCount(stepExec.getWriteCount()); this.setFilterCount(stepExec.getFilterCount()); this.setVersion(stepExec.getVersion()); this.setExitStatus(stepExec.getExitStatus()); this.setVersion(stepExec.getVersion()); this.setJobName(stepExec.getJobExecution().getJobInstance().getJobName()); this.setStartTime(stepExec.getStartTime()); this.setEndTime(stepExec.getEndTime()); this.setLastUpdated(stepExec.getLastUpdated()); this.setExecutionContext(stepExec.getExecutionContext()); }
public static StepExecution map(final org.springframework.batch.core.StepExecution stepExecution) { final StepExecution response = new StepExecution(); response.setId(stepExecution.getId()); response.setVersion(stepExecution.getVersion()); response.setJobExecutionId(stepExecution.getJobExecutionId()); response.setStepName(stepExecution.getStepName()); response.setStatus(map(stepExecution.getStatus())); response.setReadCount(stepExecution.getReadCount()); response.setWriteCount(stepExecution.getWriteCount()); response.setCommitCount(stepExecution.getCommitCount()); response.setRollbackCount(stepExecution.getRollbackCount()); response.setReadSkipCount(stepExecution.getReadSkipCount()); response.setProcessSkipCount(stepExecution.getProcessSkipCount()); response.setWriteSkipCount(stepExecution.getWriteSkipCount()); response.setStartTime(stepExecution.getStartTime()); response.setEndTime(stepExecution.getEndTime()); response.setLastUpdated(stepExecution.getLastUpdated()); response.setExitStatus(map(stepExecution.getExitStatus())); response.setTerminateOnly(stepExecution.isTerminateOnly()); response.setFilterCount(stepExecution.getFilterCount()); response.setFailureExceptions(stepExecution.getFailureExceptions()); return response; }