本文整理匯總了Java中org.springframework.batch.core.JobExecution.setId方法的典型用法代碼示例。如果您正苦於以下問題:Java JobExecution.setId方法的具體用法?Java JobExecution.setId怎麽用?Java JobExecution.setId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.batch.core.JobExecution
的用法示例。
在下文中一共展示了JobExecution.setId方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testSynchronizeStatusUpgrade
import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
/**
* Successful synchronization from STARTED to STOPPING status.
*/
@Transactional
@Test
public void testSynchronizeStatusUpgrade() {
JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
exec1.setStatus(BatchStatus.STOPPING);
jobExecutionDao.saveJobExecution(exec1);
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
assertTrue(exec1.getId() != null);
exec2.setId(exec1.getId());
exec2.setStatus(BatchStatus.STARTED);
exec2.setVersion(7);
assertTrue(exec1.getVersion() != exec2.getVersion());
assertTrue(exec1.getStatus() != exec2.getStatus());
jobExecutionDao.synchronizeStatus(exec2);
assertEquals(exec1.getVersion(), exec2.getVersion());
assertEquals(exec1.getStatus(), exec2.getStatus());
}
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:27,代碼來源:MarkLogicJobExecutionDaoTests.java
示例2: testSynchronizeStatusDowngrade
import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
/**
* UNKNOWN status won't be changed by synchronizeStatus, because it is the
* 'largest' BatchStatus (will not downgrade).
*/
@Transactional
@Test
public void testSynchronizeStatusDowngrade() {
JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
exec1.setStatus(BatchStatus.STARTED);
jobExecutionDao.saveJobExecution(exec1);
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
Assert.state(exec1.getId() != null);
exec2.setId(exec1.getId());
exec2.setStatus(BatchStatus.UNKNOWN);
exec2.setVersion(7);
Assert.state(exec1.getVersion() != exec2.getVersion());
Assert.state(exec1.getStatus().isLessThan(exec2.getStatus()));
jobExecutionDao.synchronizeStatus(exec2);
assertEquals(exec1.getVersion(), exec2.getVersion());
assertEquals(BatchStatus.UNKNOWN, exec2.getStatus());
}
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:27,代碼來源:MarkLogicJobExecutionDaoTests.java
示例3: saveJobExecution
import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Override
public void saveJobExecution(JobExecution jobExecution) {
validateJobExecution(jobExecution);
if (jobExecution.getId() == null) {
jobExecution.setId(ThreadLocalRandom.current().nextLong(Long.MAX_VALUE));
}
AdaptedJobExecution aJobInstance;
try {
aJobInstance = adapter.marshal(jobExecution);
} catch (Exception ex) {
logger.error(ex.getMessage());
throw new RuntimeException(ex);
}
XMLDocumentManager xmlDocMgr = databaseClient.newXMLDocumentManager();
String uri = getUri(jobExecution);
//Set document metadata
DocumentMetadataHandle jobInstanceMetadata = new DocumentMetadataHandle();
jobInstanceMetadata.withCollections(properties.getCollection(), properties.getJobExecutionCollection());
JAXBHandle<AdaptedJobExecution> handle = new JAXBHandle<AdaptedJobExecution>(jaxbContext());
handle.set(aJobInstance);
xmlDocMgr.write(uri, jobInstanceMetadata, handle);
DocumentDescriptor desc = xmlDocMgr.exists(uri);
jobExecution.setVersion((int) desc.getVersion());
}
示例4: testConcurrentModificationException
import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
/**
* Exception should be raised when the version of update argument doesn't
* match the version of persisted entity.
* <p>
* Ignore this test, using Optimistic Locking capability of MarkLogic, update-policy=VERSION_OPTIONAL
*/
@Transactional
@Test
public void testConcurrentModificationException() {
JobExecution exec1 = new JobExecution(jobInstance, jobParameters);
jobExecutionDao.saveJobExecution(exec1);
JobExecution exec2 = new JobExecution(jobInstance, jobParameters);
exec2.setId(exec1.getId());
exec2.setVersion(exec1.getVersion());
exec2.incrementVersion();
//assertEquals((Integer) 0, exec1.getVersion());
//assertEquals(exec1.getVersion(), exec2.getVersion());
jobExecutionDao.updateJobExecution(exec1);
//assertEquals((Integer) 1, exec1.getVersion());
try {
jobExecutionDao.updateJobExecution(exec2);
fail();
} catch (OptimisticLockingFailureException e) {
// expected
}
}
開發者ID:marklogic-community,項目名稱:marklogic-spring-batch,代碼行數:33,代碼來源:MarkLogicJobExecutionDaoTests.java