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_EXECUTION_ID
ID of the Spring Cloud Task execution.
|
static String |
SPRING_CLOUD_TASK_JOB_EXECUTION_ID
ID of Spring Cloud Task job execution.
|
static String |
SPRING_CLOUD_TASK_NAME
Spring Cloud Task name property.
|
static String |
SPRING_CLOUD_TASK_PARENT_EXECUTION_ID
ID of Spring Cloud Task parent execution.
|
static String |
SPRING_CLOUD_TASK_STEP_EXECUTION_ID
ID of Spring Cloud Task step execution.
|
static String |
SPRING_CLOUD_TASK_STEP_NAME
Name of Spring Cloud Task step.
|
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)
Deprecated.
Use the constructor that accepts
TaskRepository as well as the
this constructor's set of parameters. |
DeployerPartitionHandler(org.springframework.cloud.deployer.spi.task.TaskLauncher taskLauncher,
org.springframework.batch.core.explore.JobExplorer jobExplorer,
org.springframework.core.io.Resource resource,
String stepName,
TaskRepository taskRepository) |
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 |
setApplicationName(String applicationName)
The name of the application to be launched.
|
void |
setCommandLineArgsProvider(CommandLineArgsProvider commandLineArgsProvider)
Used to provide any command line arguements to be passed to each worker launched.
|
void |
setDefaultArgsAsEnvironmentVars(boolean defaultArgsAsEnvironmentVars)
If set to true, the default args that are used internally by Spring Cloud Task and
Spring Batch are passed as environment variables instead of command line arguments.
|
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)
Used to provide any environment variables to be set on each worker launched.
|
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 static final String SPRING_CLOUD_TASK_PARENT_EXECUTION_ID
public static final String SPRING_CLOUD_TASK_EXECUTION_ID
public static final String SPRING_CLOUD_TASK_NAME
@Deprecated 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)
TaskRepository
as well as the
this constructor's set of parameters.taskLauncher
- the launcher used to execute partitioned tasks.jobExplorer
- used to acquire the status of the job.resource
- the url to the app to be launched.stepName
- the name of the step.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, TaskRepository taskRepository)
public void setEnvironmentVariablesProvider(EnvironmentVariablesProvider environmentVariablesProvider)
environmentVariablesProvider
- an EnvironmentVariablesProvider
public void setDefaultArgsAsEnvironmentVars(boolean defaultArgsAsEnvironmentVars)
defaultArgsAsEnvironmentVars
- defaults to falsepublic void setCommandLineArgsProvider(CommandLineArgsProvider commandLineArgsProvider)
commandLineArgsProvider
- CommandLineArgsProvider
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
- properties to be used by the TaskLauncher
public void setApplicationName(String applicationName)
applicationName
- The name of the application to be launched@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 © 2021 Pivotal Software, Inc.. All rights reserved.