View Javadoc

1   /*
2    * Copyright 2006-2007 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.springframework.batch.core.partition;
18  
19  import java.util.Set;
20  
21  import org.springframework.batch.core.JobExecution;
22  import org.springframework.batch.core.JobExecutionException;
23  import org.springframework.batch.core.StepExecution;
24  
25  /**
26   * Strategy interface for generating input contexts for a partitioned step
27   * execution independent from the fabric they are going to run on.
28   * 
29   * @author Dave Syer
30   * @since 2.0
31   */
32  public interface StepExecutionSplitter {
33  
34  	/**
35  	 * The name of the step configuration that will be executed remotely. Remote
36  	 * workers are going to execute a the same step for each execution context
37  	 * in the partition.
38  	 * @return the name of the step that will execute the business logic
39  	 */
40  	String getStepName();
41  
42  	/**
43  	 * Partition the provided {@link StepExecution} into a set of parallel
44  	 * executable instances with the same parent {@link JobExecution}. The grid
45  	 * size will be treated as a hint for the size of the collection to be
46  	 * returned. It may or may not correspond to the physical size of an
47  	 * execution grid.<br/>
48  	 * <br/>
49  	 * 
50  	 * On a restart clients of the {@link StepExecutionSplitter} should expect
51  	 * it to reconstitute the state of the last failed execution and only return
52  	 * those executions that need to be restarted. Thus the grid size hint will
53  	 * be ignored on a restart.
54  	 * 
55  	 * @param stepExecution the {@link StepExecution} to be partitioned.
56  	 * @param gridSize a hint for the splitter if the size of the grid is known
57  	 * @return a set of {@link StepExecution} instances for remote processing
58  	 * 
59  	 * @throws JobExecutionException if the split cannot be made
60  	 */
61  	Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException;
62  
63  }