001/* 002 * Copyright 2006-2007 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.batch.core.partition; 018 019import org.springframework.batch.core.JobExecution; 020import org.springframework.batch.core.JobExecutionException; 021import org.springframework.batch.core.StepExecution; 022 023import java.util.Set; 024 025/** 026 * Strategy interface for generating input contexts for a partitioned step 027 * execution independent from the fabric they are going to run on. 028 * 029 * @author Dave Syer 030 * @since 2.0 031 */ 032public interface StepExecutionSplitter { 033 034 /** 035 * The name of the step configuration that will be executed remotely. Remote 036 * workers are going to execute a the same step for each execution context 037 * in the partition. 038 * @return the name of the step that will execute the business logic 039 */ 040 String getStepName(); 041 042 /** 043 * Partition the provided {@link StepExecution} into a set of parallel 044 * executable instances with the same parent {@link JobExecution}. The grid 045 * size will be treated as a hint for the size of the collection to be 046 * returned. It may or may not correspond to the physical size of an 047 * execution grid.<br> 048 * <br> 049 * 050 * On a restart clients of the {@link StepExecutionSplitter} should expect 051 * it to reconstitute the state of the last failed execution and only return 052 * those executions that need to be restarted. Thus the grid size hint will 053 * be ignored on a restart. 054 * 055 * @param stepExecution the {@link StepExecution} to be partitioned. 056 * @param gridSize a hint for the splitter if the size of the grid is known 057 * @return a set of {@link StepExecution} instances for remote processing 058 * 059 * @throws JobExecutionException if the split cannot be made 060 */ 061 Set<StepExecution> split(StepExecution stepExecution, int gridSize) throws JobExecutionException; 062 063}