你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

StartTask 类

  • java.lang.Object
    • com.microsoft.azure.management.batch.StartTask

public class StartTask

当计算节点加入Azure Batch服务中的池时,或者在重新启动或重置计算节点映像时运行的任务。 在某些情况下,即使节点未重新启动,启动任务也可能重新运行。 因此,启动任务应是幂等的,如果它们正在执行的设置已经完成,则应正常退出。 应特别小心,避免启动任务创建分离进程或从启动任务工作目录安装/启动服务,因为这样会阻止 Batch 重新运行启动任务。

构造函数摘要

构造函数 说明
StartTask()

方法摘要

修饰符和类型 方法和描述
java.lang.String commandLine()

获取命令行不会在 shell 下运行,因此无法利用 shell 功能,例如环境变量扩展。

TaskContainerSettings containerSettings()

指定此项时获取,AZ_BATCH_NODE_ROOT_DIR (节点上) Azure Batch目录的根目录以递归方式映射到容器中,所有任务环境变量都映射到容器中,任务命令行在容器中执行。

java.util.List<EnvironmentSetting> environmentSettings()

获取“环境设置”值。

java.lang.Integer maxTaskRetryCount()

如果任务退出代码不为零,则获取 Batch 服务会重试该任务。

java.util.List<ResourceFile> resourceFiles()

获取资源文件值。

UserIdentity userIdentity()

如果省略,则获取 ,则任务以任务唯一的非管理用户身份运行。

java.lang.Boolean waitForSuccess()

如果为 true 且计算节点上的启动任务失败,Batch 服务将重试启动任务的最大重试计数 (最大任务重试计数) 。

StartTask withCommandLine(String commandLine)

设置命令行不会在 shell 下运行,因此无法利用 shell 功能,例如环境变量扩展。

StartTask withContainerSettings(TaskContainerSettings containerSettings)

如果指定此设置,则以递归方式AZ_BATCH_NODE_ROOT_DIR (节点上Azure Batch目录的根目录) 映射到容器中,所有任务环境变量都映射到容器中,并在容器中执行任务命令行。

StartTask withEnvironmentSettings(List<EnvironmentSetting> environmentSettings)

设置“环境设置”值。

StartTask withMaxTaskRetryCount(Integer maxTaskRetryCount)

设置 Batch 服务在任务的退出代码为非零时重试任务。

StartTask withResourceFiles(List<ResourceFile> resourceFiles)

设置资源文件值。

StartTask withUserIdentity(UserIdentity userIdentity)

如果省略,则设置任务作为任务唯一的非管理用户运行。

StartTask withWaitForSuccess(Boolean waitForSuccess)

如果计算节点上的启动任务失败,则设置为 true,Batch 服务会将启动任务重试到其最大重试计数 (最大任务重试计数) 。

方法继承自 java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

构造函数详细信息

StartTask

public StartTask()

方法详细信息

commandLine

public String commandLine()

获取命令行不会在 shell 下运行,因此无法利用 shell 功能,例如环境变量扩展。 如果要利用此类功能,则应在命令行中调用 shell,例如在 Windows 中使用“cmd /c MyCommand”或在 Linux 中使用“/bin/sh -c MyCommand”。 如果指定了 startTask 的任何其他属性,则为必需。

Returns:

commandLine 值

containerSettings

public TaskContainerSettings containerSettings()

指定此项时获取,AZ_BATCH_NODE_ROOT_DIR (节点上) Azure Batch目录的根目录以递归方式映射到容器中,所有任务环境变量都映射到容器中,任务命令行在容器中执行。

Returns:

containerSettings 值

environmentSettings

public List environmentSettings()

获取 environmentSettings 值。

Returns:

environmentSettings 值

maxTaskRetryCount

public Integer maxTaskRetryCount()

如果任务退出代码不为零,则获取 Batch 服务会重试该任务。 请注意,此值专门用于控制重试的次数。 批处理服务将尝试任务一次,然后重试,直至达到此上限为止。 例如,如果最大重试计数为 3 次,则 Batch (一次初始尝试最多尝试 4 次,) 重试 3 次。 如果最大重试计数为 0,Batch 服务不会重试该任务。 如果最大重试计数为 -1,Batch 服务将无限制地重试任务。

