public class DeployerPartitionHandler extends Object implements org.springframework.batch.core.partition.PartitionHandler, org.springframework.context.EnvironmentAware, org.springframework.beans.factory.InitializingBean
A PartitionHandler
implementation that delegates to a TaskLauncher
for
each of the workers. The id of the worker's StepExecution is passed as an environment
variable to the worker. The worker, bootstrapped by the
DeployerStepExecutionHandler
, looks up the StepExecution in the JobRepository
and executes it. This PartitionHandler polls the JobRepository for the results.
If the job fails, the partitions will be re-executed per normal batch rules (steps that are complete should do nothing, failed steps should restart based on their configurations).
This PartitionHandler and all of the worker processes must share the same JobRepository data store (aka point the same database).
Modifier and Type | Field and Description |
---|---|
static String |
SPRING_CLOUD_TASK_JOB_EXECUTION_ID |
static String |
SPRING_CLOUD_TASK_STEP_EXECUTION_ID |
static String |
SPRING_CLOUD_TASK_STEP_NAME |
Constructor and Description |
---|
DeployerPartitionHandler(org.springframework.cloud.deployer.spi.task.TaskLauncher taskLauncher,
org.springframework.batch.core.explore.JobExplorer jobExplorer,
org.springframework.core.io.Resource resource,
String stepName) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
beforeTask(TaskExecution taskExecution) |
Collection<org.springframework.batch.core.StepExecution> |
handle(org.springframework.batch.core.partition.StepExecutionSplitter stepSplitter,
org.springframework.batch.core.StepExecution stepExecution) |
void |
setDeploymentProperties(Map<String,String> deploymentProperties)
Map of deployment properties to be used by the
TaskLauncher |
void |
setEnvironment(org.springframework.core.env.Environment environment) |
void |
setEnvironmentVariablesProvider(EnvironmentVariablesProvider environmentVariablesProvider) |
void |
setGridSize(int gridSize)
Approximate size of the pool of worker JVMs available.
|
void |
setMaxWorkers(int maxWorkers)
The maximum number of workers to be executing at once.
|
void |
setPollInterval(long pollInterval)
The interval to check the job repository for completed steps.
|
void |
setTimeout(long timeout)
Timeout for the master step.
|
public static final String SPRING_CLOUD_TASK_JOB_EXECUTION_ID
public static final String SPRING_CLOUD_TASK_STEP_EXECUTION_ID
public static final String SPRING_CLOUD_TASK_STEP_NAME
public DeployerPartitionHandler(org.springframework.cloud.deployer.spi.task.TaskLauncher taskLauncher, org.springframework.batch.core.explore.JobExplorer jobExplorer, org.springframework.core.io.Resource resource, String stepName)
public void setEnvironmentVariablesProvider(EnvironmentVariablesProvider environmentVariablesProvider)
public void setMaxWorkers(int maxWorkers)
maxWorkers
- number of workers. Defaults to -1 (unlimited)public void setGridSize(int gridSize)
StepExecutionSplitter
to determine how many partitions to create (at the
discretion of the Partitioner
).gridSize
- size of grid. Defaults to 1public void setPollInterval(long pollInterval)
pollInterval
- interval. Defaults to 10 secondspublic void setTimeout(long timeout)
timeout
- timeout. Defaults to none (-1).public void setDeploymentProperties(Map<String,String> deploymentProperties)
TaskLauncher
deploymentProperties
- properites to be used by the TaskLauncher
@BeforeTask public void beforeTask(TaskExecution taskExecution)
public Collection<org.springframework.batch.core.StepExecution> handle(org.springframework.batch.core.partition.StepExecutionSplitter stepSplitter, org.springframework.batch.core.StepExecution stepExecution) throws Exception
handle
in interface org.springframework.batch.core.partition.PartitionHandler
Exception
public void setEnvironment(org.springframework.core.env.Environment environment)
setEnvironment
in interface org.springframework.context.EnvironmentAware
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.