Example usage for org.springframework.batch.core.job.builder JobBuilder start

List of usage examples for org.springframework.batch.core.job.builder JobBuilder start

Introduction

In this page you can find the example usage for org.springframework.batch.core.job.builder JobBuilder start.

Prototype

public JobFlowBuilder start(Flow flow) 

Source Link

Document

Create a new job builder that will execute a flow.

Usage

From source file:uk.ac.ebi.eva.pipeline.jobs.DatabaseInitializationJob.java

@Bean
@Qualifier("initDBJob")
public Job initDBJob() {
    JobBuilder jobBuilder = jobBuilderFactory.get(jobName).incrementer(new RunIdIncrementer());

    return jobBuilder.start(indexesCreate()).next(genesLoadStep).build();
}

From source file:uk.ac.ebi.eva.pipeline.jobs.PopulationStatisticsJob.java

@Bean
public Job variantStatisticsJob() {
    JobBuilder jobBuilder = jobBuilderFactory.get(jobName).incrementer(new RunIdIncrementer());

    return jobBuilder.start(optionalStatisticsFlow()).build().build();
}

From source file:uk.ac.ebi.eva.pipeline.jobs.AnnotationJob.java

@Bean
public Job variantAnnotationBatchJob() {
    JobBuilder jobBuilder = jobBuilderFactory.get(jobName).incrementer(new RunIdIncrementer());

    return jobBuilder.start(optionalAnnotationFlow()).build().build();
}

From source file:io.pivotal.dataflow.task.app.jdbcgemfire.common.JdbcGemfireConfiguration.java

@Bean
public Job partitionedJob() throws Exception {
    String jobName = environment.getProperty("spring.cloud.task.name") != null
            ? environment.getProperty("spring.cloud.task.name")
            : this.context.getId();
    JobBuilder jobBuilder = this.jobBuilderFactory.get(jobName);
    if (!this.props.isRestartable()) {
        jobBuilder.preventRestart();//from ww  w.  ja  v  a  2s  .  com
    }
    return jobBuilder.start(workerStep()).build();
}

From source file:org.duracloud.snapshot.service.impl.RestoreJobBuilder.java

@Override
public Job buildJob(Restoration restoration, SnapshotJobManagerConfig jobManagerConfig)
        throws SnapshotException {
    Job job;/*from   w w  w . j av  a 2s . c  o m*/

    try {

        DuracloudEndPointConfig destination = restoration.getDestination();
        String destinationSpaceId = destination.getSpaceId();
        String restoreId = restoration.getRestorationId();

        StoreClientUtil clientUtil = new StoreClientUtil();
        ContentStore contentStore = clientUtil.createContentStore(destination.getHost(), destination.getPort(),
                SnapshotServiceConstants.DURASTORE_CONTEXT, jobManagerConfig.getDuracloudUsername(),
                jobManagerConfig.getDuracloudPassword(), destination.getStoreId());

        Step restoreContentStep = buildRestoreContentStep(restoreId, destinationSpaceId, contentStore,
                jobManagerConfig);
        Step restorePropertiesStep = buildRestoreContentPropertiesStep(restoreId, destinationSpaceId,
                contentStore, jobManagerConfig);

        JobBuilderFactory jobBuilderFactory = new JobBuilderFactory(jobRepository);
        JobBuilder jobBuilder = jobBuilderFactory.get(SnapshotServiceConstants.RESTORE_JOB_NAME);
        SimpleJobBuilder simpleJobBuilder = jobBuilder.start(restoreContentStep).next(restorePropertiesStep);

        simpleJobBuilder.listener(jobListener);
        job = simpleJobBuilder.build();
        log.debug("build job {}", job);
    } catch (Exception e) {
        log.error("Error creating job: {}", e.getMessage(), e);
        throw new SnapshotException(e.getMessage(), e);
    }
    return job;
}

From source file:org.duracloud.snapshot.service.impl.SnapshotJobBuilder.java

@Override
public Job buildJob(Snapshot snapshot, SnapshotJobManagerConfig config) throws SnapshotException {

    Job job;// w w  w .j  av a 2 s  .c o m
    try {

        DuracloudEndPointConfig source = snapshot.getSource();
        StoreClientUtil clientUtil = new StoreClientUtil();

        ContentStore contentStore = clientUtil.createContentStore(source.getHost(), source.getPort(),
                SnapshotServiceConstants.DURASTORE_CONTEXT, config.getDuracloudUsername(),
                config.getDuracloudPassword(), source.getStoreId());

        List<String> spaces = new ArrayList<>();
        spaces.add(source.getSpaceId());

        RetrievalSource retrievalSource = new DuraStoreStitchingRetrievalSource(contentStore, spaces, false);

        ItemReader<ContentItem> itemReader = new SpaceItemReader(retrievalSource);

        File contentDir = new File(
                ContentDirUtils.getDestinationPath(snapshot.getName(), config.getContentRootDir()));
        if (!contentDir.exists()) {
            contentDir.mkdirs();
        }

        File workDir = config.getWorkDir();
        OutputWriter outputWriter = new CSVFileOutputWriter(workDir);

        BufferedWriter propsWriter = createWriter(contentDir,
                SnapshotServiceConstants.CONTENT_PROPERTIES_JSON_FILENAME);
        BufferedWriter md5Writer = createWriter(contentDir, MANIFEST_MD5_TXT_FILE_NAME);
        BufferedWriter sha256Writer = createWriter(contentDir, MANIFEST_SHA256_TXT_FILE_NAME);

        ItemWriter itemWriter = new SpaceItemWriter(snapshot, retrievalSource, contentDir, outputWriter,
                propsWriter, md5Writer, sha256Writer, snapshotManager);

        SimpleStepFactoryBean<ContentItem, File> stepFactory = new SimpleStepFactoryBean<>();
        stepFactory.setJobRepository(jobRepository);
        stepFactory.setTransactionManager(transactionManager);
        stepFactory.setBeanName("step1");
        stepFactory.setItemReader(itemReader);
        stepFactory.setItemWriter(itemWriter);
        stepFactory.setCommitInterval(1);
        stepFactory.setThrottleLimit(20);
        stepFactory.setTaskExecutor(taskExecutor);
        Step step = (Step) stepFactory.getObject();

        JobBuilderFactory jobBuilderFactory = new JobBuilderFactory(jobRepository);
        JobBuilder jobBuilder = jobBuilderFactory.get(SnapshotServiceConstants.SNAPSHOT_JOB_NAME);
        SimpleJobBuilder simpleJobBuilder = jobBuilder.start(step);
        simpleJobBuilder.listener(jobListener);

        job = simpleJobBuilder.build();
        log.debug("build job {}", job);

    } catch (Exception e) {
        log.error("Error creating job: {}", e.getMessage(), e);
        throw new SnapshotException(e.getMessage(), e);
    }
    return job;
}