CloudTask Class

  • java.lang.Object
    • com.microsoft.azure.batch.protocol.models.CloudTask

public class CloudTask

An Azure Batch task. Batch will retry tasks when a recovery operation is triggered on a compute node. Examples of recovery operations include (but are not limited to) when an unhealthy compute node is rebooted or a compute node disappeared due to host failure. Retries due to recovery operations are independent of and are not counted against the maxTaskRetryCount. Even if the maxTaskRetryCount is 0, an internal retry due to a recovery operation may occur. Because of this, all tasks should be idempotent. This means tasks need to tolerate being interrupted and restarted without causing any corruption or duplicate data. The best practice for long running tasks is to use some form of checkpointing.

Method Summary

Modifier and Type Method and Description
AffinityInformation affinityInfo()

Get the affinityInfo value.

List<ApplicationPackageReference> applicationPackageReferences()

Get application packages are downloaded and deployed to a shared directory, not the task working directory. Therefore, if a referenced package is already on the compute node, and is up to date, then it is not re-downloaded; the existing copy on the compute node is used. If a referenced application package cannot be installed, for example because the package has been deleted or because download failed, the task fails.

AuthenticationTokenSettings authenticationTokenSettings()

Get if this property is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other tasks to the job, or check the status of the job or of other tasks under the job.

String commandLine()

Get for multi-instance tasks, the command line is executed as the primary task, after the primary task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the task working directory), or use the Batch provided environment variable (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).

TaskConstraints constraints()

Get the constraints value.

TaskContainerSettings containerSettings()

Get if the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and the task command line is executed in the container.

DateTime creationTime()

Get the creationTime value.

TaskDependencies dependsOn()

Get this task will not be scheduled until all tasks that it depends on have completed successfully. If any of those tasks fail and exhaust their retry counts, this task will never be scheduled.

String displayName()

Get the display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.

List<EnvironmentSetting> environmentSettings()

Get the environmentSettings value.

String eTag()

Get this is an opaque string. You can use it to detect whether the task has changed between requests. In particular, you can be pass the ETag when updating a task to specify that your changes should take effect only if nobody else has modified the task in the meantime.

TaskExecutionInformation executionInfo()

Get the executionInfo value.

ExitConditions exitConditions()

Get how the Batch service should respond when the task completes.

String id()

Get the ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters.

DateTime lastModified()

Get the lastModified value.

MultiInstanceSettings multiInstanceSettings()

Get the multiInstanceSettings value.

ComputeNodeInformation nodeInfo()

Get the nodeInfo value.

List<OutputFile> outputFiles()

Get for multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.

TaskState previousState()

Get this property is not set if the task is in its initial Active state. Possible values include: 'active', 'preparing', 'running', 'completed'.

DateTime previousStateTransitionTime()

Get this property is not set if the task is in its initial Active state.

List<ResourceFile> resourceFiles()

Get for multi-instance tasks, the resource files will only be downloaded to the compute node on which the primary task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.

TaskState state()

Get possible values include: 'active', 'preparing', 'running', 'completed'.

DateTime stateTransitionTime()

Get the stateTransitionTime value.

TaskStatistics stats()

Get the stats value.

String url()

Get the url value.

UserIdentity userIdentity()

Get if omitted, the task runs as a non-administrative user unique to the task.

CloudTask withAffinityInfo(AffinityInformation affinityInfo)

Set the affinityInfo value.

CloudTask withApplicationPackageReferences(List<ApplicationPackageReference> applicationPackageReferences)

Set application packages are downloaded and deployed to a shared directory, not the task working directory. Therefore, if a referenced package is already on the compute node, and is up to date, then it is not re-downloaded; the existing copy on the compute node is used. If a referenced application package cannot be installed, for example because the package has been deleted or because download failed, the task fails.

CloudTask withAuthenticationTokenSettings(AuthenticationTokenSettings authenticationTokenSettings)

Set if this property is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other tasks to the job, or check the status of the job or of other tasks under the job.

CloudTask withCommandLine(String commandLine)

Set for multi-instance tasks, the command line is executed as the primary task, after the primary task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the task working directory), or use the Batch provided environment variable (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).

CloudTask withConstraints(TaskConstraints constraints)

Set the constraints value.

CloudTask withContainerSettings(TaskContainerSettings containerSettings)

Set if the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and the task command line is executed in the container.

CloudTask withCreationTime(DateTime creationTime)

Set the creationTime value.

