本文整理汇总了Java中org.springframework.batch.repeat.RepeatStatus.FINISHED属性的典型用法代码示例。如果您正苦于以下问题:Java RepeatStatus.FINISHED属性的具体用法?Java RepeatStatus.FINISHED怎么用?Java RepeatStatus.FINISHED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.springframework.batch.repeat.RepeatStatus
的用法示例。
在下文中一共展示了RepeatStatus.FINISHED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
/**
* 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,代码行数:31,代码来源:TaskLauncherTasklet.java
示例2: execute
@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;
}
示例3: execute
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;
}
示例4: execute
@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;
}
示例5: execute
@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;
}
示例6: execute
@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;
}
示例7: execute
@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;
}
示例8: execute
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;
}
示例9: execute
@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;
}
示例10: execute
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
if (marklogicVersion.equals("8")) {
QueryManager qryMgr = databaseClient.newQueryManager();
GenericDocumentManager docMgr = databaseClient.newDocumentManager();
SearchHandle handle = qryMgr.search(queryDefinition, new SearchHandle());
MatchDocumentSummary[] results = handle.getMatchResults();
for (int i = 0; i < results.length; i++) {
docMgr.delete(results[i].getUri());
}
} else if (marklogicVersion.equals("9")) {
final DataMovementManager dataMovementManager = databaseClient.newDataMovementManager();
QueryBatcher qb = dataMovementManager.newQueryBatcher(queryDefinition)
.withBatchSize(2500)
.withConsistentSnapshot()
.onUrisReady(new DeleteListener())
.onQueryFailure(throwable -> throwable.printStackTrace());
JobTicket ticket = dataMovementManager.startJob(qb);
qb.awaitCompletion();
dataMovementManager.stopJob(ticket);
}
return RepeatStatus.FINISHED;
}
示例11: execute
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception {
UUID uuid = UUID.randomUUID();
String unpackDirectoryName = harvesterSpoolDirectory + File.separator + uuid.toString();
String temporaryFileName = harvesterSpoolDirectory + File.separator + uuid.toString() + ".zip";
File unpackDirectory = new File(unpackDirectoryName);
unpackDirectory.mkdir();
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name", temporaryFile.getAbsolutePath());
executionContext.put("unpack.directory.name", unpackDirectory.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
log.debug("setting temporary.file.name to {}", temporaryFile.getAbsolutePath());
log.debug("execution context: {}", executionContext);
return RepeatStatus.FINISHED;
}
示例12: execute
@Override
@Transactional
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
Query query = this.getSession().createQuery(queryString);
query.setMaxResults(1);
query.setFirstResult(0);
List<String> results = (List<String>)query.list();
if(results.size() == 0) {
contribution.setExitStatus(new ExitStatus("NO_MORE_RESULTS"));
} else {
chunkContext.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("record.identifier", results.get(0));
contribution.setExitStatus(new ExitStatus("MORE_RESULTS"));
}
return RepeatStatus.FINISHED;
}
示例13: execute
/**
* @param contribution Set the step contribution
* @param chunkContext Set the chunk context
* @return the repeat status
* @throws Exception if there is a problem deleting the resources
*/
public final RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext)
throws Exception {
UUID uuid = UUID.randomUUID();
String unpackDirectoryName = harvesterSpoolDirectory + File.separator
+ uuid.toString();
String temporaryFileName = harvesterSpoolDirectory + File.separator
+ uuid.toString() + ".zip";
File unpackDirectory = new File(unpackDirectoryName);
unpackDirectory.mkdir();
File temporaryFile = new File(temporaryFileName);
ExecutionContext executionContext = chunkContext.getStepContext()
.getStepExecution().getJobExecution().getExecutionContext();
executionContext.put("temporary.file.name",temporaryFile.getAbsolutePath());
executionContext.put("unpack.directory.name",unpackDirectory.getAbsolutePath());
executionContext.putLong("job.execution.id", chunkContext.getStepContext().getStepExecution().getJobExecutionId());
return RepeatStatus.FINISHED;
}
示例14: execute
@Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext chunkContext) throws Exception {
CoreAdminResponse coreAdminResponse = CoreAdminRequest.getStatus(core, solrServer);
NamedList<Object> index = (NamedList<Object>)coreAdminResponse.getCoreStatus(core).get("index");
Integer segmentCount = (Integer)index.get("segmentCount");
if(segmentCount < maxSegments) {
logger.debug("Core " + core + " only has " + segmentCount + " segments, skipping optimization");
} else {
logger.debug("Core " + core + " has " + segmentCount + " segments, starting optimization");
solrServer.optimize(true, true);
logger.debug("Core " + core + " optimized");
}
return RepeatStatus.FINISHED;
}
示例15: execute
/**
* @param contribution
* Set the step contribution
* @param chunkContext
* Set the chunk context
* @return the repeat status
* @throws Exception
* if there is a problem
*/
public final RepeatStatus execute(final StepContribution contribution,
final ChunkContext chunkContext) throws Exception {
// Set up input documents
Source inputXML = new StreamSource(inputFile.getFile());
Source inputXSL = new StreamSource(xsltFile.getFile());
// Set up output sink
Result outputXHTML = new StreamResult(outputFile.getFile());
// Setup a factory for transforms
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(inputXSL);
for (String parameterName : parameters.keySet()) {
transformer.setParameter(parameterName,
parameters.get(parameterName));
}
if(errorListener != null) {
transformer.setErrorListener(errorListener);
}
transformer.transform(inputXML, outputXHTML);
return RepeatStatus.FINISHED;
}