IN PROGRESS - issue BATCH-7: Remove transaction synchronization and state management from input/output sources (formerly buffering)

http://jira.springframework.org/browse/BATCH-7

Remove references to RestartData
This commit is contained in:
dsyer
2008-01-31 13:41:37 +00:00
parent 8b6aad9d82
commit acc1460fb8
17 changed files with 94 additions and 99 deletions

View File

@@ -98,10 +98,6 @@ public class MapStepDao implements StepDao {
stepExecution.setId(new Long(currentId++));
executions.add(stepExecution);
}
public void saveRestartData(Long stepId, StreamContext streamContext) {
restartsById.put(stepId, streamContext);
}
public List findStepExecutions(StepInstance step) {
Set executions = (Set) executionsById.get(step.getId());

View File

@@ -185,9 +185,9 @@ public class SimpleStepExecutor {
// the conversation in StepScope
stepContext.setAttribute(StepScope.ID_KEY, stepExecution.getJobExecution().getId());
final boolean saveRestartData = step.isSaveStreamContext();
final boolean saveStreamContext = step.isSaveStreamContext();
if (saveRestartData && isRestart) {
if (saveStreamContext && isRestart) {
stepContext.setInitialStreamContext(stepInstance.getStreamContext());
}
@@ -233,7 +233,7 @@ public class SimpleStepExecutor {
// only if chunk was successful
stepExecution.apply(contribution);
if (saveRestartData) {
if (saveStreamContext) {
stepInstance.setStreamContext(stepContext.getStreamContext());
jobRepository.update(stepInstance);
}

View File

@@ -22,7 +22,6 @@ import org.springframework.batch.core.domain.JobInstance;
import org.springframework.batch.core.domain.StepExecution;
import org.springframework.batch.core.domain.StepInstance;
import org.springframework.batch.execution.repository.dao.StepDao;
import org.springframework.batch.item.StreamContext;
public class MockStepDao implements StepDao {
@@ -46,10 +45,6 @@ public class MockStepDao implements StepDao {
return newSteps;
}
public StreamContext getRestartData(Long stepId) {
return null;
}
public int getStepExecutionCount(StepInstance step) {
return 1;
}
@@ -57,9 +52,6 @@ public class MockStepDao implements StepDao {
public void save(StepExecution stepExecution) {
}
public void saveRestartData(Long stepId, StreamContext streamContext) {
}
public void update(StepInstance step) {
}

View File

@@ -396,7 +396,7 @@ public class SimpleJobRepositoryTests extends TestCase {
* Test to ensure that if a StepDao returns invalid
* restart data, it is corrected.
*/
public void testCreateStepsFixesInvalidRestartData() throws Exception{
public void testCreateStepsFixesInvalidStreamContext() throws Exception{
List jobs = new ArrayList();
@@ -432,7 +432,7 @@ public class SimpleJobRepositoryTests extends TestCase {
assertTrue(step.getStreamContext().getProperties().isEmpty());
}
public void testFindStepsFixesInvalidRestartData() throws Exception{
public void testFindStepsFixesInvalidStreamContext() throws Exception{
List jobs = new ArrayList();
jobDao.findJobInstances(jobConfiguration.getName(), jobParameters);
jobs.add(databaseJob);

View File

@@ -139,7 +139,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
assertEquals(step3, tempStep);
}
public void testUpdateStepWithoutRestartData(){
public void testUpdateStepWithoutStreamContext(){
step1.setStatus(BatchStatus.COMPLETED);
stepDao.update(step1);
@@ -147,7 +147,7 @@ public abstract class AbstractStepDaoTests extends AbstractTransactionalDataSour
assertEquals(tempStep, step1);
}
public void testUpdateStepWithRestartData(){
public void testUpdateStepWithStreamContext(){
step1.setStatus(BatchStatus.COMPLETED);
Properties data = new Properties();

View File

@@ -106,7 +106,7 @@ public class MapStepDaoTests extends TestCase {
assertEquals(2, dao.getStepExecutionCount(step));
}
public void testSaveRestartData() throws Exception {
public void testSaveStreamContext() throws Exception {
assertEquals(null, dao.getStreamContext(step.getId()));
step.setStatus(BatchStatus.COMPLETED);
Properties data = new Properties();

View File

@@ -101,7 +101,7 @@ public class SimpleStepConfigurationTests extends TestCase {
* Test method for
* {@link org.springframework.batch.execution.step.simple.AbstractStep#isSaveStreamContext()}.
*/
public void testIsSaveRestartData() {
public void testIsSaveStreamContext() {
assertEquals(false, configuration.isSaveStreamContext());
configuration.setSaveStreamContext(true);
assertEquals(true, configuration.isSaveStreamContext());

View File

@@ -277,7 +277,7 @@ public class SimpleStepExecutorTests extends TestCase {
/*
* make sure a job that has never been executed before, but does have
* saveRestartData = true, doesn't have restoreFrom called on it.
* saveStreamContext = true, doesn't have restoreFrom called on it.
*/
public void testNonRestartedJob() throws Exception {
StepInstance step = new StepInstance(new Long(1));
@@ -290,7 +290,7 @@ public class SimpleStepExecutorTests extends TestCase {
stepExecutor.execute(stepExecution);
assertFalse(tasklet.isRestoreFromCalled());
assertTrue(tasklet.isGetRestartDataCalled());
assertTrue(tasklet.isGetStreamContextCalled());
}
/*
@@ -312,14 +312,14 @@ public class SimpleStepExecutorTests extends TestCase {
assertTrue(tasklet.isRestoreFromCalled());
assertTrue(tasklet.isRestoreFromCalledWithSomeContext());
assertTrue(tasklet.isGetRestartDataCalled());
assertTrue(tasklet.isGetStreamContextCalled());
}
/*
* Test that a job that is being restarted, but has saveRestartData set to
* false, doesn't have restore or getRestartData called on it.
* Test that a job that is being restarted, but has saveStreamContext set to
* false, doesn't have restore or getStreamContext called on it.
*/
public void testNoSaveRestartDataRestartableJob() {
public void testNoSaveStreamContextRestartableJob() {
StepInstance step = new StepInstance(new Long(1));
step.setStepExecutionCount(1);
MockRestartableTasklet tasklet = new MockRestartableTasklet();
@@ -336,11 +336,11 @@ public class SimpleStepExecutorTests extends TestCase {
}
assertFalse(tasklet.isRestoreFromCalled());
assertFalse(tasklet.isGetRestartDataCalled());
assertFalse(tasklet.isGetStreamContextCalled());
}
/*
* Even though the job is restarted, and saveRestartData is true, nothing
* Even though the job is restarted, and saveStreamContext is true, nothing
* will be restored because the Tasklet does not implement Restartable.
*/
public void testRestartJobOnNonRestartableTasklet() throws Exception {
@@ -430,7 +430,7 @@ public class SimpleStepExecutorTests extends TestCase {
private class MockRestartableTasklet implements Tasklet, ItemStream {
private boolean getRestartDataCalled = false;
private boolean getStreamContextCalled = false;
private boolean restoreFromCalled = false;
@@ -446,7 +446,7 @@ public class SimpleStepExecutorTests extends TestCase {
}
public StreamContext getStreamContext() {
getRestartDataCalled = true;
getStreamContextCalled = true;
return new GenericStreamContext(PropertiesConverter.stringToProperties("spam=bucket"));
}
@@ -455,8 +455,8 @@ public class SimpleStepExecutorTests extends TestCase {
restoreFromCalledWithSomeContext = data.getProperties().size() > 0;
}
public boolean isGetRestartDataCalled() {
return getRestartDataCalled;
public boolean isGetStreamContextCalled() {
return getStreamContextCalled;
}
public boolean isRestoreFromCalled() {