I命令调度器

public interface ICommandScheduler

com.android.tradefed.command.ICommandScheduler


用于运行 TradeFederation 命令的调度程序。

概括

嵌套类

interface ICommandScheduler.IScheduledInvocationListener

调用完成时调用事件的侦听器。

公共方法

abstract Pair <Boolean, Integer> addCommand (String[] args)

向调度程序添加命令。

abstract void addCommandFile (String cmdFile, extraArgs) addCommandFile (String cmdFile, extraArgs)

将给定文件中的所有命令添加到调度程序

abstract void await ()

等待调度程序开始运行,包括等待旧 TF 的切换完成(如果适用)。

abstract void displayCommandQueue (PrintWriter printWriter)

输出有关命令执行队列状态的详细调试信息。

abstract void displayCommandsInfo (PrintWriter printWriter, String regex)

输出当前命令的列表。

abstract void displayInvocationsInfo (PrintWriter printWriter)

显示当前调用的列表。

abstract void dumpCommandsXml (PrintWriter printWriter, String regex)

转储该命令的扩展 xml 文件,其中包含为所有当前命令指定的所有Option值。

abstract long execCommand ( IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)

直接分配设备并执行命令,而不使用现有的IInvocationContext将其添加到命令队列。

abstract long execCommand ( ICommandScheduler.IScheduledInvocationListener listener, String[] args)

直接分配设备并执行命令,而不将其添加到命令队列。

abstract long execCommand ( ICommandScheduler.IScheduledInvocationListener listener, devices, String[] args) execCommand ( ICommandScheduler.IScheduledInvocationListener listener, devices, String[] args)

直接在已分配的设备上执行命令。

abstract CommandFileWatcher getCommandFileWatcher ()

为该调度程序获取适当的 CommandFileWatcher

abstract int getExecutingCommandCount ()

返回处于执行状态的命令数。

abstract String getInvocationInfo (int invocationId)

返回有关指定调用 ID 的调用的信息。

abstract CommandRunner.ExitCode getLastInvocationExitCode ()

返回上次运行的调用的错误代码。

abstract Throwable getLastInvocationThrowable ()

返回上次运行的调用中的Throwable

abstract int getReadyCommandCount ()

返回队列中处于就绪状态的命令数。

abstract boolean isDeviceInInvocationThread ( ITestDevice device)

如果设备由活动调用线程使用,则返回 true。

abstract void join ()

等待调度程序完成。

abstract void join (long millis)

等待调度程序完成或在指定的持续时间(以毫秒为单位)后超时。

abstract void removeAllCommands ()

从调度程序中删除所有命令

abstract void setClearcutClient (ClearcutClient client)

设置客户端报告线束数据

abstract boolean shouldShutdownOnCmdfileError ()

如果我们需要在命令错误时关闭调度程序,则返回 true

default void shutdown ()

尝试正常关闭命令调度程序。

abstract void shutdown (boolean notifyStop)

尝试正常关闭命令调度程序。

abstract void shutdownHard (boolean killAdb)

尝试强制关闭命令调度程序。

abstract void shutdownHard ()

尝试强制关闭命令调度程序。

abstract void shutdownOnEmpty ()

shutdown()类似,但会等待所有命令执行完毕后再退出。

abstract void start ()

启动ICommandScheduler

abstract boolean stopInvocation (int invocationId, String cause)

通过指定其 id 来停止正在运行的调用。

default boolean stopInvocation (int invocationId)

通过指定其 id 来停止正在运行的调用。

abstract boolean stopInvocation ( ITestInvocation invocation)

停止正在运行的调用。

default void stopScheduling ()

停止安排和接受新测试,但不停止 Tradefed。

公共方法

添加命令

public abstract Pair<Boolean, Integer> addCommand (String[] args)

向调度程序添加命令。

命令本质上是要运行的配置及其关联参数的实例。

如果指定了“--help”参数,则配置的帮助文本将输出到标准输出。否则,配置将被添加到队列中运行。

参数
args String :配置参数。

退货
Pair <Boolean, Integer>一对值,如果命令添加成功,第一个值是布尔值true 。第二个值是已知的命令跟踪器 ID(非负值),如果命令添加成功,则为所有设备添加命令时返回 0,否则返回 -1。

投掷
ConfigurationException if 命令无法解析

添加命令文件

public abstract void addCommandFile (String cmdFile, 
                 extraArgs)

将给定文件中的所有命令添加到调度程序

参数
cmdFile String : 命令文件的文件系统路径

extraArgs :附加到从文件解析的每个命令的String参数的ERROR(/List) 。可以为空,但不应为空。

投掷
ConfigurationException如果无法解析命令文件

也可以看看:

等待

public abstract void await ()

等待调度程序开始运行,包括等待旧 TF 的切换完成(如果适用)。

显示命令队列

public abstract void displayCommandQueue (PrintWriter printWriter)

输出有关命令执行队列状态的详细调试信息。

显示命令信息

public abstract void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

输出当前命令的列表。

参数
printWriter PrintWriter :要输出到的ERROR(/PrintWriter)

regex String :命令应与其匹配才能打印的正则表达式。如果为空,则将打印所有命令。

显示调用信息

public abstract void displayInvocationsInfo (PrintWriter printWriter)

显示当前调用的列表。

参数
printWriter PrintWriter :要输出到的ERROR(/PrintWriter)

dumpCommandsXml

public abstract void dumpCommandsXml (PrintWriter printWriter, 
                String regex)

