本文整理汇总了Java中org.springframework.batch.core.BatchStatus类的典型用法代码示例。如果您正苦于以下问题:Java BatchStatus类的具体用法?Java BatchStatus怎么用?Java BatchStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BatchStatus类属于org.springframework.batch.core包,在下文中一共展示了BatchStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: discreteJob
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Bean
public Job discreteJob() {
AbstractJob job = new AbstractJob("discreteRegisteredJob") {
@Override
public Collection<String> getStepNames() {
return Collections.emptySet();
}
@Override
public Step getStep(String stepName) {
return null;
}
@Override
protected void doExecute(JobExecution execution)
throws JobExecutionException {
execution.setStatus(BatchStatus.COMPLETED);
}
};
job.setJobRepository(this.jobRepository);
return job;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:BatchAutoConfigurationTests.java
示例2: setup
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Before
public void setup() throws Exception {
if (!initialized) {
registerApp(task, "timestamp");
initialize();
createJobExecution(JOB_NAME, BatchStatus.STARTED);
documentation.dontDocument(() -> this.mockMvc.perform(
post("/tasks/definitions")
.param("name", "DOCJOB_1")
.param("definition", "timestamp --format='YYYY MM DD'"))
.andExpect(status().isOk()));
initialized = true;
}
}
示例3: setup
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Before
public void setup() throws Exception {
if (!initialized) {
registerApp(task, "timestamp");
initialize();
createJobExecution(JOB_NAME, BatchStatus.STARTED);
createJobExecution(JOB_NAME + "_1", BatchStatus.STOPPED);
documentation.dontDocument(() -> this.mockMvc.perform(
post("/tasks/definitions")
.param("name", "DOCJOB_1")
.param("definition", "timestamp --format='YYYY MM DD'"))
.andExpect(status().isOk()));
initialized = true;
}
}
示例4: mapRow
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
/**
* @param resultSet Set the result set
* @param rowNumber Set the row number
* @throws SQLException if there is a problem
* @return a job execution instance
*/
public final JobExecution mapRow(final ResultSet resultSet,
final int rowNumber) throws SQLException {
JobInstance jobInstance = new JobInstance(resultSet.getBigDecimal(
"JOB_INSTANCE_ID").longValue(),
new JobParameters(), resultSet.getString("JOB_NAME"));
JobExecution jobExecution = new JobExecution(jobInstance,
resultSet.getBigDecimal("JOB_EXECUTION_ID").longValue());
jobExecution.setStartTime(resultSet.getTimestamp("START_TIME"));
jobExecution.setCreateTime(resultSet.getTimestamp("CREATE_TIME"));
jobExecution.setEndTime(resultSet.getTimestamp("END_TIME"));
jobExecution.setStatus(BatchStatus.valueOf(resultSet
.getString("STATUS")));
ExitStatus exitStatus = new ExitStatus(
resultSet.getString("EXIT_CODE"),
resultSet.getString("EXIT_MESSAGE"));
jobExecution.setExitStatus(exitStatus);
return jobExecution;
}
示例5: listResourcesToHarvest
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Override
public List<Resource> listResourcesToHarvest(Integer limit, DateTime now, String fetch) {
Criteria criteria = getSession().createCriteria(type);
criteria.add(Restrictions.isNotNull("resourceType"));
criteria.add(Restrictions.in("status", Arrays.asList(new BatchStatus[] {BatchStatus.COMPLETED, BatchStatus.FAILED,BatchStatus.ABANDONED, BatchStatus.STOPPED})));
criteria.add(Restrictions.eq("scheduled", Boolean.TRUE));
criteria.add(Restrictions.disjunction().add(Restrictions.lt("nextAvailableDate", now)).add(Restrictions.isNull("nextAvailableDate")));
if (limit != null) {
criteria.setMaxResults(limit);
}
enableProfilePreQuery(criteria, fetch);
criteria.addOrder( Property.forName("nextAvailableDate").asc() );
List<Resource> result = (List<Resource>) criteria.list();
for(Resource t : result) {
enableProfilePostQuery(t, fetch);
}
return result;
}
示例6: isStartable
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
/**
* @param status
* Set the status
* @return true if the job is startable
*/
public static Boolean isStartable(BatchStatus status) {
if (status == null) {
return Boolean.TRUE;
} else {
switch (status) {
case STARTED:
case STARTING:
case STOPPING:
case UNKNOWN:
return Boolean.FALSE;
case COMPLETED:
case FAILED:
case STOPPED:
default:
return Boolean.TRUE;
}
}
}
示例7: notify
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Override
public void notify(JobExecutionException jobExecutionException, String resourceIdentifier) {
if(resourceIdentifier != null) {
Resource resource = service.find(resourceIdentifier,"job-with-source");
resource.setJobId(null);
resource.setDuration(null);
resource.setExitCode("FAILED");
resource.setExitDescription(jobExecutionException.getLocalizedMessage());
resource.setJobInstance(null);
resource.setResource(null);
resource.setStartTime(null);
resource.setStatus(BatchStatus.FAILED);
resource.setProcessSkip(0);
resource.setRecordsRead(0);
resource.setReadSkip(0);
resource.setWriteSkip(0);
resource.setWritten(0);
service.saveOrUpdate(resource);
solrIndexingListener.indexObject(resource);
}
}
示例8: testUpdateExecution
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
/**
* Update and retrieve job execution - check attributes have changed as
* expected.
*/
@Transactional
@Test
public void testUpdateExecution() {
execution.setStatus(BatchStatus.STARTED);
jobExecutionDao.saveJobExecution(execution);
execution.setLastUpdated(new Date(0));
execution.setStatus(BatchStatus.COMPLETED);
jobExecutionDao.updateJobExecution(execution);
JobExecution updated = jobExecutionDao.findJobExecutions(jobInstance).get(0);
assertEquals(execution, updated);
assertEquals(BatchStatus.COMPLETED, updated.getStatus());
assertExecutionsAreEqual(execution, updated);
}
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:20,代码来源:MarkLogicJobExecutionDaoTests.java
示例9: testSynchronizeStatusUpgrade
import org.springframework.batch.core.BatchStatus; //导入依赖的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
示例10: testSynchronizeStatusDowngrade
import org.springframework.batch.core.BatchStatus; //导入依赖的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
示例11: harvestSuccessful
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
private boolean harvestSuccessful(JobConfiguration job) {
DateTime start = DateTime.now();
while(new Period(start, DateTime.now()).getSeconds() < 20) {
jobConfigurationService.refresh(job);
if(BatchStatus.COMPLETED.equals(job.getJobStatus())) {
logger.info("Succesfully completed {}", job.getDescription());
return true;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return false;
}
示例12: testJobInterruptedException
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Test
public void testJobInterruptedException() throws Exception {
StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
doThrow(new JobInterruptedException("expected")).when(this.step).execute(workerStep);
handler.run();
verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());
assertEquals(BatchStatus.STOPPED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
示例13: testRuntimeException
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Test
public void testRuntimeException() throws Exception {
StepExecution workerStep = new StepExecution("workerStep", new JobExecution(1L), 2L);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn(true);
when(this.environment.containsProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn(true);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBeanNamesForType(Step.class)).thenReturn(new String[] {"workerStep", "foo", "bar"});
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_EXECUTION_ID)).thenReturn("2");
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_JOB_EXECUTION_ID)).thenReturn("1");
when(this.jobExplorer.getStepExecution(1L, 2L)).thenReturn(workerStep);
when(this.environment.getProperty(DeployerPartitionHandler.SPRING_CLOUD_TASK_STEP_NAME)).thenReturn("workerStep");
when(this.beanFactory.getBean("workerStep", Step.class)).thenReturn(this.step);
doThrow(new RuntimeException("expected")).when(this.step).execute(workerStep);
handler.run();
verify(this.jobRepository).update(this.stepExecutionArgumentCaptor.capture());
assertEquals(BatchStatus.FAILED, this.stepExecutionArgumentCaptor.getValue().getStatus());
}
示例14: createJobParametersWithIncrementerIfAvailable
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
private JobParameters createJobParametersWithIncrementerIfAvailable(String parameters, Job job) throws JobParametersNotFoundException {
JobParameters jobParameters = jobParametersConverter.getJobParameters(PropertiesConverter.stringToProperties(parameters));
// use JobParametersIncrementer to create JobParameters if incrementer is set and only if the job is no restart
if (job.getJobParametersIncrementer() != null){
JobExecution lastJobExecution = jobRepository.getLastJobExecution(job.getName(), jobParameters);
boolean restart = false;
// check if job failed before
if (lastJobExecution != null) {
BatchStatus status = lastJobExecution.getStatus();
if (status.isUnsuccessful() && status != BatchStatus.ABANDONED) {
restart = true;
}
}
// if it's not a restart, create new JobParameters with the incrementer
if (!restart) {
JobParameters nextParameters = getNextJobParameters(job);
Map<String, JobParameter> map = new HashMap<String, JobParameter>(nextParameters.getParameters());
map.putAll(jobParameters.getParameters());
jobParameters = new JobParameters(map);
}
}
return jobParameters;
}
示例15: testRunJob
import org.springframework.batch.core.BatchStatus; //导入依赖的package包/类
@Test
public void testRunJob() throws InterruptedException {
Long executionId = restTemplate.postForObject("http://localhost:" + port + "/batch/operations/jobs/flatFile2JobXml", "", Long.class);
while (!restTemplate.getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}", String.class, executionId)
.equals("COMPLETED")) {
Thread.sleep(1000);
}
String log = restTemplate.getForObject("http://localhost:" + port + "/batch/operations/jobs/executions/{executionId}/log", String.class,
executionId);
assertThat(log.length() > 20, is(true));
JobExecution jobExecution = jobExplorer.getJobExecution(executionId);
assertThat(jobExecution.getStatus(), is(BatchStatus.COMPLETED));
String jobExecutionString = restTemplate.getForObject("http://localhost:" + port + "/batch/monitoring/jobs/executions/{executionId}",
String.class, executionId);
assertThat(jobExecutionString.contains("COMPLETED"), is(true));
}