Class TaskServiceUtils
java.lang.Object
org.springframework.cloud.dataflow.server.service.impl.TaskServiceUtils
Provides utility methods for setting up tasks for execution.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
addDatabaseCredentials
(boolean useKubernetesSecrets, String platformType) Determines if a database credentials should be added to task properties.static void
contributeCommonProperties
(Optional<Properties> defaultProperties, Map<String, String> appDeploymentProperties, String taskPlatformType) Merge the common properties defined via the spring.cloud.dataflow.common-properties.task-resource file.static String
Creates a properly formatted CTR definition based on the graph provided.static String
createComposedTaskDefinition
(String alternateComposedTaskRunnerName, String graph) Creates a properly formatted CTR definition based on the graph provided.establishComposedTaskProperties
(Map<String, String> taskDeploymentProperties, org.springframework.cloud.dataflow.core.dsl.TaskNode taskNode) Establish the app and deployment properties to be used for a CTR.Extract app properties from the deployment properties by task name.extractAppProperties
(String name, Map<String, String> taskDeploymentProperties) Extract app properties from the deployment properties by task name.static boolean
Parses the task DSL to see if it is a composed task definitionstatic String
labelForSimpleTask
(String name, String dsl) static org.springframework.cloud.deployer.spi.core.AppDefinition
mergeAndExpandAppProperties
(TaskDefinition original, Resource resource, Map<String, String> appDeploymentProperties, VisibleProperties visibleProperties) Return a copy of a given task definition where short form parameters have been expanded to their long form (amongst the visible properties of the app) if applicable.static void
updateDataFlowUriIfNeeded
(String dataFlowServerUriKey, String dataflowServerUri, Map<String, String> appDeploymentProperties, List<String> commandLineArgs) static void
updateDataFlowUriIfNeeded
(String dataflowServerUri, Map<String, String> appDeploymentProperties, List<String> commandLineArgs) static TaskDefinition
updateTaskProperties
(TaskDefinition taskDefinition, org.springframework.boot.autoconfigure.jdbc.DataSourceProperties dataSourceProperties) Updates the task definition with the datasource properties.static TaskDefinition
updateTaskProperties
(TaskDefinition taskDefinition, org.springframework.boot.autoconfigure.jdbc.DataSourceProperties dataSourceProperties, boolean setDatabaseCredentials) Updates the task definition with the datasource properties.
-
Constructor Details
-
TaskServiceUtils
public TaskServiceUtils()
-
-
Method Details
-
isComposedTaskDefinition
Parses the task DSL to see if it is a composed task definition- Parameters:
dsl
- task DSL- Returns:
- true if composed, false otherwise.
-
createComposedTaskDefinition
Creates a properly formatted CTR definition based on the graph provided.- Parameters:
graph
- the graph for the CTR to execute.- Returns:
- String containing the CTR task definition.
-
createComposedTaskDefinition
public static String createComposedTaskDefinition(String alternateComposedTaskRunnerName, String graph) Creates a properly formatted CTR definition based on the graph provided.- Parameters:
alternateComposedTaskRunnerName
- a ctr name to be used instead of the default.graph
- the graph for the CTR to execute. of the CTR app to be launched.- Returns:
- String containing the CTR task definition.
-
establishComposedTaskProperties
public static Map<String,String> establishComposedTaskProperties(Map<String, String> taskDeploymentProperties, org.springframework.cloud.dataflow.core.dsl.TaskNode taskNode) Establish the app and deployment properties to be used for a CTR.- Parameters:
taskDeploymentProperties
- properties to be parsed for the CTR.taskNode
- containing the tasks apps to be executed by the CTR- Returns:
- properties that can be consumed by the CTR.
-
updateTaskProperties
public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, org.springframework.boot.autoconfigure.jdbc.DataSourceProperties dataSourceProperties) Updates the task definition with the datasource properties.- Parameters:
taskDefinition
- theTaskDefinition
to be updated.dataSourceProperties
- the dataSource properties used by SCDF.- Returns:
- the updated
TaskDefinition
-
updateTaskProperties
public static TaskDefinition updateTaskProperties(TaskDefinition taskDefinition, org.springframework.boot.autoconfigure.jdbc.DataSourceProperties dataSourceProperties, boolean setDatabaseCredentials) Updates the task definition with the datasource properties.- Parameters:
taskDefinition
- theTaskDefinition
to be updated.dataSourceProperties
- the dataSource properties used by SCDF.setDatabaseCredentials
- if true database username and password that should be set in theTaskDefinition
.- Returns:
- the updated
TaskDefinition
-
extractAppProperties
public static Map<String,String> extractAppProperties(String name, Map<String, String> taskDeploymentProperties) Extract app properties from the deployment properties by task name.- Parameters:
name
- the task app name to search for in the deployment properties.taskDeploymentProperties
- the properties for the task deployment.- Returns:
- a map containing the app properties for a task.
-
extractAppProperties
public static Map<String,String> extractAppProperties(String name, String label, Map<String, String> taskDeploymentProperties) Extract app properties from the deployment properties by task name.- Parameters:
name
- the task app name to search for in the deployment properties.label
- the taks app label to search for in the deployment properties.taskDeploymentProperties
- the properties for the task deployment.- Returns:
- a map containing the app properties for a task.
-
mergeAndExpandAppProperties
public static org.springframework.cloud.deployer.spi.core.AppDefinition mergeAndExpandAppProperties(TaskDefinition original, Resource resource, Map<String, String> appDeploymentProperties, VisibleProperties visibleProperties) Return a copy of a given task definition where short form parameters have been expanded to their long form (amongst the visible properties of the app) if applicable.- Parameters:
original
- the task definition with the original set of properties.resource
- the resource to be used for identifying included properties.appDeploymentProperties
- the app deployment properties to be added to theAppDefinition
.visibleProperties
- util for formatting visible properties properly.- Returns:
- fully qualified
AppDefinition
.
-
updateDataFlowUriIfNeeded
-
updateDataFlowUriIfNeeded
-
labelForSimpleTask
-
addDatabaseCredentials
Determines if a database credentials should be added to task properties.- Parameters:
platformType
- The type of platform.useKubernetesSecrets
- User wants to use kubernetes secrets for user name and password.- Returns:
- true if database credentials should be added to task properties.
-
contributeCommonProperties
public static void contributeCommonProperties(Optional<Properties> defaultProperties, Map<String, String> appDeploymentProperties, String taskPlatformType) Merge the common properties defined via the spring.cloud.dataflow.common-properties.task-resource file. Doesn't override existing properties! The placeholders defined in the task-resource file are not resolved by SCDF but passed to the apps as they are.- Parameters:
defaultProperties
- Default properties, if any, to contribute to the launch app properties.appDeploymentProperties
- App deployment properties passed to the Task at launch.taskPlatformType
- the platform type
-