IN PROGRESS - BATCH-858: Pause / resume of Job
used same tx isolation for getLastJobExecution(..) as for createJobExecution(..) added simple functional test with JobOperator (same id returned after pause and resume)
This commit is contained in:
@@ -29,8 +29,6 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, InitializingBean {
|
||||
|
||||
|
||||
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
private ProxyFactory proxyFactory;
|
||||
@@ -103,6 +101,7 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
|
||||
proxyFactory = new ProxyFactory();
|
||||
TransactionInterceptor advice = new TransactionInterceptor(transactionManager, PropertiesConverter
|
||||
.stringToProperties("create*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate
|
||||
+ "\ngetLastJobExecution*=PROPAGATION_REQUIRES_NEW," + isolationLevelForCreate
|
||||
+ "\n*=PROPAGATION_REQUIRED"));
|
||||
DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor(advice);
|
||||
NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
|
||||
@@ -113,23 +112,23 @@ public abstract class AbstractJobRepositoryFactoryBean implements FactoryBean, I
|
||||
proxyFactory.addInterface(JobRepository.class);
|
||||
proxyFactory.setTarget(getTarget());
|
||||
}
|
||||
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(transactionManager, "TransactionManager must not be null.");
|
||||
|
||||
initializeProxy();
|
||||
|
||||
initializeProxy();
|
||||
}
|
||||
|
||||
private Object getTarget() throws Exception {
|
||||
return new SimpleJobRepository(createJobInstanceDao(), createJobExecutionDao(), createStepExecutionDao(),
|
||||
createExecutionContextDao());
|
||||
}
|
||||
|
||||
|
||||
public Object getObject() throws Exception {
|
||||
if (proxyFactory==null) {
|
||||
if (proxyFactory == null) {
|
||||
afterPropertiesSet();
|
||||
}
|
||||
return proxyFactory.getProxy();
|
||||
}
|
||||
return proxyFactory.getProxy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,6 +83,31 @@ public class RemoteLauncherTests {
|
||||
assertTrue(launcher.getJobNames().contains("loopJob"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPauseJob() throws Exception {
|
||||
final int SLEEP_INTERVAL = 500;
|
||||
assertTrue(isConnected());
|
||||
assertTrue(launcher.getJobNames().contains("loopJob"));
|
||||
long executionId = launcher.start("loopJob", "");
|
||||
|
||||
// sleep long enough to avoid race conditions (serializable tx isolation
|
||||
// doesn't work with HSQL)
|
||||
Thread.sleep(SLEEP_INTERVAL);
|
||||
launcher.pause(executionId);
|
||||
|
||||
Thread.sleep(SLEEP_INTERVAL);
|
||||
long resumedId = launcher.resume(executionId);
|
||||
assertEquals("Picked up the same execution after pause and resume", executionId, resumedId);
|
||||
|
||||
// launcher.pause(executionId);
|
||||
// Thread.sleep(SLEEP_INTERVAL);
|
||||
// long resumeId2 = launcher.resume(executionId);
|
||||
// assertEquals("Picked up the same execution after pause and resume", executionId, resumeId2);
|
||||
|
||||
launcher.stop(executionId);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user