List of usage examples for org.springframework.batch.core ExitStatus COMPLETED
ExitStatus COMPLETED
To view the source code for org.springframework.batch.core ExitStatus COMPLETED.
Click Source Link
From source file:org.examproject.batch.listener.ContentStepListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { LOG.info("<<<<<<<<<<<<<<<<<<<<<<<<<< afterStep called."); try {/*from w w w . j a v a 2s . co m*/ contentService.save(); } catch (Exception e) { LOG.error("error: " + e.getMessage()); throw new RuntimeException(e); } LOG.info("============ ExitStatus.COMPLETED returned."); return ExitStatus.COMPLETED; }
From source file:com.manning.siia.batch.BatchTest.java
@Test @SuppressWarnings("unchecked") public void runBatch() throws Exception { //120 s should provide enough time for the poller to detect the file and process it JobExecution jobExecution = ((Message<JobExecution>) statusesChannel.receive(120000)).getPayload(); ExitStatus exitStatus = jobExecution.getExitStatus(); Assert.assertEquals(ExitStatus.COMPLETED, exitStatus); int count = jdbcTemplate.queryForInt("select count(*) from payments"); Assert.assertEquals(27, count);// ww w . java 2 s .c o m }
From source file:com.javaetmoi.core.batch.test.TestParallelAndPartitioning.java
@Test public void launchJob() throws Exception { // Launch the parallelAndPartitioningJob JobExecution execution = testUtils.launchJob(); // Batch Status assertEquals(ExitStatus.COMPLETED, execution.getExitStatus()); // Movies//w w w . jav a 2 s .c o m assertEquals("8 movies", 8, getStepExecution(execution, "stepLogMovie").getWriteCount()); // Music Albums StepExecution stepExecutionMusic = getStepExecution(execution, "stepLogMusicAlbum"); assertEquals("11 music albums", 11, stepExecutionMusic.getWriteCount()); Object gridSize = ExecutionContextTestUtils.getValueFromStep(stepExecutionMusic, "SimpleStepExecutionSplitter.GRID_SIZE"); assertEquals("stepLogMusicAlbum divided into 2 partitions", 2L, gridSize); StepExecution stepExecPart0 = getStepExecution(execution, "stepLogMusicAlbumPartition:partition0"); assertEquals("First partition processed 6 music albums", 6, stepExecPart0.getWriteCount()); StepExecution stepExecPart1 = getStepExecution(execution, "stepLogMusicAlbumPartition:partition1"); assertEquals("Second partition processed 5 music albums", 5, stepExecPart1.getWriteCount()); }
From source file:org.cbio.portal.pipelines.foundation.CnaStepListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { return ExitStatus.COMPLETED; }
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.IndexesGeneratorStepTest.java
@Test public void testIndexesAreCreated() throws Exception { String dbCollectionGenesName = jobOptions.getDbCollectionsFeaturesName(); JobExecution jobExecution = jobLauncherTestUtils .launchStep(DatabaseInitializationJob.CREATE_DATABASE_INDEXES); assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); MongoClient mongoClient = new MongoClient(); DBCollection genesCollection = mongoClient.getDB(dbName).getCollection(dbCollectionGenesName); assertEquals(/*ww w . j a v a 2 s . c o m*/ "[{ \"v\" : 1 , \"key\" : { \"_id\" : 1} , \"name\" : \"_id_\" , \"ns\" : \"" + dbName + "." + dbCollectionGenesName + "\"}, { \"v\" : 1 , \"key\" : { \"name\" : 1} , \"name\" : \"name_1\" , \"ns\" : \"" + dbName + "." + dbCollectionGenesName + "\" , \"sparse\" : true , \"background\" : true}]", genesCollection.getIndexInfo().toString()); }
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.VepInputGeneratorStepTest.java
@Test public void shouldGenerateVepInput() throws Exception { String dump = PopulationStatisticsJobTest.class.getResource("/dump/").getFile(); JobTestUtils.restoreMongoDbFromDump(dump); File vepInputFile = new File(jobOptions.getVepInput()); if (vepInputFile.exists()) vepInputFile.delete();/*from ww w .j a v a2s . c o m*/ Assert.assertFalse(vepInputFile.exists()); JobExecution jobExecution = jobLauncherTestUtils .launchStep(VepInputGeneratorStep.FIND_VARIANTS_TO_ANNOTATE); Assert.assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); Assert.assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); Assert.assertTrue(vepInputFile.exists()); TestCase.assertEquals("20\t60343\t60343\tG/A\t+", readFirstLine(vepInputFile)); JobTestUtils.cleanDBs(VARIANTS_ANNOT_GENERATE_VEP_INPUT_DB_NAME); }
From source file:com.javaetmoi.core.batch.integration.JobExitStatusRouter.java
@Router public String route(JobExecution jobExecution) { while (jobExecution.getStatus().isRunning()) { LOGGER.debug("Still running job {} execution end ...", jobExecution.getJobId()); try {/*from w w w . j a v a2s . c om*/ Thread.sleep(pollingInterval); } catch (InterruptedException e) { LOGGER.warn("Router has been interrupted before job execution ending", e); return errorChannel; } } LOGGER.debug("Job {} exit status: {}", jobExecution.getJobId(), jobExecution.getExitStatus()); if (jobExecution.getExitStatus().equals(ExitStatus.COMPLETED)) { return successChannel; } return errorChannel; }
From source file:uk.ac.ebi.eva.pipeline.jobs.steps.VepAnnotationGeneratorStepTest.java
@Test public void shouldGenerateVepAnnotations() throws Exception { makeGzipFile("20\t60343\t60343\tG/A\t+", jobOptions.getVepInput()); File vepOutputFile = JobTestUtils.createTempFile(); jobOptions.setVepOutput(vepOutputFile.getAbsolutePath()); vepOutputFile.delete();/*from w w w . ja va2s.com*/ TestCase.assertFalse(vepOutputFile.exists()); // ensure the annot file doesn't exist from previous executions // When the execute method in variantsAnnotCreate is executed JobExecution jobExecution = jobLauncherTestUtils.launchStep(AnnotationJob.GENERATE_VEP_ANNOTATION); //Then variantsAnnotCreate step should complete correctly assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); // And VEP output should exist and annotations should be in the file TestCase.assertTrue(vepOutputFile.exists()); Assert.assertEquals(537, JobTestUtils.getLines(new GZIPInputStream(new FileInputStream(vepOutputFile)))); vepOutputFile.delete(); }
From source file:uk.ac.ebi.eva.pipeline.jobs.AnnotationJobTest.java
@Test public void allAnnotationStepsShouldBeExecuted() throws Exception { String dump = PopulationStatisticsJobTest.class.getResource("/dump/").getFile(); JobTestUtils.restoreMongoDbFromDump(dump); JobExecution jobExecution = jobLauncherTestUtils.launchJob(); assertEquals(ExitStatus.COMPLETED, jobExecution.getExitStatus()); assertEquals(BatchStatus.COMPLETED, jobExecution.getStatus()); Assert.assertEquals(3, jobExecution.getStepExecutions().size()); List<StepExecution> steps = new ArrayList<>(jobExecution.getStepExecutions()); StepExecution findVariantsToAnnotateStep = steps.get(0); StepExecution generateVepAnnotationsStep = steps.get(1); StepExecution loadVepAnnotationsStep = steps.get(2); Assert.assertEquals(FIND_VARIANTS_TO_ANNOTATE, findVariantsToAnnotateStep.getStepName()); Assert.assertEquals(GENERATE_VEP_ANNOTATION, generateVepAnnotationsStep.getStepName()); Assert.assertEquals(LOAD_VEP_ANNOTATION, loadVepAnnotationsStep.getStepName()); //check list of variants without annotation output file assertTrue(vepInputFile.exists());//from w w w.ja va 2s. c o m assertEquals("20\t60343\t60343\tG/A\t+", JobTestUtils.readFirstLine(vepInputFile)); //check that documents have the annotation DBCursor cursor = collection(dbName, jobOptions.getDbCollectionsVariantsName()).find(); int cnt = 0; int consequenceTypeCount = 0; while (cursor.hasNext()) { cnt++; DBObject dbObject = (DBObject) cursor.next().get("annot"); if (dbObject != null) { VariantAnnotation annot = converter.convertToDataModelType(dbObject); assertNotNull(annot.getConsequenceTypes()); consequenceTypeCount += annot.getConsequenceTypes().size(); } } assertEquals(300, cnt); assertEquals(536, consequenceTypeCount); //check that one line is skipped because malformed List<StepExecution> variantAnnotationLoadStepExecution = jobExecution.getStepExecutions().stream() .filter(stepExecution -> stepExecution.getStepName().equals(LOAD_VEP_ANNOTATION)) .collect(Collectors.toList()); assertEquals(1, variantAnnotationLoadStepExecution.get(0).getReadSkipCount()); }
From source file:org.jasig.ssp.util.importer.job.listener.StagingAndUpsertListener.java
@SuppressWarnings("unchecked") @Override/*from w ww . j a v a2 s .co m*/ @AfterStep public ExitStatus afterStep(StepExecution arg0) { Integer numInsertedUpdated = (Integer) stepExecution.getExecutionContext().get("numInsertedUpdated"); String currentEntity = (String) stepExecution.getExecutionContext().get("currentEntity"); if (currentEntity != null) { Map<String, ReportEntry> report = (Map<String, ReportEntry>) stepExecution.getJobExecution() .getExecutionContext().get("report"); if (report == null) { report = new HashMap<String, ReportEntry>(); } ReportEntry currentEntry = report.get(currentEntity); if (currentEntry != null) { currentEntry.setTableName(currentEntity); currentEntry.setNumberInsertedUpdated(numInsertedUpdated == null ? 0 : numInsertedUpdated); currentEntry.setNumberSkippedOnDatabaseWrite(arg0.getWriteSkipCount()); } else { currentEntry = new ReportEntry(); currentEntry.setTableName(currentEntity); currentEntry.setNumberInsertedUpdated(numInsertedUpdated == null ? 0 : numInsertedUpdated); currentEntry.setNumberSkippedOnDatabaseWrite(arg0.getWriteSkipCount()); } report.put(currentEntity, currentEntry); stepExecution.getJobExecution().getExecutionContext().put("report", report); } return ExitStatus.COMPLETED; }