Returns:

maxTaskRetryCount 值

resourceFiles

public List resourceFiles()

获取 resourceFiles 值。

Returns:

resourceFiles 值

userIdentity

public UserIdentity userIdentity()

如果省略,则获取 ,则任务以任务唯一的非管理用户身份运行。

Returns:

userIdentity 值

waitForSuccess

public Boolean waitForSuccess()

如果为 true 且计算节点上的启动任务失败,Batch 服务会将启动任务重试到其最大重试次数 (maxTaskRetryCount) 。 如果所有重试后任务仍未成功完成,Batch 服务会将计算节点标记为不可用,并且不会为其计划任务。 可以通过节点状态和计划错误详细信息来检测此情况。 如果为 false,则 Batch 服务不会等待启动任务完成。 在这种情况下,当启动任务仍在运行时,其他任务可以在计算节点上开始执行;即使启动任务失败,也将继续在节点上安排新任务。 默认值为 true。

Returns:

waitForSuccess 值

withCommandLine

public StartTask withCommandLine(String commandLine)

设置命令行不会在 shell 下运行,因此无法利用 shell 功能,例如环境变量扩展。 如果要利用此类功能,则应在命令行中调用 shell,例如在 Windows 中使用“cmd /c MyCommand”或在 Linux 中使用“/bin/sh -c MyCommand”。 如果指定了 startTask 的任何其他属性,则为必需。

Parameters:

commandLine - 要设置的 commandLine 值

Returns:

StartTask 对象本身。

withContainerSettings

public StartTask withContainerSettings(TaskContainerSettings containerSettings)

如果指定此设置,则以递归方式AZ_BATCH_NODE_ROOT_DIR (节点上Azure Batch目录的根目录) 映射到容器中,所有任务环境变量都映射到容器中,并在容器中执行任务命令行。

Parameters:

containerSettings - 要设置的 containerSettings 值

Returns:

StartTask 对象本身。

withEnvironmentSettings

public StartTask withEnvironmentSettings(List environmentSettings)

设置 environmentSettings 值。

Parameters:

environmentSettings - 要设置的 environmentSettings 值

Returns:

StartTask 对象本身。

withMaxTaskRetryCount

public StartTask withMaxTaskRetryCount(Integer maxTaskRetryCount)

设置 Batch 服务在任务的退出代码为非零时重试任务。 请注意,此值专门用于控制重试的次数。 批处理服务将尝试任务一次,然后重试,直至达到此上限为止。 例如,如果最大重试计数为 3 次,则 Batch (一次初始尝试最多尝试 4 次,) 重试 3 次。 如果最大重试计数为 0,Batch 服务不会重试该任务。 如果最大重试计数为 -1,Batch 服务将无限制地重试任务。

Parameters:

maxTaskRetryCount - 要设置的 maxTaskRetryCount 值

Returns:

StartTask 对象本身。

withResourceFiles

public StartTask withResourceFiles(List resourceFiles)

设置 resourceFiles 值。

Parameters:

resourceFiles - 要设置的 resourceFiles 值

Returns:

StartTask 对象本身。

withUserIdentity

public StartTask withUserIdentity(UserIdentity userIdentity)

如果省略,则设置任务作为任务唯一的非管理用户运行。

Parameters:

userIdentity - 要设置的 userIdentity 值

Returns:

StartTask 对象本身。

withWaitForSuccess

public StartTask withWaitForSuccess(Boolean waitForSuccess)

如果计算节点上的启动任务失败,则设置为 true,Batch 服务会将启动任务重试到其最大重试次数 (maxTaskRetryCount) 。 如果所有重试后任务仍未成功完成,Batch 服务会将计算节点标记为不可用,并且不会为其计划任务。 可以通过节点状态和计划错误详细信息来检测此情况。 如果为 false,则 Batch 服务不会等待启动任务完成。 在这种情况下,当启动任务仍在运行时,其他任务可以在计算节点上开始执行;即使启动任务失败,也将继续在节点上安排新任务。 默认值为 true。

Parameters:

waitForSuccess - 要设置的 waitForSuccess 值

Returns:

StartTask 对象本身。

适用于