當前位置: 首頁>>代碼示例>>Java>>正文


Java JobExecution.setStatus方法代碼示例

本文整理匯總了Java中org.springframework.batch.core.JobExecution.setStatus方法的典型用法代碼示例。如果您正苦於以下問題:Java JobExecution.setStatus方法的具體用法?Java JobExecution.setStatus怎麽用?Java JobExecution.setStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.batch.core.JobExecution的用法示例。


在下文中一共展示了JobExecution.setStatus方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: discreteJob

import org.springframework.batch.core.JobExecution; //導入方法依賴的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: 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: discreteJob

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Bean
public Job discreteJob() {
	AbstractJob job = new AbstractJob("discreteLocalJob") {

		@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:Nephilim84,項目名稱:contestparser,代碼行數:24,代碼來源:BatchAutoConfigurationTests.java

示例4: mapRow

import org.springframework.batch.core.JobExecution; //導入方法依賴的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;
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:25,代碼來源:JobExecutionDaoImpl.java

示例5: 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

示例6: afterJob

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Override
public void afterJob(JobExecution jobExecution) {
	for (StepExecution stepExecution : jobExecution.getStepExecutions()) {
		if (stepExecution.getSkipCount() > 0) {
			jobExecution.setExitStatus(ExitStatus.FAILED);
			jobExecution.setStatus(BatchStatus.FAILED);
			return;
		}
	}
}
 
開發者ID:namics,項目名稱:spring-batch-support,代碼行數:11,代碼來源:FailIfSkippedJobExecutionListener.java

示例7: testExitCodeForCompleted

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testExitCodeForCompleted() {
	JobExecution execution = new JobExecution(0L);
	execution.setStatus(BatchStatus.COMPLETED);
	this.generator.onApplicationEvent(new JobExecutionEvent(execution));
	assertThat(this.generator.getExitCode()).isEqualTo(0);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:JobExecutionExitCodeGeneratorTests.java

示例8: testExitCodeForFailed

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testExitCodeForFailed() {
	JobExecution execution = new JobExecution(0L);
	execution.setStatus(BatchStatus.FAILED);
	this.generator.onApplicationEvent(new JobExecutionEvent(execution));
	assertThat(this.generator.getExitCode()).isEqualTo(5);
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:8,代碼來源:JobExecutionExitCodeGeneratorTests.java

示例9: testIsJobExecutionRestartableWithNullBatchStatus

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testIsJobExecutionRestartableWithNullBatchStatus() {
	try {
		final JobExecution jobExecution = new JobExecution(1L);
		jobExecution.setStatus(null);
		JobUtils.isJobExecutionRestartable(jobExecution);
		fail("Expected an IllegalArgumentException to be thrown.");
	}
	catch (IllegalArgumentException e) {
		assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage());
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:13,代碼來源:JobUtilsTests.java

示例10: testIsJobExecutionAbandonableWithNullBatchStatus

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testIsJobExecutionAbandonableWithNullBatchStatus() {
	try {
		final JobExecution jobExecution = new JobExecution(1L);
		jobExecution.setStatus(null);
		JobUtils.isJobExecutionAbandonable(jobExecution);
		fail("Expected an IllegalArgumentException to be thrown.");
	}
	catch (IllegalArgumentException e) {
		assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage());
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:13,代碼來源:JobUtilsTests.java

示例11: testIsJobExecutionStoppableWithNullBatchStatus

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testIsJobExecutionStoppableWithNullBatchStatus() {
	try {
		final JobExecution jobExecution = new JobExecution(1L);
		jobExecution.setStatus(null);
		JobUtils.isJobExecutionStoppable(jobExecution);
		fail("Expected an IllegalArgumentException to be thrown.");
	}
	catch (IllegalArgumentException e) {
		assertEquals("The BatchStatus of the provided jobExecution must not be null.", e.getMessage());
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:13,代碼來源:JobUtilsTests.java

示例12: createJobExecution

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
private void createJobExecution(String name, BatchStatus status) {
	TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null);
	JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null);
	this.taskBatchDao.saveRelationship(taskExecution, jobExecution);
	jobExecution.setStatus(status);
	jobExecution.setStartTime(new Date());
	this.jobRepository.update(jobExecution);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:9,代碼來源:JobInstancesDocumentation.java

示例13: createJobExecution

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
private void createJobExecution(String name, BatchStatus status) {
	TaskExecution taskExecution = this.dao.createTaskExecution(name, new Date(), new ArrayList<>(), null);
	JobExecution jobExecution = this.jobRepository.createJobExecution(this.jobRepository.createJobInstance(name, new JobParameters()), new JobParameters(), null);
	StepExecution stepExecution = new StepExecution(name + "_STEP", jobExecution, jobExecution.getId());
	stepExecution.setId(null);
	jobRepository.add(stepExecution);
	this.taskBatchDao.saveRelationship(taskExecution, jobExecution);
	jobExecution.setStatus(status);
	jobExecution.setStartTime(new Date());
	this.jobRepository.update(jobExecution);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:12,代碼來源:JobStepExecutionsDocumentation.java

示例14: createSampleJob

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
private void createSampleJob(String jobName, int jobExecutionCount, BatchStatus status) {
	JobInstance instance = jobRepository.createJobInstance(jobName, new JobParameters());
	TaskExecution taskExecution = dao.createTaskExecution(jobName, new Date(), new ArrayList<String>(), null);
	JobExecution jobExecution = null;

	for (int i = 0; i < jobExecutionCount; i++) {
		jobExecution = jobRepository.createJobExecution(instance, new JobParameters(), null);
		taskBatchDao.saveRelationship(taskExecution, jobExecution);
		jobExecution.setStatus(status);
		if (BatchStatus.STOPPED.equals(status)) {
			jobExecution.setEndTime(new Date());
		}
		jobRepository.update(jobExecution);
	}
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:16,代碼來源:JobExecutionControllerTests.java

示例15: testExitCodeForCompleted

import org.springframework.batch.core.JobExecution; //導入方法依賴的package包/類
@Test
public void testExitCodeForCompleted() {
	JobExecution execution = new JobExecution(0L);
	execution.setStatus(BatchStatus.COMPLETED);
	this.generator.onApplicationEvent(new JobExecutionEvent(execution));
	assertEquals(0, this.generator.getExitCode());
}
 
開發者ID:Nephilim84,項目名稱:contestparser,代碼行數:8,代碼來源:JobExecutionExitCodeGeneratorTests.java


注:本文中的org.springframework.batch.core.JobExecution.setStatus方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。