List of usage examples for org.springframework.batch.repeat RepeatStatus FINISHED
RepeatStatus FINISHED
To view the source code for org.springframework.batch.repeat RepeatStatus FINISHED.
Click Source Link
From source file:org.jasig.ssp.util.importer.job.tasklet.PartialUploadGuard.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Date lastAllowedModificationTime = getLastAllowedModifiedDate(); if (resources == null || resources.length == 0) { logger.error("Job not started. No resources found"); stopJob();//from w ww .j av a 2 s . c o m return RepeatStatus.FINISHED; } for (Resource resource : resources) { Date modified = new Date(resource.lastModified()); if (modified.after(lastAllowedModificationTime)) { logger.info(FILE_SOAK_TIME + resource.getFilename()); stopJob(); return RepeatStatus.FINISHED; } } return RepeatStatus.FINISHED; }
From source file:com.navercorp.pinpoint.web.batch.flink.HealthCheckTasklet.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { List<String> urlList = generatedFlinkManagerServerApi(); if (urlList.size() == 0) { return RepeatStatus.FINISHED; }// www.ja v a2 s.c o m Map<String, Boolean> jobExecuteStatus = createjobExecuteStatus(); for (String url : urlList) { try { ResponseEntity<Map> responseEntity = this.restTemplate.exchange(url, HttpMethod.GET, null, Map.class); if (responseEntity.getStatusCode() != HttpStatus.OK) { continue; } checkJobExecuteStatus(responseEntity, jobExecuteStatus); } catch (Exception e) { logger.error("fail call api to flink server.", e); } } List<String> notExecuteJobList = new ArrayList<>(3); for (Map.Entry<String, Boolean> entry : jobExecuteStatus.entrySet()) { if (entry.getValue().equals(Boolean.FALSE)) { notExecuteJobList.add(entry.getKey()); } } if (notExecuteJobList.size() > 0) { String exceptionMessage = String.format("job fail : %s", notExecuteJobList); throw new Exception(exceptionMessage); } return RepeatStatus.FINISHED; }
From source file:lcn.module.batch.web.guide.support.ErrorLogTasklet.java
/** * Error_Log ?? Skip Error ? /*from w ww. ja v a2 s . com*/ */ public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { Assert.notNull(this.stepName, "Step name not set. Either this class was not registered as a listener " + "or the key 'stepName' was not found in the Job's ExecutionContext."); this.simpleJdbcTemplate.update( "insert into ERROR_LOG values (?, ?, '" + getSkipCount() + " records were skipped!')", jobName, stepName); return RepeatStatus.FINISHED; }
From source file:org.obiba.onyx.core.purge.PurgeParticipantDataTasklet.java
public RepeatStatus execute(StepContribution stepContribution, ChunkContext context) { log.info("**** STARTING PARTICIPANT DATA PURGE ****"); log.info("Current purge configuration is [{}] days", purgeParticipantDataService.getPurgeDataOlderThanInDays()); long start = System.currentTimeMillis(); List<Participant> participantsToBePurged = onyxDataPurge.getParticipantsToPurge(); for (Participant participant : participantsToBePurged) { participantService.deleteParticipant(participant); log.info("Deleting Participant id = [{}] and related data : ", participant.getId()); }/*from w ww. j ava 2s .c o m*/ context.getStepContext().getStepExecution().getJobExecution().getExecutionContext().put("totalDeleted", participantsToBePurged.size()); long end = System.currentTimeMillis(); log.info("A total of [{}] Participants were deleted in [{}] ms.", participantsToBePurged.size(), end - start); log.info("**** PARTICIPANT DATA PURGE COMPLETED ****"); return RepeatStatus.FINISHED; }
From source file:com.javaetmoi.core.batch.tasklet.CreateElasticIndexSettingsTasklet.java
@Override public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception { LOG.debug("Creating the index {} settings", indexName); String source = IOUtils.toString(indexSettings.getInputStream(), "UTF-8"); CreateIndexRequestBuilder createIndexReq = esClient.admin().indices().prepareCreate(indexName); createIndexReq.setSettings(source);/* w w w. j av a2s.com*/ CreateIndexResponse response = createIndexReq.execute().actionGet(); if (!response.isAcknowledged()) { throw new RuntimeException("The index settings has not been acknowledged"); } esClient.admin().indices().refresh(new RefreshRequest(indexName)).actionGet(); LOG.info("Index {} settings created", indexName); return RepeatStatus.FINISHED; }
From source file:com.dalamar.schedule.ScheduleTasklet.java
@Override public RepeatStatus execute(StepContribution sc, ChunkContext cc) throws Exception { System.out.println("Testing batch job"); SimpleDateFormat df = new SimpleDateFormat("M/d/yyyy"); Date yesterday = df.parse("2/17/2016"); LateTrainDao ltd = appContext.getBean(LateTrainDao.class); StatSnapshotDao std = appContext.getBean(StatSnapshotDao.class); TrainStationWatcher sofiaWatcher = new TrainStationWatcher("Sofia", appContext.getBean(LateTrainDao.class)); StatisticsWatcher sofiaStats = new StatisticsWatcher("Sofia", ltd, std); TrainStationWatcher plovdivWatcher = new TrainStationWatcher("Plovdiv", appContext.getBean(LateTrainDao.class)); StatisticsWatcher plovdivStats = new StatisticsWatcher("Plovdiv", ltd, std); TrainStationWatcher varnaWatcher = new TrainStationWatcher("Varna", appContext.getBean(LateTrainDao.class)); StatisticsWatcher varnaStats = new StatisticsWatcher("Varna", ltd, std); TrainStationWatcher burgasWatcher = new TrainStationWatcher("Burgas", appContext.getBean(LateTrainDao.class)); StatisticsWatcher burgasStats = new StatisticsWatcher("Burgas", ltd, std); StatisticsWatcher totalStats = new StatisticsWatcher("total", ltd, std); sofiaWatcher.diffWithDB();// w w w .j ava 2 s . c om plovdivWatcher.diffWithDB(); varnaWatcher.diffWithDB(); burgasWatcher.diffWithDB(); sofiaStats.persistStats(); plovdivStats.persistStats(); varnaStats.persistStats(); burgasStats.persistStats(); totalStats.persistStats(); return RepeatStatus.FINISHED; }
From source file:fr.acxio.tools.agia.tasks.FileOperationTasklet.java
public RepeatStatus execute(StepContribution sContribution, ChunkContext sChunkContext) throws IOException, ResourceCreationException, FileOperationException { doOperation(origin, new HashMap<String, Object>(), sContribution, ((sChunkContext != null) && (sChunkContext.getStepContext() != null)) ? sChunkContext.getStepContext().getStepExecution() : null);/*from www .ja v a2s.c o m*/ return RepeatStatus.FINISHED; }
From source file:com.github.jrrdev.mantisbtsync.core.jobs.projects.tasklets.ProjectsExtractorTasklet.java
/** * {@inheritDoc}/*from w w w .jav a 2 s. c om*/ * @see org.springframework.batch.core.step.tasklet.Tasklet#execute(org.springframework.batch.core.StepContribution, org.springframework.batch.core.scope.context.ChunkContext) */ @Override public RepeatStatus execute(final StepContribution contribution, final ChunkContext chunkContext) throws Exception { final Set<BigInteger> projectsId = (Set<BigInteger>) chunkContext.getStepContext().getJobExecutionContext() .get("mantis.loop.projects_to_process"); if (projectsId != null && !projectsId.isEmpty()) { final BigInteger id = projectsId.iterator().next(); projectsId.remove(id); chunkContext.getStepContext().getStepExecution().getExecutionContext().put("mantis.loop.project_id", id); } else { chunkContext.getStepContext().getStepExecution().getExecutionContext().remove("mantis.loop.project_id"); } return RepeatStatus.FINISHED; }
From source file:jp.yustam.batch.SampleBatchApplication.java
@Bean protected Tasklet tasklet() { return new Tasklet() { @Override/*from ww w . jav a2s .c o m*/ public RepeatStatus execute(StepContribution contribution, ChunkContext context) throws SQLException { System.out.println("Hello, world!"); System.out.println(config.getHost()); System.out.println(config.getPort()); String url = String.format("jdbc:postgresql://%s:%d/", config.getHost(), config.getPort()); Properties props = new Properties(); props.setProperty("user", "postgres"); // props.setProperty("password", "secret"); // props.setProperty("ssl", "true"); Connection conn = DriverManager.getConnection(url, props); Statement statement = conn.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM company;"); while (rs.next()) { System.out.printf("%d %d %s\n", rs.getInt("id"), rs.getInt("code"), rs.getString("name")); } return RepeatStatus.FINISHED; } }; }