EMMA Coverage Report (generated Thu May 22 12:08:10 CDT 2014)
[all classes][org.springframework.batch.core.partition.support]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractPartitionHandler.java]

nameclass, %method, %block, %line, %
AbstractPartitionHandler.java100% (1/1)100% (4/4)100% (24/24)100% (7/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractPartitionHandler100% (1/1)100% (4/4)100% (24/24)100% (7/7)
AbstractPartitionHandler (): void 100% (1/1)100% (6/6)100% (2/2)
getGridSize (): int 100% (1/1)100% (3/3)100% (1/1)
handle (StepExecutionSplitter, StepExecution): Collection 100% (1/1)100% (11/11)100% (2/2)
setGridSize (int): void 100% (1/1)100% (4/4)100% (2/2)

1/*
2 * Copyright 2006-2013 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 */
16package org.springframework.batch.core.partition.support;
17 
18import java.util.Collection;
19import java.util.Set;
20 
21import org.springframework.batch.core.StepExecution;
22import org.springframework.batch.core.partition.PartitionHandler;
23import org.springframework.batch.core.partition.StepExecutionSplitter;
24 
25/**
26 * Base {@link PartitionHandler} implementation providing common base
27 * features. Subclasses are expected to implement only the
28 * {@link #doHandle(org.springframework.batch.core.StepExecution, java.util.Set)}
29 * method which returns with the result of the execution(s) or an exception if
30 * the step failed to process.
31 *
32 * @author Sebastien Gerard
33 * @author Dave Syer
34 */
35public abstract class AbstractPartitionHandler implements PartitionHandler {
36 
37        private int gridSize = 1;
38 
39        /**
40         * Executes the specified {@link StepExecution} instances and returns an updated
41         * view of them. Throws an {@link Exception} if anything goes wrong.
42         *
43         * @param masterStepExecution the whole partition execution
44         * @param partitionStepExecutions the {@link StepExecution} instances to execute
45         * @return an updated view of these completed {@link StepExecution} instances
46         * @throws Exception if anything goes wrong. This allows implementations to
47         * be liberal and rely on the caller to translate an exception into a step
48         * failure as necessary.
49         */
50        protected abstract Set<StepExecution> doHandle(StepExecution masterStepExecution,
51                        Set<StepExecution> partitionStepExecutions) throws Exception;
52 
53        /**
54         * @see PartitionHandler#handle(StepExecutionSplitter, StepExecution)
55         */
56        @Override
57        public Collection<StepExecution> handle(final StepExecutionSplitter stepSplitter,
58                        final StepExecution masterStepExecution) throws Exception {
59                final Set<StepExecution> stepExecutions = stepSplitter.split(masterStepExecution, gridSize);
60 
61                return doHandle(masterStepExecution, stepExecutions);
62        }
63 
64        /**
65         * Returns the number of step executions.
66         *
67         * @return the number of step executions
68         */
69        public int getGridSize() {
70                return gridSize;
71        }
72 
73        /**
74         * Passed to the {@link StepExecutionSplitter} in the
75         * {@link #handle(StepExecutionSplitter, StepExecution)} method, instructing
76         * it how many {@link StepExecution} instances are required, ideally. The
77         * {@link StepExecutionSplitter} is allowed to ignore the grid size in the
78         * case of a restart, since the input data partitions must be preserved.
79         *
80         * @param gridSize the number of step executions that will be created
81         */
82        public void setGridSize(int gridSize) {
83                this.gridSize = gridSize;
84        }
85 
86}
87 

[all classes][org.springframework.batch.core.partition.support]
EMMA 2.0.5312 (C) Vladimir Roubtsov