本文整理汇总了Java中org.springframework.batch.repeat.RepeatStatus类的典型用法代码示例。如果您正苦于以下问题:Java RepeatStatus类的具体用法?Java RepeatStatus怎么用?Java RepeatStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RepeatStatus类属于org.springframework.batch.repeat包,在下文中一共展示了RepeatStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
/**
* Taskletのエントリポイント
*
* @param contribution ステップの実行状態
* @param chunkContext チャンクの実行状態
* @return ステータス(終了)
* @throws Exception 予期しない例外
*/
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
Map<String, Object> jobParameters = chunkContext.getStepContext().getJobParameters();
// ジョブ起動パラメータの取得
LOGGER.info("FirstTasklet has been executed. job param is {}", jobParameters);
ExecutionContext executionContext = chunkContext.getStepContext()
.getStepExecution()
.getJobExecution()
.getExecutionContext();
// ステップ間の情報引き継ぎはJobExecutionのExecutionContextを取得する。(StepExecutionのExecutionContextではダメ)
executionContext.put("message", "foobar");
return RepeatStatus.FINISHED; // このステップはこれで終了
}
示例2: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
/**
* Executes the task as specified by the taskName with the associated
* properties and arguments.
* @param contribution mutable state to be passed back to update the current step execution
* @param chunkContext contains the task-execution-id used by the listener.
* @return Repeat status of FINISHED.
*/
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
String tmpTaskName = this.taskName.substring(0,
this.taskName.lastIndexOf('_'));
List<String> args = this.arguments;
ExecutionContext stepExecutionContext = chunkContext.getStepContext().getStepExecution().
getExecutionContext();
if(stepExecutionContext.containsKey("task-arguments")) {
args = (List<String>) stepExecutionContext.get("task-arguments");
}
long executionId = this.taskOperations.launch(tmpTaskName,
this.properties, args);
stepExecutionContext.put("task-execution-id", executionId);
stepExecutionContext.put("task-arguments", args);
waitForTaskToComplete(executionId);
return RepeatStatus.FINISHED;
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:32,代码来源:TaskLauncherTasklet.java
示例3: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
@Transactional
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
Query<String> query = currentSession().createQuery(queryString, String.class);
query.setMaxResults(1);
query.setFirstResult(0);
try {
String result = query.getSingleResult();
chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("record.identifier", result);
contribution.setExitStatus(new ExitStatus("MORE_RESULTS"));
} catch (NoResultException e) {
contribution.setExitStatus(new ExitStatus("NO_MORE_RESULTS"));
}
return RepeatStatus.FINISHED;
}
示例4: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
public final RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext) throws Exception {
Map<String,String> defaultValuesMap = new HashMap<String,String>();
if(this.defaultValues != null) {
String values = defaultValues.substring(1, this.defaultValues.length() - 1);
for(String defaultValue : values.split(",")) {
if(defaultValue.indexOf("=") > -1) {
String field = defaultValue.substring(0,defaultValue.indexOf("="));
String value = defaultValue.substring(defaultValue.indexOf("=") + 1, defaultValue.length());
defaultValuesMap.put(field,value);
}
}
}
chunkContext.getStepContext().getStepExecution()
.getJobExecution().getExecutionContext().put(defaultValuesKey, defaultValuesMap);
logger.debug("SETTING " + defaultValuesKey + " as " + defaultValuesMap);
String names = fieldNames.substring(1, this.fieldNames.length() - 1);
String[] fieldNamesArray = names.split(",");
chunkContext.getStepContext().getStepExecution()
.getJobExecution().getExecutionContext().put(fieldNamesKey, fieldNamesArray);
logger.debug("SETTING " + fieldNamesKey + " as " + Arrays.toString(fieldNamesArray));
return RepeatStatus.FINISHED;
}
示例5: step1
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Bean
public Step step1() {
return stepBuilderFactory.get("step1")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
// get path of file in src/main/resources
Path xmlDocPath = Paths.get(getFilePath());
// process the file to json
String json = processXML2JSON(xmlDocPath);
// insert json into mongodb
insertToMongo(json);
return RepeatStatus.FINISHED;
}
}).build();
}
示例6: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) {
Object parametersObj = chunkContext.getStepContext().getJobParameters().get("JobParameters");
String jobParameters = String.valueOf(System.currentTimeMillis());
String params = "(";
if (parametersObj != null) {
jobParameters = parametersObj.toString();
String[] p = jobParameters.split(" ");
for (int i = 0; i < p.length; i++) {
if (i == 0) {
params += "'" + p[i] + "'";
} else {
params += ",'" + p[i] + "'";
}
}
}
params += ")";
try {
logger.info("program is :" + scriptFile + ", argument is:" + params);
jdbcTemplate.execute("call " + scriptFile + params);
} catch (Exception e) {
logger.error(e.getMessage());
chunkContext.getStepContext().getStepExecution().setExitStatus(ExitStatus.FAILED);
}
return RepeatStatus.FINISHED;
}
示例7: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
logger.info("Started MappingParserTask");
// Delete the files that are error out in previous run
Arrays.stream(new File(propertyConstants.getReportDir()).listFiles()).forEach(File::delete);
logger.debug("Found Mapping file:: " + propertyConstants.getMappingJsonPath());
// Create the mapping between Hub and Fortify
final List<BlackDuckFortifyMapperGroup> groupMap = mappingParser.createMapping(propertyConstants.getMappingJsonPath());
logger.info("blackDuckFortifyMappers :" + groupMap.toString());
// Create the threads for parallel processing
ExecutorService exec = Executors.newFixedThreadPool(propertyConstants.getMaximumThreadSize());
List<Future<?>> futures = new ArrayList<>(groupMap.size());
for (BlackDuckFortifyMapperGroup blackDuckFortifyMapperGroup : groupMap) {
futures.add(exec.submit(new BlackDuckFortifyPushThread(blackDuckFortifyMapperGroup,
hubServices, fortifyFileTokenApi, fortifyUploadApi, propertyConstants)));
}
for (Future<?> f : futures) {
f.get(); // wait for a processor to complete
}
jobStatus = true;
logger.info("After all threads processing");
return RepeatStatus.FINISHED;
}
示例8: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
public RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext) throws Exception {
final Stopwatch stopwatch = Stopwatch.createStarted();
final Path tempFile = Files.createTempFile(FILE_PREFIX, FILE_SUFFIX);
try {
final Path path = lupahallintaHttpClient.downloadClubCSV(tempFile);
LOG.info("Download completed successfully in {}, inputFile={}", stopwatch, path);
chunkContext.getStepContext()
.getStepExecution()
.getJobExecution()
.getExecutionContext()
.put(KEY_INPUT_FILE, path.toString());
} catch (final Exception ex) {
Files.deleteIfExists(tempFile);
throw ex;
}
return RepeatStatus.FINISHED;
}
示例9: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
public RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext) throws Exception {
final MetsastajaRekisteriJobParameters jobParameters = new MetsastajaRekisteriJobParameters(
chunkContext.getStepContext().getJobParameters());
final Path sourcePath = Paths.get(jobParameters.getInputFile());
final File sourceFile = sourcePath.toFile();
final UUID uuid = UUID.randomUUID();
LOG.info("Archiving file with UUID={} filename={}", uuid, sourceFile.getName());
fileStorageService.storeFile(
uuid,
sourceFile,
FileType.METSASTAJAREKISTERI,
"application/octet-stream",
sourceFile.getName());
Files.delete(sourcePath);
return RepeatStatus.FINISHED;
}
示例10: init
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Before
public void init() throws Exception {
this.context.register(BatchConfiguration.class);
this.context.refresh();
JobRepository jobRepository = this.context.getBean(JobRepository.class);
this.jobLauncher = this.context.getBean(JobLauncher.class);
this.jobs = new JobBuilderFactory(jobRepository);
PlatformTransactionManager transactionManager = this.context
.getBean(PlatformTransactionManager.class);
this.steps = new StepBuilderFactory(jobRepository, transactionManager);
this.step = this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
return null;
}
}).build();
this.job = this.jobs.get("job").start(this.step).build();
this.jobExplorer = this.context.getBean(JobExplorer.class);
this.runner = new JobLauncherCommandLineRunner(this.jobLauncher,
this.jobExplorer);
this.context.getBean(BatchConfiguration.class).clear();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:24,代码来源:JobLauncherCommandLineRunnerTests.java
示例11: retryFailedExecutionOnNonRestartableJob
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Test
public void retryFailedExecutionOnNonRestartableJob() throws Exception {
this.job = this.jobs.get("job").preventRestart()
.start(this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
throw new RuntimeException("Planned");
}
}).build()).incrementer(new RunIdIncrementer()).build();
this.runner.execute(this.job, new JobParameters());
this.runner.execute(this.job, new JobParameters());
// A failed job that is not restartable does not re-use the job params of
// the last execution, but creates a new job instance when running it again.
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(2);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JobLauncherCommandLineRunnerTests.java
示例12: retryFailedExecutionWithNonIdentifyingParameters
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Test
public void retryFailedExecutionWithNonIdentifyingParameters() throws Exception {
this.job = this.jobs.get("job")
.start(this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
throw new RuntimeException("Planned");
}
}).build()).incrementer(new RunIdIncrementer()).build();
JobParameters jobParameters = new JobParametersBuilder().addLong("id", 1L, false)
.addLong("foo", 2L, false).toJobParameters();
this.runner.execute(this.job, jobParameters);
this.runner.execute(this.job, jobParameters);
assertThat(this.jobExplorer.getJobInstances("job", 0, 100)).hasSize(1);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:JobLauncherCommandLineRunnerTests.java
示例13: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
if (init) {
init();
log.info("the batch process inits completely.");
init = false;
}
try {
contribution.setExitStatus(mapResult(execute(chunkContext)));
Thread.sleep(getSleepTime());
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
synchronized (lock) {
if (stop) {
lock.notifyAll();
log.info("business is executed compeletly!");
return RepeatStatus.FINISHED;
}
}
}
return RepeatStatus.CONTINUABLE;
}
示例14: execute
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Override
public RepeatStatus execute(StepContribution arg0, ChunkContext arg1) throws Exception {
Long time = Calendar.getInstance().getTimeInMillis();
String exit;
if(time % 2 == 0){
exit = ExitStatus.NOOP.getExitCode().toString();
arg0.setExitStatus(ExitStatus.NOOP);
}else{
exit = ExitStatus.COMPLETED.getExitCode().toString();
arg0.setExitStatus(ExitStatus.COMPLETED);
}
System.out.println("Executing step with name " + taskletName + " and exitCode " + exit);
return RepeatStatus.FINISHED;
}
示例15: retryFailedExecutionOnNonRestartableJob
import org.springframework.batch.repeat.RepeatStatus; //导入依赖的package包/类
@Test
public void retryFailedExecutionOnNonRestartableJob() throws Exception {
this.job = this.jobs.get("job").preventRestart()
.start(this.steps.get("step").tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
throw new RuntimeException("Planned");
}
}).build()).incrementer(new RunIdIncrementer()).build();
this.runner.execute(this.job, new JobParameters());
this.runner.execute(this.job, new JobParameters());
// A failed job that is not restartable does not re-use the job params of
// the last execution, but creates a new job instance when running it again.
assertEquals(2, this.jobExplorer.getJobInstances("job", 0, 100).size());
}