From 740d299c809e59e9bca34b48abba4bcafa628fff Mon Sep 17 00:00:00 2001 From: robokaso Date: Wed, 3 Sep 2008 12:32:37 +0000 Subject: [PATCH] IN PROGRESS - BATCH-774: Split item count into read/write/filter made read/filter/write counts persistent --- .../repository/dao/JdbcStepExecutionDao.java | 69 +++++++++++-------- .../src/main/resources/schema-db2.sql | 4 +- .../src/main/resources/schema-derby.sql | 4 +- .../src/main/resources/schema-hsqldb.sql | 4 +- .../src/main/resources/schema-mysql.sql | 4 +- .../src/main/resources/schema-oracle10g.sql | 4 +- .../src/main/resources/schema-postgresql.sql | 4 +- .../src/main/resources/schema-sqlserver.sql | 4 +- .../src/main/resources/schema-sybase.sql | 4 +- .../src/main/sql/tables-main.sql.vpp | 4 +- .../dao/AbstractStepExecutionDaoTests.java | 6 ++ 11 files changed, 72 insertions(+), 39 deletions(-) diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java index 916cf456d..d2123fdad 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDao.java @@ -41,19 +41,19 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement private static final Log logger = LogFactory.getLog(JdbcStepExecutionDao.class); private static final String SAVE_STEP_EXECUTION = "INSERT into %PREFIX%STEP_EXECUTION(STEP_EXECUTION_ID, VERSION, STEP_NAME, JOB_EXECUTION_ID, START_TIME, " - + "END_TIME, STATUS, COMMIT_COUNT, ITEM_COUNT, CONTINUABLE, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED) " - + "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; + + "END_TIME, STATUS, COMMIT_COUNT, READ_COUNT, FILTER_COUNT, WRITE_COUNT, CONTINUABLE, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED) " + + "values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; private static final String UPDATE_STEP_EXECUTION = "UPDATE %PREFIX%STEP_EXECUTION set START_TIME = ?, END_TIME = ?, " - + "STATUS = ?, COMMIT_COUNT = ?, ITEM_COUNT = ?, CONTINUABLE = ? , EXIT_CODE = ?, " - + "EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ?" + - " where STEP_EXECUTION_ID = ? and VERSION = ?"; + + "STATUS = ?, COMMIT_COUNT = ?, READ_COUNT = ?, FILTER_COUNT = ?, WRITE_COUNT = ?, CONTINUABLE = ? , EXIT_CODE = ?, " + + "EXIT_MESSAGE = ?, VERSION = ?, READ_SKIP_COUNT = ?, WRITE_SKIP_COUNT = ?, ROLLBACK_COUNT = ?, LAST_UPDATED = ?" + + " where STEP_EXECUTION_ID = ? and VERSION = ?"; private static final String GET_RAW_STEP_EXECUTIONS = "SELECT STEP_EXECUTION_ID, STEP_NAME, START_TIME, END_TIME, STATUS, COMMIT_COUNT," - + " ITEM_COUNT, CONTINUABLE, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID = ?"; + + " READ_COUNT, FILTER_COUNT, WRITE_COUNT, CONTINUABLE, EXIT_CODE, EXIT_MESSAGE, READ_SKIP_COUNT, WRITE_SKIP_COUNT, ROLLBACK_COUNT, LAST_UPDATED from %PREFIX%STEP_EXECUTION where JOB_EXECUTION_ID = ?"; private static final String GET_STEP_EXECUTIONS = GET_RAW_STEP_EXECUTIONS + " order by STEP_EXECUTION_ID"; - + private static final String GET_STEP_EXECUTION = GET_RAW_STEP_EXECUTIONS + " and STEP_NAME = ?"; private static final String CURRENT_VERSION_STEP_EXECUTION = "SELECT VERSION FROM %PREFIX%STEP_EXECUTION WHERE STEP_EXECUTION_ID=?"; @@ -105,15 +105,17 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement Object[] parameters = new Object[] { stepExecution.getId(), stepExecution.getVersion(), 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.getLastUpdated() }; + stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), + stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), + exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), + stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; getJdbcTemplate().getJdbcOperations().update( getQuery(SAVE_STEP_EXECUTION), parameters, new int[] { Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.INTEGER, Types.TIMESTAMP, - Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.CHAR, Types.VARCHAR, - Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }); + Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, + Types.CHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, + Types.TIMESTAMP }); } /** @@ -132,7 +134,9 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement /* * (non-Javadoc) - * @see org.springframework.batch.execution.repository.dao.StepExecutionDao#updateStepExecution(org.springframework.batch.core.domain.StepExecution) + * + * @seeorg.springframework.batch.execution.repository.dao.StepExecutionDao# + * updateStepExecution(org.springframework.batch.core.domain.StepExecution) */ public void updateStepExecution(StepExecution stepExecution) { @@ -151,18 +155,21 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement Integer version = new Integer(stepExecution.getVersion().intValue() + 1); Object[] parameters = new Object[] { stepExecution.getStartTime(), stepExecution.getEndTime(), - stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getItemCount(), + stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), + stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().isContinuable() ? "Y" : "N", stepExecution.getExitStatus().getExitCode(), exitDescription, version, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), - stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), + stepExecution.getRollbackCount(), stepExecution.getLastUpdated(), stepExecution.getId(), stepExecution.getVersion() }; - int count = getJdbcTemplate().getJdbcOperations().update( - getQuery(UPDATE_STEP_EXECUTION), - parameters, - new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, - Types.CHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, - Types.INTEGER, Types.TIMESTAMP, Types.INTEGER, Types.INTEGER }); + int count = getJdbcTemplate().getJdbcOperations() + .update( + getQuery(UPDATE_STEP_EXECUTION), + parameters, + new int[] { Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, + Types.INTEGER, Types.INTEGER, Types.CHAR, Types.VARCHAR, Types.VARCHAR, + Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP, + Types.INTEGER, Types.INTEGER }); // Avoid concurrent modifications... if (count == 0) { @@ -207,13 +214,13 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement return (StepExecution) executions.get(0); } } - + public List getStepExecutions(JobExecution jobExecution) { List executions = getJdbcTemplate().query(getQuery(GET_STEP_EXECUTIONS), new StepExecutionRowMapper(jobExecution), jobExecution.getId()); return executions; } - + private class StepExecutionRowMapper implements ParameterizedRowMapper { private final JobExecution jobExecution; @@ -228,15 +235,17 @@ public class JdbcStepExecutionDao extends AbstractJdbcBatchMetadataDao implement stepExecution.setEndTime(rs.getTimestamp(4)); stepExecution.setStatus(BatchStatus.valueOf(rs.getString(5))); stepExecution.setCommitCount(rs.getInt(6)); - stepExecution.setItemCount(rs.getInt(7)); - stepExecution.setExitStatus(new ExitStatus("Y".equals(rs.getString(8)), rs.getString(9), rs.getString(10))); - stepExecution.setReadSkipCount(rs.getInt(11)); - stepExecution.setWriteSkipCount(rs.getInt(12)); - stepExecution.setRollbackCount(rs.getInt(13)); - stepExecution.setLastUpdated(rs.getTimestamp(14)); + stepExecution.setReadCount(rs.getInt(7)); + stepExecution.setFilterCount(rs.getInt(8)); + stepExecution.setWriteCount(rs.getInt(9)); + stepExecution.setExitStatus(new ExitStatus("Y".equals(rs.getString(10)), rs.getString(11), rs.getString(12))); + stepExecution.setReadSkipCount(rs.getInt(13)); + stepExecution.setWriteSkipCount(rs.getInt(14)); + stepExecution.setRollbackCount(rs.getInt(15)); + stepExecution.setLastUpdated(rs.getTimestamp(16)); return stepExecution; } } - + } diff --git a/spring-batch-core/src/main/resources/schema-db2.sql b/spring-batch-core/src/main/resources/schema-db2.sql index 63fd47f1f..a4953f746 100644 --- a/spring-batch-core/src/main/resources/schema-db2.sql +++ b/spring-batch-core/src/main/resources/schema-db2.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-derby.sql b/spring-batch-core/src/main/resources/schema-derby.sql index 749409b40..0ffa3c7b7 100644 --- a/spring-batch-core/src/main/resources/schema-derby.sql +++ b/spring-batch-core/src/main/resources/schema-derby.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-hsqldb.sql b/spring-batch-core/src/main/resources/schema-hsqldb.sql index ffc43f726..41a685272 100644 --- a/spring-batch-core/src/main/resources/schema-hsqldb.sql +++ b/spring-batch-core/src/main/resources/schema-hsqldb.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-mysql.sql b/spring-batch-core/src/main/resources/schema-mysql.sql index 14bd39af2..494ac4985 100644 --- a/spring-batch-core/src/main/resources/schema-mysql.sql +++ b/spring-batch-core/src/main/resources/schema-mysql.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME DATETIME DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-oracle10g.sql b/spring-batch-core/src/main/resources/schema-oracle10g.sql index d81864ac0..4648a4d27 100644 --- a/spring-batch-core/src/main/resources/schema-oracle10g.sql +++ b/spring-batch-core/src/main/resources/schema-oracle10g.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR2(10) , COMMIT_COUNT NUMBER(38) , - ITEM_COUNT NUMBER(38) , + READ_COUNT NUMBER(38) , + FILTER_COUNT NUMBER(38) , + WRITE_COUNT NUMBER(38) , READ_SKIP_COUNT NUMBER(38) , WRITE_SKIP_COUNT NUMBER(38) , ROLLBACK_COUNT NUMBER(38) , diff --git a/spring-batch-core/src/main/resources/schema-postgresql.sql b/spring-batch-core/src/main/resources/schema-postgresql.sql index 1bc2d6d0e..8255504fd 100644 --- a/spring-batch-core/src/main/resources/schema-postgresql.sql +++ b/spring-batch-core/src/main/resources/schema-postgresql.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME TIMESTAMP DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-sqlserver.sql b/spring-batch-core/src/main/resources/schema-sqlserver.sql index c993d55c1..5d1330039 100644 --- a/spring-batch-core/src/main/resources/schema-sqlserver.sql +++ b/spring-batch-core/src/main/resources/schema-sqlserver.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME DATETIME DEFAULT NULL , STATUS VARCHAR(10) , COMMIT_COUNT BIGINT , - ITEM_COUNT BIGINT , + READ_COUNT BIGINT , + FILTER_COUNT BIGINT , + WRITE_COUNT BIGINT , READ_SKIP_COUNT BIGINT , WRITE_SKIP_COUNT BIGINT , ROLLBACK_COUNT BIGINT , diff --git a/spring-batch-core/src/main/resources/schema-sybase.sql b/spring-batch-core/src/main/resources/schema-sybase.sql index 8b4cf69be..01dbca5fb 100644 --- a/spring-batch-core/src/main/resources/schema-sybase.sql +++ b/spring-batch-core/src/main/resources/schema-sybase.sql @@ -54,7 +54,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME DATETIME DEFAULT NULL NULL, STATUS VARCHAR(10) NULL, COMMIT_COUNT BIGINT NULL, - ITEM_COUNT BIGINT NULL, + READ_COUNT BIGINT NULL, + FILTER_COUNT BIGINT NULL, + WRITE_COUNT BIGINT NULL, READ_SKIP_COUNT BIGINT NULL, WRITE_SKIP_COUNT BIGINT NULL, ROLLBACK_COUNT BIGINT NULL, diff --git a/spring-batch-core/src/main/sql/tables-main.sql.vpp b/spring-batch-core/src/main/sql/tables-main.sql.vpp index 463178797..1826959b3 100644 --- a/spring-batch-core/src/main/sql/tables-main.sql.vpp +++ b/spring-batch-core/src/main/sql/tables-main.sql.vpp @@ -42,7 +42,9 @@ CREATE TABLE BATCH_STEP_EXECUTION ( END_TIME ${TIMESTAMP} DEFAULT NULL $!{NULL}, STATUS ${VARCHAR}(10) $!{NULL}, COMMIT_COUNT ${BIGINT} $!{NULL}, - ITEM_COUNT ${BIGINT} $!{NULL}, + READ_COUNT ${BIGINT} $!{NULL}, + FILTER_COUNT ${BIGINT} $!{NULL}, + WRITE_COUNT ${BIGINT} $!{NULL}, READ_SKIP_COUNT ${BIGINT} $!{NULL}, WRITE_SKIP_COUNT ${BIGINT} $!{NULL}, ROLLBACK_COUNT ${BIGINT} $!{NULL}, diff --git a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java index d0117c25f..b3fa9a1d6 100644 --- a/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java +++ b/spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/AbstractStepExecutionDaoTests.java @@ -99,6 +99,9 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona stepExecution.setWriteSkipCount(5); stepExecution.setRollbackCount(3); stepExecution.setLastUpdated(new Date(System.currentTimeMillis())); + stepExecution.setReadCount(17); + stepExecution.setFilterCount(15); + stepExecution.setWriteCount(13); dao.saveStepExecution(stepExecution); StepExecution retrieved = dao.getStepExecution(jobExecution, step.getName()); @@ -108,6 +111,9 @@ public abstract class AbstractStepExecutionDaoTests extends AbstractTransactiona assertEquals(stepExecution.getWriteSkipCount(), retrieved.getWriteSkipCount()); assertEquals(stepExecution.getRollbackCount(), retrieved.getRollbackCount()); assertEquals(stepExecution.getLastUpdated(), retrieved.getLastUpdated()); + assertEquals(stepExecution.getReadCount(), retrieved.getReadCount()); + assertEquals(stepExecution.getFilterCount(), retrieved.getFilterCount()); + assertEquals(stepExecution.getWriteCount(), retrieved.getWriteCount()); assertNull(dao.getStepExecution(jobExecution, "not-existing step")); }