public class

TaskUtil

extends Object
java.lang.Object
   ↳ org.apache.helix.task.TaskUtil

Class Overview

Static utility methods.

Summary

Constants
String CONTEXT_NODE
String PREV_RA_NODE
Public Constructors
TaskUtil()
Public Methods
static Workflow cloneWorkflow(HelixManager manager, String origWorkflowName, String newWorkflowName, Date newStartTime)
Create a new workflow based on an existing one
static Map<StringString> deserializeJobCommandConfigMap(String commandConfig)
Deserialize a single string into a map of job-level configurations
static String getDenamespacedJobName(String workflowResource, String jobName)
Remove the workflow namespace from the job name
static JobConfig getJobCfg(HelixDataAccessor accessor, String jobResource)
Parses job resource configurations in Helix into a JobConfig object.
static JobConfig getJobCfg(HelixManager manager, String jobResource)
Parses job resource configurations in Helix into a JobConfig object.
static JobContext getJobContext(HelixPropertyStore<ZNRecord> propertyStore, String jobResource)
Get the runtime context of a single job
static JobContext getJobContext(HelixManager manager, String jobResource)
Get the runtime context of a single job
static String getNamespacedJobName(String workflowResource, String jobName)
Get a workflow-qualified job name for a job in that workflow
static String getNamespacedJobName(String singleJobWorkflow)
Get a workflow-qualified job name for a single-job workflow
static ResourceAssignment getPrevResourceAssignment(HelixManager manager, String resourceName)
Get the last task assignment for a given job
static HelixConfigScope getResourceConfigScope(String clusterName, String resource)
Get a Helix configuration scope at a resource (i.e.
static WorkflowConfig getWorkflowCfg(ConfigAccessor cfgAccessor, HelixDataAccessor accessor, String clusterName, String workflowResource)
Parses workflow resource configurations in Helix into a WorkflowConfig object.
static WorkflowConfig getWorkflowCfg(HelixManager manager, String workflowResource)
Parses workflow resource configurations in Helix into a WorkflowConfig object.
static WorkflowContext getWorkflowContext(HelixPropertyStore<ZNRecord> propertyStore, String workflowResource)
Get the runtime context of a single workflow
static WorkflowContext getWorkflowContext(HelixManager manager, String workflowResource)
Get the runtime context of a single workflow
static void invokeRebalance(HelixManager manager, String resource)
Trigger a controller pipeline execution for a given resource.
static ScheduleConfig parseScheduleFromConfigMap(Map<StringString> cfg)
Get a ScheduleConfig from a workflow config string map
static String serializeJobCommandConfigMap(Map<StringString> commandConfig)
Serialize a map of job-level configurations as a single string
static void setJobContext(HelixManager manager, String jobResource, JobContext ctx)
Set the runtime context of a single job
static void setPrevResourceAssignment(HelixManager manager, String resourceName, ResourceAssignment ra)
Set the last task assignment for a given job
static boolean setRequestedState(HelixDataAccessor accessor, String instance, String sessionId, String resource, String partition, TaskPartitionState state)
Request a state change for a specific task.
static void setWorkflowContext(HelixManager manager, String workflowResource, WorkflowContext ctx)
Set the runtime context of a single workflow
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final String CONTEXT_NODE

Constant Value: "Context"

public static final String PREV_RA_NODE

Constant Value: "PreviousResourceAssignment"

Public Constructors

public TaskUtil ()

Public Methods

public static Workflow cloneWorkflow (HelixManager manager, String origWorkflowName, String newWorkflowName, Date newStartTime)

Create a new workflow based on an existing one

Parameters
manager connection to Helix
origWorkflowName the name of the existing workflow
newWorkflowName the name of the new workflow
newStartTime a provided start time that deviates from the desired start time
Returns
  • the cloned workflow, or null if there was a problem cloning the existing one

public static Map<StringString> deserializeJobCommandConfigMap (String commandConfig)

Deserialize a single string into a map of job-level configurations

Parameters
commandConfig the serialized job config map
Returns
  • a map of job config key to config value

public static String getDenamespacedJobName (String workflowResource, String jobName)

Remove the workflow namespace from the job name

Parameters
workflowResource the name of the workflow that owns the job
jobName the namespaced job name
Returns
  • the denamespaced job name, or the same job name if it is already denamespaced

public static JobConfig getJobCfg (HelixDataAccessor accessor, String jobResource)

Parses job resource configurations in Helix into a JobConfig object.

Parameters
accessor Accessor to access Helix configs
jobResource The name of the job resource
Returns
  • A JobConfig object if Helix contains valid configurations for the job, null otherwise.

public static JobConfig getJobCfg (HelixManager manager, String jobResource)

Parses job resource configurations in Helix into a JobConfig object.

Parameters
manager HelixManager object used to connect to Helix.
jobResource The name of the job resource.
Returns
  • A JobConfig object if Helix contains valid configurations for the job, null otherwise.

public static JobContext getJobContext (HelixPropertyStore<ZNRecord> propertyStore, String jobResource)

Get the runtime context of a single job

Parameters
propertyStore Property store for the cluster
jobResource The name of the job
Returns

public static JobContext getJobContext (HelixManager manager, String jobResource)

Get the runtime context of a single job

Parameters
manager a connection to Helix
jobResource the name of the job
Returns

public static String getNamespacedJobName (String workflowResource, String jobName)

Get a workflow-qualified job name for a job in that workflow

Parameters
workflowResource the name of the workflow
jobName the un-namespaced name of the job
Returns
  • The namespaced job name, which is just workflowResource_jobName

public static String getNamespacedJobName (String singleJobWorkflow)

Get a workflow-qualified job name for a single-job workflow

Parameters
singleJobWorkflow the name of the single-job workflow
Returns
  • The namespaced job name, which is just singleJobWorkflow_singleJobWorkflow

public static ResourceAssignment getPrevResourceAssignment (HelixManager manager, String resourceName)

Get the last task assignment for a given job

Parameters
manager a connection to Helix
resourceName the name of the job
Returns

public static HelixConfigScope getResourceConfigScope (String clusterName, String resource)

Get a Helix configuration scope at a resource (i.e. job and workflow) level

Parameters
clusterName the cluster containing the resource
resource the resource name
Returns

public static WorkflowConfig getWorkflowCfg (ConfigAccessor cfgAccessor, HelixDataAccessor accessor, String clusterName, String workflowResource)

Parses workflow resource configurations in Helix into a WorkflowConfig object.

Parameters
cfgAccessor Config accessor to access Helix configs
accessor Accessor to access Helix configs
clusterName Cluster name
workflowResource The name of the workflow resource.
Returns
  • A WorkflowConfig object if Helix contains valid configurations for the workflow, null otherwise.

public static WorkflowConfig getWorkflowCfg (HelixManager manager, String workflowResource)

Parses workflow resource configurations in Helix into a WorkflowConfig object.

Parameters
manager Helix manager object used to connect to Helix.
workflowResource The name of the workflow resource.
Returns
  • A WorkflowConfig object if Helix contains valid configurations for the workflow, null otherwise.

public static WorkflowContext getWorkflowContext (HelixPropertyStore<ZNRecord> propertyStore, String workflowResource)

Get the runtime context of a single workflow

Parameters
propertyStore Property store of the cluster
workflowResource The name of the workflow
Returns

public static WorkflowContext getWorkflowContext (HelixManager manager, String workflowResource)

Get the runtime context of a single workflow

Parameters
manager a connection to Helix
workflowResource the name of the workflow
Returns

public static void invokeRebalance (HelixManager manager, String resource)

Trigger a controller pipeline execution for a given resource.

Parameters
manager Helix connection
resource the name of the resource changed to triggering the execution

public static ScheduleConfig parseScheduleFromConfigMap (Map<StringString> cfg)

Get a ScheduleConfig from a workflow config string map

Parameters
cfg the string map
Returns
  • a ScheduleConfig if one exists, otherwise null

public static String serializeJobCommandConfigMap (Map<StringString> commandConfig)

Serialize a map of job-level configurations as a single string

Parameters
commandConfig map of job config key to config value
Returns
  • serialized string

public static void setJobContext (HelixManager manager, String jobResource, JobContext ctx)

Set the runtime context of a single job

Parameters
manager a connection to Helix
jobResource the name of the job
ctx the up-to-date JobContext for the job

public static void setPrevResourceAssignment (HelixManager manager, String resourceName, ResourceAssignment ra)

Set the last task assignment for a given job

Parameters
manager a connection to Helix
resourceName the name of the job
ra ResourceAssignment containing the task assignment

public static boolean setRequestedState (HelixDataAccessor accessor, String instance, String sessionId, String resource, String partition, TaskPartitionState state)

Request a state change for a specific task.

Parameters
accessor connected Helix data accessor
instance the instance serving the task
sessionId the current session of the instance
resource the job name
partition the task partition name
state the requested state
Returns
  • true if the request was persisted, false otherwise

public static void setWorkflowContext (HelixManager manager, String workflowResource, WorkflowContext ctx)

Set the runtime context of a single workflow

Parameters
manager a connection to Helix
workflowResource the name of the workflow
ctx the up-to-date WorkflowContext for the workflow