IN PROGRESS - issue BATCH-412: consistent ItemStream key prefixes
http://jira.springframework.org/browse/BATCH-412 all keys made private (not referenced outside tests)
This commit is contained in:
@@ -51,9 +51,9 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class HibernateCursorItemReader extends ExecutionContextUserSupport implements ItemReader, ItemStream, Skippable, InitializingBean {
|
||||
|
||||
private static final String RESTART_DATA_ROW_NUMBER_KEY = "rowNumber";
|
||||
private static final String RESTART_DATA_ROW_NUMBER_KEY = "row.number";
|
||||
|
||||
private static final String SKIPPED_ROWS = "skippedRows";
|
||||
private static final String SKIPPED_ROWS = "skipped.rows";
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
|
||||
@@ -109,11 +109,11 @@ public class JdbcCursorItemReader extends ExecutionContextUserSupport implements
|
||||
|
||||
public static final int VALUE_NOT_SET = -1;
|
||||
|
||||
private static final String CURRENT_PROCESSED_ROW = "lastProcessedRowNum";
|
||||
private static final String CURRENT_PROCESSED_ROW = "last.processed.row.number";
|
||||
|
||||
private static final String SKIPPED_ROWS = "skippedRows";
|
||||
private static final String SKIPPED_ROWS = "skipped.rows";
|
||||
|
||||
private static final String SKIP_COUNT = "skippedRrecordCount";
|
||||
private static final String SKIP_COUNT = "skipped.record.count";
|
||||
|
||||
private Connection con;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
*/
|
||||
public class IbatisKeyGenerator extends ExecutionContextUserSupport implements KeyGenerator {
|
||||
|
||||
public static final String RESTART_KEY = "keyIndex";
|
||||
private static final String RESTART_KEY = "key.index";
|
||||
|
||||
private SqlMapClientTemplate sqlMapClientTemplate;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.List;
|
||||
import org.springframework.batch.io.driving.DrivingQueryItemReader;
|
||||
import org.springframework.batch.io.driving.KeyGenerator;
|
||||
import org.springframework.batch.item.ExecutionContext;
|
||||
import org.springframework.batch.item.ExecutionContextUserSupport;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -37,9 +36,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see DrivingQueryItemReader
|
||||
* @since 1.0
|
||||
*/
|
||||
public class MultipleColumnJdbcKeyGenerator extends ExecutionContextUserSupport implements KeyGenerator {
|
||||
|
||||
public static final String RESTART_KEY = "key";
|
||||
public class MultipleColumnJdbcKeyGenerator implements KeyGenerator {
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@@ -50,7 +47,6 @@ public class MultipleColumnJdbcKeyGenerator extends ExecutionContextUserSupport
|
||||
private String restartSql;
|
||||
|
||||
public MultipleColumnJdbcKeyGenerator() {
|
||||
setName(MultipleColumnJdbcKeyGenerator.class.getSimpleName());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class SingleColumnJdbcKeyGenerator extends ExecutionContextUserSupport implements KeyGenerator {
|
||||
|
||||
public static final String RESTART_KEY = "key";
|
||||
private static final String RESTART_KEY = "key";
|
||||
|
||||
private JdbcTemplate jdbcTemplate;
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ public class FlatFileItemReader extends ExecutionContextUserSupport implements I
|
||||
|
||||
private static Log log = LogFactory.getLog(FlatFileItemReader.class);
|
||||
|
||||
public static final String READ_STATISTICS_NAME = "lines.read.count";
|
||||
private static final String READ_STATISTICS_NAME = "lines.read.count";
|
||||
|
||||
public static final String SKIPPED_STATISTICS_NAME = "skipped.lines.count";
|
||||
private static final String SKIPPED_STATISTICS_NAME = "skipped.lines.count";
|
||||
|
||||
// default encoding for input files
|
||||
public static final String DEFAULT_CHARSET = "ISO-8859-1";
|
||||
|
||||
@@ -71,11 +71,11 @@ public class FlatFileItemWriter extends ExecutionContextUserSupport implements I
|
||||
|
||||
private static final String LINE_SEPARATOR = System.getProperty("line.separator");
|
||||
|
||||
public static final String WRITTEN_STATISTICS_NAME = "written";
|
||||
private static final String WRITTEN_STATISTICS_NAME = "written";
|
||||
|
||||
public static final String RESTART_COUNT_STATISTICS_NAME = "restart.count";
|
||||
private static final String RESTART_COUNT_STATISTICS_NAME = "restart.count";
|
||||
|
||||
public static final String RESTART_DATA_NAME = "current.count";
|
||||
private static final String RESTART_DATA_NAME = "current.count";
|
||||
|
||||
private Resource resource;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
|
||||
public class StaxEventItemReader extends ExecutionContextUserSupport implements ItemReader, Skippable, ItemStream,
|
||||
InitializingBean {
|
||||
|
||||
public static final String READ_COUNT_STATISTICS_NAME = "readCount";
|
||||
private static final String READ_COUNT_STATISTICS_NAME = "read.count";
|
||||
|
||||
private FragmentEventReader fragmentReader;
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ public class StaxEventItemWriter extends ExecutionContextUserSupport implements
|
||||
private static final String DEFAULT_ROOT_TAG_NAME = "root";
|
||||
|
||||
// restart data property name
|
||||
public static final String RESTART_DATA_NAME = "position";
|
||||
private static final String RESTART_DATA_NAME = "position";
|
||||
|
||||
// restart data property name
|
||||
public static final String WRITE_STATISTICS_NAME = "record.count";
|
||||
private static final String WRITE_STATISTICS_NAME = "record.count";
|
||||
|
||||
// file system resource
|
||||
private Resource resource;
|
||||
|
||||
@@ -44,7 +44,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
|
||||
public void testRestoreKeys(){
|
||||
|
||||
executionContext.putString(SingleColumnJdbcKeyGenerator.RESTART_KEY, "3");
|
||||
executionContext.putString("key", "3");
|
||||
|
||||
List keys = keyStrategy.retrieveKeys(executionContext);
|
||||
|
||||
@@ -58,7 +58,7 @@ public class SingleColumnJdbcKeyGeneratorIntegrationTests extends AbstractTransa
|
||||
keyStrategy.saveState(new Long(3), executionContext);
|
||||
|
||||
assertEquals(1, executionContext.size());
|
||||
assertEquals("3", executionContext.getString(SingleColumnJdbcKeyGenerator.RESTART_KEY));
|
||||
assertEquals("3", executionContext.getString("key"));
|
||||
}
|
||||
|
||||
public void testGetNullKeyAsStreamContext(){
|
||||
|
||||
@@ -161,7 +161,7 @@ public class FlatFileItemReaderAdvancedTests extends TestCase {
|
||||
// get restart data
|
||||
reader.update(executionContext);
|
||||
assertEquals(4, executionContext.getLong(
|
||||
FlatFileItemReader.class.getSimpleName() + "." + FlatFileItemReader.READ_STATISTICS_NAME));
|
||||
FlatFileItemReader.class.getSimpleName() + ".lines.read.count"));
|
||||
// close input
|
||||
reader.close(executionContext);
|
||||
|
||||
@@ -175,7 +175,7 @@ public class FlatFileItemReaderAdvancedTests extends TestCase {
|
||||
assertEquals("[testLine6]", reader.read().toString());
|
||||
|
||||
reader.update(executionContext);
|
||||
assertEquals(6, executionContext.getLong(FlatFileItemReader.class.getSimpleName() + "." + FlatFileItemReader.READ_STATISTICS_NAME));
|
||||
assertEquals(6, executionContext.getLong(FlatFileItemReader.class.getSimpleName() + ".lines.read.count"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
}
|
||||
|
||||
// 3 lines were written to the file after restart
|
||||
assertEquals(3, executionContext.getLong(FlatFileItemWriter.class.getSimpleName() + "." + FlatFileItemWriter.WRITTEN_STATISTICS_NAME));
|
||||
assertEquals(3, executionContext.getLong(FlatFileItemWriter.class.getSimpleName() + ".written"));
|
||||
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ public class FlatFileItemWriterTests extends TestCase {
|
||||
inputSource.update(executionContext);
|
||||
assertNotNull(executionContext);
|
||||
assertEquals(3, executionContext.entrySet().size());
|
||||
assertEquals(0, executionContext.getLong(FlatFileItemWriter.class.getSimpleName() + "." + FlatFileItemWriter.RESTART_DATA_NAME));
|
||||
assertEquals(0, executionContext.getLong(FlatFileItemWriter.class.getSimpleName() + ".current.count"));
|
||||
}
|
||||
|
||||
private void commit() throws Exception {
|
||||
|
||||
@@ -119,7 +119,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
source.read();
|
||||
source.update(executionContext);
|
||||
System.out.println(executionContext);
|
||||
assertEquals(1, executionContext.getLong(StaxEventItemReader.class.getSimpleName() + "." + StaxEventItemReader.READ_COUNT_STATISTICS_NAME));
|
||||
assertEquals(1, executionContext.getLong(StaxEventItemReader.class.getSimpleName() + ".read.count"));
|
||||
List expectedAfterRestart = (List) source.read();
|
||||
|
||||
source = createNewInputSouce();
|
||||
@@ -134,7 +134,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
*/
|
||||
public void testInvalidRestore() {
|
||||
ExecutionContext context = new ExecutionContext();
|
||||
context.putLong(StaxEventItemReader.class.getSimpleName() + "." + StaxEventItemReader.READ_COUNT_STATISTICS_NAME, 100000);
|
||||
context.putLong(StaxEventItemReader.class.getSimpleName() + ".read.count", 100000);
|
||||
try {
|
||||
source.open(context);
|
||||
fail("Expected StreamException");
|
||||
@@ -214,7 +214,7 @@ public class StaxEventItemReaderTests extends TestCase {
|
||||
}
|
||||
|
||||
private long extractRecordCount() {
|
||||
return executionContext.getLong(StaxEventItemReader.class.getSimpleName() + "." + StaxEventItemReader.READ_COUNT_STATISTICS_NAME);
|
||||
return executionContext.getLong(StaxEventItemReader.class.getSimpleName() + ".read.count");
|
||||
}
|
||||
|
||||
public void testCloseWithoutOpen() throws Exception {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class StaxEventItemWriterTests extends TestCase {
|
||||
for (int i = 1; i <= NUMBER_OF_RECORDS; i++) {
|
||||
writer.write(record);
|
||||
writer.update(executionContext);
|
||||
long writeStatistics = executionContext.getLong(StaxEventItemWriter.class.getSimpleName() + "." + StaxEventItemWriter.WRITE_STATISTICS_NAME);
|
||||
long writeStatistics = executionContext.getLong(StaxEventItemWriter.class.getSimpleName() + ".record.count");
|
||||
|
||||
assertEquals(i, writeStatistics);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user