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


Java JobExecution類代碼示例

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


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

示例1: testComposedConfiguration

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
	JobExecution jobExecution = this.jobRepository.createJobExecution(
			"ComposedTest", new JobParameters());
	job.execute(jobExecution);

	Map<String, String> props = new HashMap<>(1);
	props.put("format", "yyyy");
	assertEquals(1010, composedTaskProperties.getMaxWaitTime());
	assertEquals(1100, composedTaskProperties.getIntervalTimeBetweenChecks());
	assertEquals("http://bar", composedTaskProperties.getDataflowServerUri().toASCIIString());

	List<String> args = new ArrayList<>(1);
	args.add("--baz=boo");
	Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
	verify(this.taskOperations).launch("AAA", props, args);
}
 
開發者ID:spring-cloud-task-app-starters,項目名稱:composed-task-runner,代碼行數:19,代碼來源:ComposedTaskRunnerConfigurationWithPropertiesTests.java

示例2: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("chunkJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例3: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("taskletJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例4: testWriteTaxonFile

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
/**
 * @throws Exception
 */
@Test
public void testWriteTaxonFile() throws Exception {
	Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
	parameters.put("query", new JobParameter(""));
	parameters.put("selected.facets", new JobParameter("taxon.family_ss=Araceae"));
	parameters.put("download.taxon", new JobParameter(toParameter(DarwinCorePropertyMap.getConceptTerms(DwcTerm.Taxon))));
	parameters.put("download.file", new JobParameter(UUID.randomUUID().toString() + ".txt"));
	parameters.put("download.limit", new JobParameter(new Integer(Integer.MAX_VALUE).toString()));
	parameters.put("download.fieldsTerminatedBy", new JobParameter("\t"));
	parameters.put("download.fieldsEnclosedBy", new JobParameter("\""));
	parameters.put("download.format", new JobParameter("taxon"));

	JobParameters jobParameters = new JobParameters(parameters);
	Job archiveCreatorJob = jobLocator.getJob("FlatFileCreation");
	assertNotNull("flatFileCreatorJob must exist", archiveCreatorJob);
	JobExecution jobExecution = jobLauncher.run(archiveCreatorJob,
			jobParameters);

	assertEquals("The Job should be sucessful", ExitStatus.COMPLETED, jobExecution.getExitStatus());
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:24,代碼來源:FlatFileCreatorIntegrationTest.java

示例5: runner

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
CommandLineRunner runner(JobLauncher launcher,
                         Job job,
                         @Value("${file}") File in,
                         JdbcTemplate jdbcTemplate) {
    return args -> {

        JobExecution execution = launcher.run(job,
                new JobParametersBuilder()
                        .addString("file", in.getAbsolutePath())
                        .toJobParameters());

        System.out.println("execution status: " + execution.getExitStatus().toString());

        List<Person> personList = jdbcTemplate.query("select * from PEOPLE", (resultSet, i) -> new Person(resultSet.getString("first"),
                resultSet.getString("last"),
                resultSet.getString("email")));

        personList.forEach(System.out::println);

    };

}
 
開發者ID:livelessons-spring,項目名稱:building-microservices,代碼行數:23,代碼來源:BatchConfiguration.java

示例6: testComposedConfiguration

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
@Test
@DirtiesContext
public void testComposedConfiguration() throws Exception {
	JobExecution jobExecution = this.jobRepository.createJobExecution(
			"ComposedTest", new JobParameters());
	job.execute(jobExecution);

	Assert.isNull(job.getJobParametersIncrementer(), "JobParametersIncrementer must be null.");
	verify(this.taskOperations).launch("AAA", new HashMap<String, String>(0), new ArrayList<String>(0));
}
 
開發者ID:spring-cloud-task-app-starters,項目名稱:composed-task-runner,代碼行數:11,代碼來源:ComposedTaskRunnerConfigurationNoPropertiesTests.java

示例7: runDemoJob

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
@Scheduled(fixedDelayString = "${demo.job.fixed.delay.seconds:60}000")
public void runDemoJob() {

    SimpleDateFormat format = new SimpleDateFormat("M-dd-yy hh:mm:ss");
    String startDateTime = format.format(new Date());

    JobParameters jobParameters =
            new JobParametersBuilder()
                    .addLong("iterations", iterations)
                    .addString("username", username)
                    .addLong("time", System.currentTimeMillis()).toJobParameters();

    try {
        logger.info("");
        logger.info("STARTING BATCH JOB AT " + startDateTime);
        JobExecution execution = jobLauncher.run(demoJob, jobParameters);
        logger.info("JOB STATUS : " + execution.getStatus());
    } catch (Exception e) {
        e.printStackTrace();
        logger.info("JOB FAILED!!!");
    }

}
 
開發者ID:mintster,項目名稱:nixmash-blog,代碼行數:24,代碼來源:DemoJobRunner.java

示例8: start

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public void start() throws IOException, InterruptedException {
	List<JobExecution> jobExecutions = new ArrayList<>();
	// launch jobs
	jobExecutions.addAll(IntStream.range(0, this.cardinality).mapToObj(i -> {
		Job analysisJob = this.jobFactory.get();
		JobParametersBuilder jobParametersBuilder = new JobParametersBuilder();
		jobParametersBuilder.addString("id", analysisJob.getName() + "-" + i, true);
		try {
			return this.jobLauncher.run(analysisJob, jobParametersBuilder.toJobParameters());
		} catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException
				| JobParametersInvalidException exception) {
			throw new RuntimeException(exception);
		}
	}).collect(Collectors.toList()));
	// wait for termination
	while (jobExecutions.stream().anyMatch(jobExecution -> jobExecution.getStatus().isRunning())) {
		Thread.sleep(1000);
	}
}
 
開發者ID:maenu,項目名稱:kowalski,代碼行數:20,代碼來源:Application.java

示例9: afterJob

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
@Override
public void afterJob(final JobExecution jobExecution) {
    if (ExitStatus.COMPLETED.equals(jobExecution.getExitStatus())) {
        final ExecutionContext executionContext = jobExecution.getExecutionContext();
        final String inputFile = executionContext.getString(LHHuntingClubBatchConfig.KEY_INPUT_FILE, null);

        if (inputFile != null) {
            final Path path = Paths.get(inputFile);

            try {
                LOG.info("Deleting temporary file: {}", inputFile);
                Files.deleteIfExists(path);

            } catch (IOException e) {
                e.printStackTrace();
            }
        } else {
            LOG.warn("Input file not found in context");
        }
    }
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-web,代碼行數:22,代碼來源:LHHuntingClubCSVCleaner.java

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

示例11: afterJob

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
@Override
    public void afterJob(JobExecution jobExecution) {

        LOGGER.info("RUNNING JobCompletion Check.");

        long cnt = movieRepository.count();

        LOGGER.info("Total Movies Saved: {}", cnt);

//        Shutdown when Job is Finished (for Windows PC)
//        Runtime runtime = Runtime.getRuntime();
//        String command = "shutdown /s";
//        try {
//            Process proc = runtime.exec(command);
//        } catch (IOException e) {
//            System.out.println(e.getMessage());
//            e.printStackTrace();
//        }

     }
 
開發者ID:RawSanj,項目名稱:SpringRestBatch,代碼行數:21,代碼來源:JobCompletionNotificationListener.java

示例12: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("multiResourceItemReaderJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例13: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customReaderWriterProcesorJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例14: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("customListeners");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java

示例15: main

import org.springframework.batch.core.JobExecution; //導入依賴的package包/類
public static void main(String[] args) {

		String[] springConfig = { "spring/batch/jobs/job-config.xml" };

		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);

		JobLauncher jobLauncher = (JobLauncher) context.getBean("jobLauncher");
		Job job = (Job) context.getBean("flatFileItemWriterJob");

		try {
			JobParameters jobParameters = new JobParametersBuilder().addLong("time",System.currentTimeMillis()).toJobParameters();
			JobExecution execution = jobLauncher.run(job, jobParameters);
			System.out.println("Exit Status : " + execution.getStatus());
			System.out.println("Exit Status : " + execution.getAllFailureExceptions());

		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println("Done");

	}
 
開發者ID:maldiny,項目名稱:Spring-Batch-en-Castellano,代碼行數:24,代碼來源:Main.java


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