Example usage for org.springframework.batch.core.partition StepExecutionSplitter split

List of usage examples for org.springframework.batch.core.partition StepExecutionSplitter split

Introduction

In this page you can find the example usage for org.springframework.batch.core.partition StepExecutionSplitter split.

Prototype

Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException;

Source Link

Document

Partition the provided StepExecution into a set of parallel executable instances with the same parent JobExecution .

Usage

From source file:org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.java

@Override
public Collection<StepExecution> handle(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
        throws Exception {

    final Set<StepExecution> tempCandidates = stepSplitter.split(stepExecution, this.gridSize);

    // Following two lines due to https://jira.spring.io/browse/BATCH-2490
    final Set<StepExecution> candidates = new HashSet<>(tempCandidates.size());
    candidates.addAll(tempCandidates);//from w  w w.  j a va  2s  . c  o  m

    int partitions = candidates.size();

    logger.debug(String.format("%s partitions were returned", partitions));

    final Set<StepExecution> executed = new HashSet<>(candidates.size());

    if (CollectionUtils.isEmpty(candidates)) {
        return null;
    }

    launchWorkers(candidates, executed);

    candidates.removeAll(executed);

    return pollReplies(stepExecution, executed, candidates, partitions);
}

From source file:org.springframework.yarn.batch.partition.HdfsSplitBatchPartitionHandler.java

@Override
protected Set<StepExecution> createStepExecutionSplits(StepExecutionSplitter stepSplitter,
        StepExecution stepExecution) throws Exception {

    String input = stepExecution.getJobParameters().getString("input");
    log.info("Input is " + input);

    FileSystem fs = FileSystem.get(configuration);
    Path path = new Path(input);
    FileStatus[] fileStatuses = fs.globStatus(path);

    Set<StepExecution> split = stepSplitter.split(stepExecution, fileStatuses.length);
    return split;
}

From source file:org.springframework.yarn.batch.partition.StaticBatchPartitionHandler.java

@Override
protected Set<StepExecution> createStepExecutionSplits(StepExecutionSplitter stepSplitter,
        StepExecution stepExecution) throws Exception {
    if (log.isDebugEnabled()) {
        log.debug("Creating splits for stepExecution=" + stepExecution + " with gridSize=" + gridSize);
    }/*from w  w w  . j av  a 2  s . c o m*/
    return stepSplitter.split(stepExecution, gridSize);
}

From source file:org.springframework.yarn.batch.partition.StaticPartitionHandler.java

@Override
protected Set<StepExecution> createSplits(StepExecutionSplitter stepSplitter, StepExecution stepExecution)
        throws Exception {
    log.info("Creating splits for stepExecution=[" + stepExecution + "] with gridSize=" + gridSize);
    return stepSplitter.split(stepExecution, gridSize);
}