RESOLVED - issue BATCH-646: Step/Job Execution DAO's EXIT_MESSAGE_LENGTH change to configurable
This commit is contained in:
@@ -36,7 +36,7 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
|
||||
private static final Log logger = LogFactory.getLog(JdbcJobExecutionDao.class);
|
||||
|
||||
private static final int EXIT_MESSAGE_LENGTH = 250;
|
||||
private static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500;
|
||||
|
||||
private static final String GET_JOB_EXECUTION_COUNT = "SELECT count(JOB_EXECUTION_ID) from %PREFIX%JOB_EXECUTION "
|
||||
+ "where JOB_INSTANCE_ID = ?";
|
||||
@@ -55,12 +55,23 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
private static final String GET_LAST_EXECUTION = "SELECT JOB_EXECUTION_ID, START_TIME, END_TIME, STATUS, CONTINUABLE, EXIT_CODE, EXIT_MESSAGE from %PREFIX%JOB_EXECUTION"
|
||||
+ " where JOB_INSTANCE_ID = ? and START_TIME = (SELECT max(START_TIME) from %PREFIX%JOB_EXECUTION where JOB_INSTANCE_ID = ?)";
|
||||
|
||||
private int exitMessageLength = DEFAULT_EXIT_MESSAGE_LENGTH;
|
||||
|
||||
private DataFieldMaxValueIncrementer jobExecutionIncrementer;
|
||||
|
||||
private LobHandler lobHandler = new DefaultLobHandler();
|
||||
|
||||
private JdbcExecutionContextDao ecDao = new JdbcExecutionContextDao();
|
||||
|
||||
/**
|
||||
* Public setter for the exit message length in database. Do not set this if
|
||||
* you haven't modified the schema.
|
||||
* @param exitMessageLength the exitMessageLength to set
|
||||
*/
|
||||
public void setExitMessageLength(int exitMessageLength) {
|
||||
this.exitMessageLength = exitMessageLength;
|
||||
}
|
||||
|
||||
public List findJobExecutions(final JobInstance job) {
|
||||
|
||||
Assert.notNull(job, "Job cannot be null.");
|
||||
@@ -140,8 +151,8 @@ public class JdbcJobExecutionDao extends AbstractJdbcBatchMetadataDao implements
|
||||
jobExecution.incrementVersion();
|
||||
|
||||
String exitDescription = jobExecution.getExitStatus().getExitDescription();
|
||||
if (exitDescription != null && exitDescription.length() > EXIT_MESSAGE_LENGTH) {
|
||||
exitDescription = exitDescription.substring(0, EXIT_MESSAGE_LENGTH);
|
||||
if (exitDescription != null && exitDescription.length() > exitMessageLength) {
|
||||
exitDescription = exitDescription.substring(0, exitMessageLength);
|
||||
logger.debug("Truncating long message before update of JobExecution: " + jobExecution);
|
||||
}
|
||||
Object[] parameters = new Object[] { jobExecution.getStartTime(), jobExecution.getEndTime(),
|
||||
|
||||
@@ -58,14 +58,25 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
|
||||
private static final String CURRENT_VERSION_STEP_EXECUTION = "SELECT VERSION FROM %PREFIX%STEP_EXECUTION WHERE STEP_EXECUTION_ID=?";
|
||||
|
||||
private static final int EXIT_MESSAGE_LENGTH = 250;
|
||||
private static final int DEFAULT_EXIT_MESSAGE_LENGTH = 2500;
|
||||
|
||||
private int exitMessageLength = DEFAULT_EXIT_MESSAGE_LENGTH;
|
||||
|
||||
private LobHandler lobHandler = new DefaultLobHandler();
|
||||
|
||||
private DataFieldMaxValueIncrementer stepExecutionIncrementer;
|
||||
|
||||
|
||||
private JdbcExecutionContextDao ecDao = new JdbcExecutionContextDao();
|
||||
|
||||
/**
|
||||
* Public setter for the exit message length in database. Do not set this if
|
||||
* you haven't modified the schema.
|
||||
* @param exitMessageLength the exitMessageLength to set
|
||||
*/
|
||||
public void setExitMessageLength(int exitMessageLength) {
|
||||
this.exitMessageLength = exitMessageLength;
|
||||
}
|
||||
|
||||
public ExecutionContext findExecutionContext(final StepExecution stepExecution) {
|
||||
|
||||
return ecDao.getExecutionContext(stepExecution);
|
||||
@@ -86,7 +97,7 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
"to-be-saved (not updated) StepExecution can't already have a version assigned");
|
||||
|
||||
validateStepExecution(stepExecution);
|
||||
|
||||
|
||||
String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription());
|
||||
|
||||
stepExecution.setId(new Long(stepExecutionIncrementer.nextLongValue()));
|
||||
@@ -95,8 +106,8 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(),
|
||||
stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(),
|
||||
stepExecution.getItemCount(), stepExecution.getExitStatus().isContinuable() ? "Y" : "N",
|
||||
stepExecution.getExitStatus().getExitCode(), exitDescription,
|
||||
stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount() };
|
||||
stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(),
|
||||
stepExecution.getWriteSkipCount(), stepExecution.getRollbackCount() };
|
||||
getJdbcTemplate().update(
|
||||
getQuery(SAVE_STEP_EXECUTION),
|
||||
parameters,
|
||||
@@ -131,8 +142,6 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
ecDao.saveOrUpdateExecutionContext(stepExecution);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.batch.execution.repository.dao.StepExecutionDao#updateStepExecution(org.springframework.batch.core.domain.StepExecution)
|
||||
@@ -187,9 +196,9 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement
|
||||
* @return truncated description
|
||||
*/
|
||||
private String truncateExitDescription(String description) {
|
||||
if (description != null && description.length() > EXIT_MESSAGE_LENGTH) {
|
||||
if (description != null && description.length() > exitMessageLength) {
|
||||
logger.debug("Truncating long message before update of StepExecution, original message is: " + description);
|
||||
return description.substring(0, EXIT_MESSAGE_LENGTH);
|
||||
return description.substring(0, exitMessageLength);
|
||||
}
|
||||
else {
|
||||
return description;
|
||||
|
||||
Reference in New Issue
Block a user