CloudTask withDependsOn(TaskDependencies dependsOn)

Set this task will not be scheduled until all tasks that it depends on have completed successfully. If any of those tasks fail and exhaust their retry counts, this task will never be scheduled.

CloudTask withDisplayName(String displayName)

Set the display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.

CloudTask withEnvironmentSettings(List<EnvironmentSetting> environmentSettings)

Set the environmentSettings value.

CloudTask withETag(String eTag)

Set this is an opaque string. You can use it to detect whether the task has changed between requests. In particular, you can be pass the ETag when updating a task to specify that your changes should take effect only if nobody else has modified the task in the meantime.

CloudTask withExecutionInfo(TaskExecutionInformation executionInfo)

Set the executionInfo value.

CloudTask withExitConditions(ExitConditions exitConditions)

Set how the Batch service should respond when the task completes.

CloudTask withId(String id)

Set the ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters.

CloudTask withLastModified(DateTime lastModified)

Set the lastModified value.

CloudTask withMultiInstanceSettings(MultiInstanceSettings multiInstanceSettings)

Set the multiInstanceSettings value.

CloudTask withNodeInfo(ComputeNodeInformation nodeInfo)

Set the nodeInfo value.

CloudTask withOutputFiles(List<OutputFile> outputFiles)

Set for multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.

CloudTask withPreviousState(TaskState previousState)

Set this property is not set if the task is in its initial Active state. Possible values include: 'active', 'preparing', 'running', 'completed'.

CloudTask withPreviousStateTransitionTime(DateTime previousStateTransitionTime)

Set this property is not set if the task is in its initial Active state.

CloudTask withResourceFiles(List<ResourceFile> resourceFiles)

Set for multi-instance tasks, the resource files will only be downloaded to the compute node on which the primary task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.

CloudTask withState(TaskState state)

Set possible values include: 'active', 'preparing', 'running', 'completed'.

CloudTask withStateTransitionTime(DateTime stateTransitionTime)

Set the stateTransitionTime value.

CloudTask withStats(TaskStatistics stats)

Set the stats value.

CloudTask withUrl(String url)

Set the url value.

CloudTask withUserIdentity(UserIdentity userIdentity)

Set if omitted, the task runs as a non-administrative user unique to the task.

Method Details

affinityInfo

public AffinityInformation affinityInfo()

Get the affinityInfo value.

Returns:

the affinityInfo value

applicationPackageReferences

public List applicationPackageReferences()

Get application packages are downloaded and deployed to a shared directory, not the task working directory. Therefore, if a referenced package is already on the compute node, and is up to date, then it is not re-downloaded; the existing copy on the compute node is used. If a referenced application package cannot be installed, for example because the package has been deleted or because download failed, the task fails.

Returns:

the applicationPackageReferences value

authenticationTokenSettings

public AuthenticationTokenSettings authenticationTokenSettings()

Get if this property is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other tasks to the job, or check the status of the job or of other tasks under the job.

Returns:

the authenticationTokenSettings value

commandLine

public String commandLine()

Get for multi-instance tasks, the command line is executed as the primary task, after the primary task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the task working directory), or use the Batch provided environment variable (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).

Returns:

the commandLine value

constraints

public TaskConstraints constraints()

Get the constraints value.

Returns:

the constraints value

containerSettings

public TaskContainerSettings containerSettings()

Get if the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and the task command line is executed in the container.

Returns:

the containerSettings value

creationTime

public DateTime creationTime()

Get the creationTime value.

Returns:

the creationTime value

dependsOn

public TaskDependencies dependsOn()

Get this task will not be scheduled until all tasks that it depends on have completed successfully. If any of those tasks fail and exhaust their retry counts, this task will never be scheduled.

Returns:

the dependsOn value

displayName

public String displayName()

Get the display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.

Returns:

the displayName value

environmentSettings

public List environmentSettings()

Get the environmentSettings value.

Returns:

the environmentSettings value

eTag

public String eTag()

Get this is an opaque string. You can use it to detect whether the task has changed between requests. In particular, you can be pass the ETag when updating a task to specify that your changes should take effect only if nobody else has modified the task in the meantime.

Returns:

the eTag value

executionInfo

public TaskExecutionInformation executionInfo()

Get the executionInfo value.

Returns:

the executionInfo value

exitConditions

public ExitConditions exitConditions()

Get how the Batch service should respond when the task completes.

Returns:

the exitConditions value

id

public String id()