转储该命令的扩展 xml 文件,其中包含为所有当前命令指定的所有Option值。

参数
printWriter PrintWriter :将状态输出到的ERROR(/PrintWriter)

regex String :命令应与其匹配的正则表达式,以便转储 xml 文件。如果为 null,则所有命令都将被转储。

执行命令

public abstract long execCommand (IInvocationContext context, 
                ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

直接分配设备并执行命令,而不使用现有的IInvocationContext将其添加到命令队列。

参数
context IInvocationContext :现有的IInvocationContext

listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

args String : 命令参数

退货
long

投掷
ConfigurationException如果命令无效
NoDeviceException如果没有设备可以使用

执行命令

public abstract long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                String[] args)

直接分配设备并执行命令,而不将其添加到命令队列。

参数
listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

args String : 命令参数

退货
long计划命令的调用ID。

投掷
ConfigurationException如果命令无效
NoDeviceException如果没有设备可以使用

执行命令

public abstract long execCommand (ICommandScheduler.IScheduledInvocationListener listener, 
                 devices, 
                String[] args)

直接在已分配的设备上执行命令。

参数
listener ICommandScheduler.IScheduledInvocationListener :要通知的ICommandScheduler.IScheduledInvocationListener

devicesERROR(/List ) ERROR(/List )使用

args String : 命令参数

退货
long计划命令的调用ID。

投掷
ConfigurationException如果命令无效

获取命令文件观察者

public abstract CommandFileWatcher getCommandFileWatcher ()

为该调度程序获取适当的 CommandFileWatcher

退货
CommandFileWatcher

获取执行命令计数

public abstract int getExecutingCommandCount ()

返回处于执行状态的命令数。

退货
int

获取调用信息

public abstract String getInvocationInfo (int invocationId)

返回有关指定调用 ID 的调用的信息。

参数
invocationId int :调用的跟踪 ID。

退货
String包含有关调用的信息的String

获取最后调用退出代码

public abstract CommandRunner.ExitCode getLastInvocationExitCode ()

返回上次运行的调用的错误代码。如果尚未运行任何调用,则返回 0(无错误)。

退货
CommandRunner.ExitCode

获取最后一个调用Throwable

public abstract Throwable getLastInvocationThrowable ()

返回上次运行的调用中的Throwable 。如果没有可用的 throwable,则返回 null。

退货
Throwable

获取就绪命令计数

public abstract int getReadyCommandCount ()

返回队列中处于就绪状态的命令数。

退货
int

是设备调用线程

public abstract boolean isDeviceInInvocationThread (ITestDevice device)

如果设备由活动调用线程使用,则返回 true。

参数
device ITestDevice

退货
boolean

加入

public abstract void join ()

等待调度程序完成。

也可以看看:

加入

public abstract void join (long millis)

等待调度程序完成或在指定的持续时间(以毫秒为单位)后超时。

参数
millis long

也可以看看:

删除所有命令

public abstract void removeAllCommands ()

从调度程序中删除所有命令

设置ClearcutClient

public abstract void setClearcutClient (ClearcutClient client)

设置客户端报告线束数据

参数
client ClearcutClient

应该ShutdownOnCmdfileError

public abstract boolean shouldShutdownOnCmdfileError ()

如果我们需要在命令错误时关闭调度程序,则返回 true

退货
boolean

关闭

public void shutdown ()

尝试正常关闭命令调度程序。

清除等待测试的命令,并请求正常关闭所有正在进行的调用。

调用 shutdown 后,调度程序主循环将等待所有正在进行的调用完成,然后完全退出。

关闭

public abstract void shutdown (boolean notifyStop)

尝试正常关闭命令调度程序。

参数
notifyStop boolean :如果为 true,则通知调用 TF 关闭。

硬关机

public abstract void shutdownHard (boolean killAdb)

尝试强制关闭命令调度程序。

shutdown()类似,但也可以选择终止 adb 连接,以尝试“激发”正在进行的调用更快地完成。

参数
killAdb boolean

硬关机

public abstract void shutdownHard ()

尝试强制关闭命令调度程序。与 shutdownHard(true) 相同。

空时关闭

public abstract void shutdownOnEmpty ()

shutdown()类似,但会等待所有命令执行完毕后再退出。

请注意,如果任何命令处于循环模式,调度程序将永远不会退出。

开始

public abstract void start ()

启动ICommandScheduler

必须在调用其他方法之前调用。

将运行直到shutdown()被调用。请参阅Thread.start()

停止调用

public abstract boolean stopInvocation (int invocationId, 
                String cause)

通过指定其 id 来停止正在运行的调用。

参数
invocationId int :调用的跟踪 ID。

cause String :停止调用的原因。

退货
boolean如果调用停止则为 true,否则为 false

投掷
UnsupportedOperationException如果实现不支持这个

停止调用

public boolean stopInvocation (int invocationId)

通过指定其 id 来停止正在运行的调用。

参数
invocationId int

退货
boolean如果调用停止则为 true,否则为 false

投掷
UnsupportedOperationException如果实现不支持这个

停止调用

public abstract boolean stopInvocation (ITestInvocation invocation)

停止正在运行的调用。

参数
invocation ITestInvocation

退货
boolean如果调用停止则为 true,否则为 false

投掷
UnsupportedOperationException如果实现不支持这个

停止调度

public void stopScheduling ()

停止安排和接受新测试,但不停止 Tradefed。这是为了实现两步关闭,首先我们耗尽所有正在运行的测试,然后终止 Tradefed 进程。