ICommandScheduler

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)

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

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, ITestDevice device, String[] args)

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

abstract long 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)

将客户端设置为报告功能区数据

default void setMaxPollTime(long polling)
default void setPrintSchedulingWarning(boolean print)
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。

公共方法

addCommand

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

向调度程序添加命令。

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

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

参数
args String:配置实参。

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

抛出
ConfigurationException 如果无法解析命令

addCommandFile

public abstract void addCommandFile (String cmdFile, 
                 extraArgs)

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

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

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

抛出
ConfigurationException 如果无法解析命令文件

另见:

await

public abstract void await ()

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

displayCommandQueue

public abstract void displayCommandQueue (PrintWriter printWriter)

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

displayCommandsInfo

public abstract void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

输出当前命令的列表。

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

regex String:命令应匹配的正则表达式,以便打印命令。如果为 null,则打印所有命令。

displayInvocationsInfo

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,则转储所有命令。

execCommand

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 如果没有可用的设备

execCommand

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

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

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

args String:命令实参

返回
long 已安排命令的调用 ID。

抛出
ConfigurationException 如果命令无效
NoDeviceException 如果没有可用的设备

execCommand

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

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

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

device ITestDevice:要使用的 ITestDevice

args String:命令实参

返回
long 已安排命令的调用 ID。

抛出
ConfigurationException 如果命令无效

execCommand

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

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

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

devices :要使用的 ERROR(/List)

args String:命令实参

返回
long 已安排命令的调用 ID。

抛出
ConfigurationException 如果命令无效

getCommandFileWatcher

public abstract CommandFileWatcher getCommandFileWatcher ()

获取相应调度程序的 CommandFileWatcher

返回
CommandFileWatcher

getExecutingCommandCount

public abstract int getExecutingCommandCount ()

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

返回
int

getInvocationInfo

public abstract String getInvocationInfo (int invocationId)

通过指定调用 ID 返回调用的相关信息。

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

返回
String 包含有关调用的信息的 String

getLastInvocationExitCode

public abstract CommandRunner.ExitCode getLastInvocationExitCode ()

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

返回
CommandRunner.ExitCode

getLastInvocationThrowable

public abstract Throwable getLastInvocationThrowable ()

返回上次运行的调用的 Throwable。 如果没有可抛出的对象,则返回 null。

返回
Throwable

getReadyCommandCount

public abstract int getReadyCommandCount ()

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

返回
int

isDeviceInInvocationThread

public abstract boolean isDeviceInInvocationThread (ITestDevice device)

如果设备正被有效的调用线程使用,则返回 true。

参数
device ITestDevice

返回
boolean

join

public abstract void join ()

等待调度程序完成。

另见:

join

public abstract void join (long millis)

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

参数
millis long

另见:

removeAllCommands

public abstract void removeAllCommands ()

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

setClearcutClient

public abstract void setClearcutClient (ClearcutClient client)

将客户端设置为报告安全带数据

参数
client ClearcutClient

setMaxPollTime

public void setMaxPollTime (long polling)

参数
polling long

setPrintSchedulingWarning

public void setPrintSchedulingWarning (boolean print)

参数
print boolean

shouldShutdownOnCmdfileError

public abstract boolean shouldShutdownOnCmdfileError ()

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

返回
boolean

关停

public void shutdown ()

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

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

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

关停

public abstract void shutdown (boolean notifyStop)

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

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

shutdownHard

public abstract void shutdownHard (boolean killAdb)

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

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

参数
killAdb boolean

shutdownHard

public abstract void shutdownHard ()

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

shutdownOnEmpty

public abstract void shutdownOnEmpty ()

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

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

start

public abstract void start ()

启动 ICommandScheduler

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

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

stopInvocation

public abstract boolean stopInvocation (int invocationId, 
                String cause)

通过指定正在运行的调用的 ID 来停止该调用。

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

cause String:停止调用的原因。

返回
boolean 如果调用已停止,则为 true;否则为 false

抛出
UnsupportedOperationException 如果实现不支持此功能

stopInvocation

public boolean stopInvocation (int invocationId)

通过指定正在运行的调用的 ID 来停止该调用。

参数
invocationId int

返回
boolean 如果调用已停止,则为 true;否则为 false

抛出
UnsupportedOperationException 如果实现不支持此功能

stopInvocation

public abstract boolean stopInvocation (ITestInvocation invocation)

停止正在运行的调用。

参数
invocation ITestInvocation

返回
boolean 如果调用已停止,则为 true;否则为 false

抛出
UnsupportedOperationException 如果实现不支持此功能

stopScheduling

public void stopScheduling ()

停止调度和接受新测试,但不停止 Tradefed。此标志旨在实现两步关停,即先排空所有正在运行的测试,然后终止 Tradefed 进程。