Get the ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters.

Returns:

the id value

lastModified

public DateTime lastModified()

Get the lastModified value.

Returns:

the lastModified value

multiInstanceSettings

public MultiInstanceSettings multiInstanceSettings()

Get the multiInstanceSettings value.

Returns:

the multiInstanceSettings value

nodeInfo

public ComputeNodeInformation nodeInfo()

Get the nodeInfo value.

Returns:

the nodeInfo value

outputFiles

public List outputFiles()

Get for multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.

Returns:

the outputFiles value

previousState

public TaskState previousState()

Get this property is not set if the task is in its initial Active state. Possible values include: 'active', 'preparing', 'running', 'completed'.

Returns:

the previousState value

previousStateTransitionTime

public DateTime previousStateTransitionTime()

Get this property is not set if the task is in its initial Active state.

Returns:

the previousStateTransitionTime value

resourceFiles

public List resourceFiles()

Get for multi-instance tasks, the resource files will only be downloaded to the compute node on which the primary task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.

Returns:

the resourceFiles value

state

public TaskState state()

Get possible values include: 'active', 'preparing', 'running', 'completed'.

Returns:

the state value

stateTransitionTime

public DateTime stateTransitionTime()

Get the stateTransitionTime value.

Returns:

the stateTransitionTime value

stats

public TaskStatistics stats()

Get the stats value.

Returns:

the stats value

url

public String url()

Get the url value.

Returns:

the url value

userIdentity

public UserIdentity userIdentity()

Get if omitted, the task runs as a non-administrative user unique to the task.

Returns:

the userIdentity value

withAffinityInfo

public CloudTask withAffinityInfo(AffinityInformation affinityInfo)

Set the affinityInfo value.

Parameters:

affinityInfo - the affinityInfo value to set

Returns:

the CloudTask object itself.

withApplicationPackageReferences

public CloudTask withApplicationPackageReferences(List applicationPackageReferences)

Set application packages are downloaded and deployed to a shared directory, not the task working directory. Therefore, if a referenced package is already on the compute node, and is up to date, then it is not re-downloaded; the existing copy on the compute node is used. If a referenced application package cannot be installed, for example because the package has been deleted or because download failed, the task fails.

Parameters:

applicationPackageReferences - the applicationPackageReferences value to set

Returns:

the CloudTask object itself.

withAuthenticationTokenSettings

public CloudTask withAuthenticationTokenSettings(AuthenticationTokenSettings authenticationTokenSettings)

Set if this property is set, the Batch service provides the task with an authentication token which can be used to authenticate Batch service operations without requiring an account access key. The token is provided via the AZ_BATCH_AUTHENTICATION_TOKEN environment variable. The operations that the task can carry out using the token depend on the settings. For example, a task can request job permissions in order to add other tasks to the job, or check the status of the job or of other tasks under the job.

Parameters:

authenticationTokenSettings - the authenticationTokenSettings value to set

Returns:

the CloudTask object itself.

withCommandLine

public CloudTask withCommandLine(String commandLine)

