StartTask Class
- java.
lang. Object - com.
microsoft. azure. batch. protocol. models. StartTask
- com.
public class StartTask
A Task which is run when a Node joins a Pool in the Azure Batch service, or when the Compute Node is rebooted or reimaged. Batch will retry Tasks when a recovery operation is triggered on a Node. Examples of recovery operations include (but are not limited to) when an unhealthy 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. In some cases the StartTask may be re-run even though the Compute Node was not rebooted. Special care should be taken to avoid StartTasks which create breakaway process or install/launch services from the StartTask working directory, as this will block Batch from being able to re-run the StartTask.
Constructor Summary
Constructor | Description | |
---|---|---|
StartTask() |
Method Summary
Modifier and Type | Method and Description |
---|---|
String |
commandLine()
Get the command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. |
Task |
containerSettings()
Get 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. |
List<Environment |
environmentSettings()
Get the environment |
Integer |
maxTaskRetryCount()
Get the Batch service retries a Task if its exit code is nonzero. |
List<Resource |
resourceFiles()
Get files listed under this element are located in the Task's working directory. |
User |
userIdentity()
Get if omitted, the Task runs as a non-administrative user unique to the Task. |
Boolean |
waitForSuccess()
Get if true and the Start |
Start |
withCommandLine(String commandLine)
Set the command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. |
Start |
withContainerSettings(TaskContainerSettings containerSettings)
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. |
Start |
withEnvironmentSettings(List<EnvironmentSetting> environmentSettings)
Set the environment |
Start |
withMaxTaskRetryCount(Integer maxTaskRetryCount)
Set the Batch service retries a Task if its exit code is nonzero. |
Start |
withResourceFiles(List<ResourceFile> resourceFiles)
Set files listed under this element are located in the Task's working directory. |
Start |
withUserIdentity(UserIdentity userIdentity)
Set if omitted, the Task runs as a non-administrative user unique to the Task. |
Start |
withWaitForSuccess(Boolean waitForSuccess)
Set if true and the Start |
Methods inherited from java.lang.Object
Constructor Details
StartTask
public StartTask()
Method Details
commandLine
public String commandLine()
Get 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/azure/batch/batch-compute-node-environment-variables).
Returns:
containerSettings
public TaskContainerSettings containerSettings()
Get 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. Files produced in the container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file APIs will not be able to access those files.
Returns:
environmentSettings
public List
Get the environmentSettings value.
Returns:
maxTaskRetryCount
public Integer maxTaskRetryCount()
Get the Batch service retries a Task if its exit code is nonzero. Note that this value specifically controls the number of retries. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries).
Returns:
resourceFiles
public List
Get files listed under this element are located in the Task's working directory.
Returns:
userIdentity
public UserIdentity userIdentity()
Get if omitted, the Task runs as a non-administrative user unique to the Task.
Returns:
waitForSuccess
public Boolean waitForSuccess()
Get if true and the StartTask fails on a Node, the Batch service retries the StartTask up to its maximum retry count (maxTaskRetryCount). If the Task has still not completed successfully after all retries, then the Batch service marks the Node unusable, and will not schedule Tasks to it. This condition can be detected via the Compute Node state and failure info details. If false, the Batch service will not wait for the StartTask to complete. In this case, other Tasks can start executing on the Compute Node while the StartTask is still running; and even if the StartTask fails, new Tasks will continue to be scheduled on the Compute Node. The default is true.
Returns:
withCommandLine
public StartTask withCommandLine(String commandLine)
Set 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/azure/batch/batch-compute-node-environment-variables).
Parameters:
Returns:
withContainerSettings
public StartTask withContainerSettings(TaskContainerSettings containerSettings)
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. Files produced in the container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file APIs will not be able to access those files.
Parameters:
Returns:
withEnvironmentSettings
public StartTask withEnvironmentSettings(List
Set the environmentSettings value.
Parameters:
Returns:
withMaxTaskRetryCount
public StartTask withMaxTaskRetryCount(Integer maxTaskRetryCount)
Set the Batch service retries a Task if its exit code is nonzero. Note that this value specifically controls the number of retries. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries).
Parameters:
Returns:
withResourceFiles
public StartTask withResourceFiles(List
Set files listed under this element are located in the Task's working directory.
Parameters:
Returns:
withUserIdentity
public StartTask withUserIdentity(UserIdentity userIdentity)
Set if omitted, the Task runs as a non-administrative user unique to the Task.
Parameters:
Returns:
withWaitForSuccess
public StartTask withWaitForSuccess(Boolean waitForSuccess)
Set if true and the StartTask fails on a Node, the Batch service retries the StartTask up to its maximum retry count (maxTaskRetryCount). If the Task has still not completed successfully after all retries, then the Batch service marks the Node unusable, and will not schedule Tasks to it. This condition can be detected via the Compute Node state and failure info details. If false, the Batch service will not wait for the StartTask to complete. In this case, other Tasks can start executing on the Compute Node while the StartTask is still running; and even if the StartTask fails, new Tasks will continue to be scheduled on the Compute Node. The default is true.
Parameters:
Returns:
Applies to
Azure SDK for Java