Set for multi-instance tasks, the command line is executed as the primary task, after the primary task and all subtasks have finished executing the coordination command line. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using "cmd /c MyCommand" in Windows or "/bin/sh -c MyCommand" in Linux. If the command line refers to file paths, it should use a relative path (relative to the task working directory), or use the Batch provided environment variable (https://docs.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).

Parameters:

commandLine - the commandLine value to set

Returns:

the CloudTask object itself.

withConstraints

public CloudTask withConstraints(TaskConstraints constraints)

Set the constraints value.

Parameters:

constraints - the constraints value to set

Returns:

the CloudTask object itself.

withContainerSettings

public CloudTask withContainerSettings(TaskContainerSettings containerSettings)

Set if the pool that will run this task has containerConfiguration set, this must be set as well. If the pool that will run this task doesn't have containerConfiguration set, this must not be set. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all task environment variables are mapped into the container, and the task command line is executed in the container.

Parameters:

containerSettings - the containerSettings value to set

Returns:

the CloudTask object itself.

withCreationTime

public CloudTask withCreationTime(DateTime creationTime)

Set the creationTime value.

Parameters:

creationTime - the creationTime value to set

Returns:

the CloudTask object itself.

withDependsOn

public CloudTask withDependsOn(TaskDependencies dependsOn)

Set this task will not be scheduled until all tasks that it depends on have completed successfully. If any of those tasks fail and exhaust their retry counts, this task will never be scheduled.

Parameters:

dependsOn - the dependsOn value to set

Returns:

the CloudTask object itself.

withDisplayName

public CloudTask withDisplayName(String displayName)

Set the display name need not be unique and can contain any Unicode characters up to a maximum length of 1024.

Parameters:

displayName - the displayName value to set

Returns:

the CloudTask object itself.

withEnvironmentSettings

public CloudTask withEnvironmentSettings(List environmentSettings)

Set the environmentSettings value.

Parameters:

environmentSettings - the environmentSettings value to set

Returns:

the CloudTask object itself.

withETag

public CloudTask withETag(String eTag)

Set this is an opaque string. You can use it to detect whether the task has changed between requests. In particular, you can be pass the ETag when updating a task to specify that your changes should take effect only if nobody else has modified the task in the meantime.

Parameters:

eTag - the eTag value to set

Returns:

the CloudTask object itself.

withExecutionInfo

public CloudTask withExecutionInfo(TaskExecutionInformation executionInfo)

Set the executionInfo value.

Parameters:

executionInfo - the executionInfo value to set

Returns:

the CloudTask object itself.

withExitConditions

public CloudTask withExitConditions(ExitConditions exitConditions)

Set how the Batch service should respond when the task completes.

Parameters:

exitConditions - the exitConditions value to set

Returns:

the CloudTask object itself.

withId

public CloudTask withId(String id)

Set the ID can contain any combination of alphanumeric characters including hyphens and underscores, and cannot contain more than 64 characters.

Parameters:

id - the id value to set

Returns:

the CloudTask object itself.

withLastModified

public CloudTask withLastModified(DateTime lastModified)

Set the lastModified value.

Parameters:

lastModified - the lastModified value to set

Returns:

the CloudTask object itself.

withMultiInstanceSettings

public CloudTask withMultiInstanceSettings(MultiInstanceSettings multiInstanceSettings)

Set the multiInstanceSettings value.

Parameters:

multiInstanceSettings - the multiInstanceSettings value to set

Returns:

the CloudTask object itself.

withNodeInfo

public CloudTask withNodeInfo(ComputeNodeInformation nodeInfo)

Set the nodeInfo value.

Parameters:

nodeInfo - the nodeInfo value to set

Returns:

the CloudTask object itself.

withOutputFiles

public CloudTask withOutputFiles(List outputFiles)

Set for multi-instance tasks, the files will only be uploaded from the compute node on which the primary task is executed.

Parameters:

outputFiles - the outputFiles value to set

Returns:

the CloudTask object itself.

withPreviousState

public CloudTask withPreviousState(TaskState previousState)

Set this property is not set if the task is in its initial Active state. Possible values include: 'active', 'preparing', 'running', 'completed'.

Parameters:

previousState - the previousState value to set

Returns:

the CloudTask object itself.

withPreviousStateTransitionTime

public CloudTask withPreviousStateTransitionTime(DateTime previousStateTransitionTime)

Set this property is not set if the task is in its initial Active state.

Parameters:

previousStateTransitionTime - the previousStateTransitionTime value to set

Returns:

the CloudTask object itself.

withResourceFiles

public CloudTask withResourceFiles(List resourceFiles)

Set for multi-instance tasks, the resource files will only be downloaded to the compute node on which the primary task is executed. There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers.

Parameters:

resourceFiles - the resourceFiles value to set

Returns:

the CloudTask object itself.

withState

public CloudTask withState(TaskState state)

Set possible values include: 'active', 'preparing', 'running', 'completed'.

Parameters:

state - the state value to set

Returns:

the CloudTask object itself.

withStateTransitionTime

public CloudTask withStateTransitionTime(DateTime stateTransitionTime)

Set the stateTransitionTime value.

Parameters:

stateTransitionTime - the stateTransitionTime value to set

Returns:

the CloudTask object itself.

withStats

public CloudTask withStats(TaskStatistics stats)

Set the stats value.

Parameters:

stats - the stats value to set

Returns:

the CloudTask object itself.

withUrl

public CloudTask withUrl(String url)

Set the url value.

Parameters:

url - the url value to set

Returns:

the CloudTask object itself.

withUserIdentity

public CloudTask withUserIdentity(UserIdentity userIdentity)

Set if omitted, the task runs as a non-administrative user unique to the task.

Parameters:

userIdentity - the userIdentity value to set

Returns:

the CloudTask object itself.

Applies to