CommandScheduler
public
class
CommandScheduler
extends Object
implements
ICommandScheduler
java.lang.Object 中 | |
↳ | com.android.tradefed.command.CommandScheduler |
在所有可用设备上运行 TradeFederation 命令的调度器。
将尝试根据命令的总执行次数来确定要运行的命令的优先级 。例如不频繁或快速运行的命令将优先于长时间运行的命令。
会在后台永久运行,直到关机。
摘要
嵌套类 | |
---|---|
enum |
CommandScheduler.HostState
主机的不同状态的枚举 |
公共构造函数 | |
---|---|
CommandScheduler()
创建 |
公共方法 | |
---|---|
boolean
|
addCommand(String[] args)
向调度器添加命令。 |
void
|
addCommandFile(String cmdFilePath,
将给定文件中的所有命令添加到调度器 |
void
|
await()
等待调度器开始运行,包括等待从旧 TF 的切换完成 (如果适用)。 |
static
TradefedDelegator
|
checkDelegation(String[] args)
根据命令行创建一个委托程序,以查看我们是否需要将该运行委托给他人。 |
void
|
completeHandover()
通知命令调度程序,发起的切换序列已全部完成,并且 应在默认端口上重新初始化其远程管理器。 |
static
|
createReleaseMap(IInvocationContext context, Throwable e)
创建设备状态映射,以便适当地发布设备。 |
ISandbox
|
createSandbox()
创建调用将用于运行的 |
void
|
displayCommandQueue(PrintWriter printWriter)
输出有关命令执行队列状态的详细调试信息。 |
void
|
displayCommandsInfo(PrintWriter printWriter, String regex)
输出当前命令的列表。 |
void
|
displayInvocationsInfo(PrintWriter printWriter)
显示当前调用的列表。 |
void
|
dumpCommandsXml(PrintWriter printWriter, String regex)
转储命令的展开后 xml 文件,其中包含
为所有当前命令指定了 |
void
|
execCommand(ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)
在已分配的设备上直接执行命令。 |
void
|
execCommand(IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)
直接分配设备并执行命令,无需将其添加到命令队列
使用现有的 |
void
|
execCommand(ICommandScheduler.IScheduledInvocationListener listener, String[] args)
直接分配设备并执行命令,无需将其添加到命令队列。 |
CommandFileWatcher
|
getCommandFileWatcher()
获取此调度器的相应 |
int
|
getExecutingCommandCount()
返回处于执行状态的命令数量。 |
CommandScheduler.HostState
|
getHostState()
|
String
|
getInvocationInfo(int invocationId)
返回指定调用 ID 的调用相关信息。 |
CommandRunner.ExitCode
|
getLastInvocationExitCode()
返回上次运行的调用的错误代码。 |
Throwable
|
getLastInvocationThrowable()
返回上次运行的调用中的 |
int
|
getReadyCommandCount()
返回队列中处于就绪状态的命令数量。 |
long
|
getShutdownTimeout()
|
void
|
handoverInitiationComplete()
通知命令调度程序,其初始切换交换正在使用的设备和命令 就可以开始安排操作了 |
boolean
|
handoverShutdown(int handoverPort)
启动 |
void
|
notifyFileChanged(File cmdFile,
|
void
|
removeAllCommands()
从调度器中移除所有命令 |
void
|
run()
此线程的主执行块。 |
void
|
setClearcutClient(ClearcutClient client)
将客户端设置为报告自动化测试框架数据 |
boolean
|
shouldShutdownOnCmdfileError()
如果由于命令错误而需要关闭调度器,则返回 true |
void
|
shutdown()
尝试正常关闭命令调度器。 |
void
|
shutdownHard(boolean killAdb)
尝试强制关闭命令调度程序。 |
void
|
shutdownHard()
尝试强制关闭命令调度程序。 |
void
|
shutdownOnEmpty()
与 |
void
|
start()
启动调度器,包括日志记录设置、 |
boolean
|
stopInvocation(ITestInvocation invocation)
停止正在运行的调用。 |
boolean
|
stopInvocation(int invocationId, String cause)
通过指定其 ID 来停止正在运行的调用。 |
受保护的方法 | |
---|---|
void
|
cleanUp()
在我们退出之前,关闭日志并进行任何其他必要的清理。 |
IConfiguration
|
createConfiguration(String[] args)
|
IInvocationContext
|
createInvocationContext()
|
IConfigurationFactory
|
getConfigFactory()
用于获取对 |
IDeviceManager
|
getDeviceManager()
用于获取对 |
TradefedFeatureServer
|
getFeatureServer()
|
IHostOptions
|
getHostOptions()
|
IKeyStoreClient
|
getKeyStoreClient()
使用 |
void
|
initLogging()
初始化 ddmlib 日志。 |
boolean
|
isShutdown()
|
boolean
|
isShuttingDown()
|
void
|
processReadyCommands(IDeviceManager manager)
|
void
|
waitForAllInvocationThreads()
等待所有调用线程完成。 |
公共构造函数
公共方法
addCommand
public boolean addCommand (String[] args)
向调度器添加命令。
命令实质上是要运行的配置及其相关参数的实例。
如果为“--help”参数是以下部分的帮助文本: 配置将输出到 stdout。否则,系统会将配置添加到队列中 运行。
参数 | |
---|---|
args |
String :配置参数。 |
返回 | |
---|---|
boolean |
如果命令已成功添加,则为 true |
抛出 | |
---|---|
ConfigurationException |
addCommandFile
public void addCommandFile (String cmdFilePath,extraArgs)
将给定文件中的所有命令添加到调度器
参数 | |
---|---|
cmdFilePath |
String :命令文件的文件系统路径 |
extraArgs |
:要附加到解析的每个命令的 ERROR(/List) (包含 String 个参数)
来自文件。可以为空,但不得为 null。 |
抛出 | |
---|---|
ConfigurationException |
等待
public void await ()
等待调度器开始运行,包括等待从旧 TF 的切换完成 (如果适用)。
checkDelegation
public static TradefedDelegator checkDelegation (String[] args)
根据命令行创建一个委托程序,以查看我们是否需要将该运行委托给他人。
参数 | |
---|---|
args |
String |
返回 | |
---|---|
TradefedDelegator |
抛出 | |
---|---|
ConfigurationException |
完整交接
public void completeHandover ()
通知命令调度程序,发起的切换序列已全部完成,并且 应在默认端口上重新初始化其远程管理器。
createReleaseMap
public staticcreateReleaseMap (IInvocationContext context, Throwable e)
创建设备状态映射,以便适当地发布设备。
参数 | |
---|---|
context |
IInvocationContext |
e |
Throwable |
返回 | |
---|---|
|
displayCommandQueue
public void displayCommandQueue (PrintWriter printWriter)
输出有关命令执行队列状态的详细调试信息。
displayCommandsInfo
public void displayCommandsInfo (PrintWriter printWriter, String regex)
输出当前命令的列表。
参数 | |
---|---|
printWriter |
PrintWriter :要输出到的 ERROR(/PrintWriter) 。 |
regex |
String :要与命令匹配的正则表达式,
。如果为 null,将输出所有命令。
|
displayInvocationsInfo
public void displayInvocationsInfo (PrintWriter printWriter)
显示当前调用的列表。
参数 | |
---|---|
printWriter |
PrintWriter :要输出到的 ERROR(/PrintWriter) 。
|
dumpCommandsXml
public void dumpCommandsXml (PrintWriter printWriter, String regex)
转储命令的展开后 xml 文件,其中包含
为所有当前命令指定了 Option
值。
参数 | |
---|---|
printWriter |
PrintWriter :要向其中输出状态的 ERROR(/PrintWriter) 。 |
regex |
String :为了让
xml 文件。如果为 null,将转储所有命令。
|
execCommand
public void execCommand (ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)
在已分配的设备上直接执行命令。
参数 | |
---|---|
listener |
ICommandScheduler.IScheduledInvocationListener :要通知的 ICommandScheduler.IScheduledInvocationListener |
device |
ITestDevice :要使用的 ITestDevice |
args |
String :命令参数 |
抛出 | |
---|---|
ConfigurationException |
execCommand
public void execCommand (IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)
直接分配设备并执行命令,无需将其添加到命令队列
使用现有的 IInvocationContext
。
参数 | |
---|---|
context |
IInvocationContext :现有的 IInvocationContext 。 |
listener |
ICommandScheduler.IScheduledInvocationListener :要通知的 ICommandScheduler.IScheduledInvocationListener |
args |
String :命令参数 |
抛出 | |
---|---|
ConfigurationException |
|
NoDeviceException |
execCommand
public void execCommand (ICommandScheduler.IScheduledInvocationListener listener, String[] args)
直接分配设备并执行命令,无需将其添加到命令队列。
参数 | |
---|---|
listener |
ICommandScheduler.IScheduledInvocationListener :要通知的 ICommandScheduler.IScheduledInvocationListener |
args |
String :命令参数 |
抛出 | |
---|---|
ConfigurationException |
|
NoDeviceException |
getCommandFileWatcher
public CommandFileWatcher getCommandFileWatcher ()
获取此调度器的相应 CommandFileWatcher
返回 | |
---|---|
CommandFileWatcher |
getExecutingCommandCount
public int getExecutingCommandCount ()
返回处于执行状态的命令数量。
返回 | |
---|---|
int |
getInvocationInfo
public String getInvocationInfo (int invocationId)
返回指定调用 ID 的调用相关信息。
参数 | |
---|---|
invocationId |
int :调用的跟踪 ID。 |
返回 | |
---|---|
String |
包含调用相关信息的 String 。
|
getLastInvocationExitCode
public CommandRunner.ExitCode getLastInvocationExitCode ()
返回上次运行的调用的错误代码。 如果还没有运行任何调用,则返回 0(无错误)。
返回 | |
---|---|
CommandRunner.ExitCode |
getLastInvocationThrowable
public Throwable getLastInvocationThrowable ()
返回上次运行的调用中的 Throwable
。
如果没有可抛出对象,则返回 null。
返回 | |
---|---|
Throwable |
getReadyCommandCount
public int getReadyCommandCount ()
返回队列中处于就绪状态的命令数量。
返回 | |
---|---|
int |
getShutdownTimeout
public long getShutdownTimeout ()
返回 | |
---|---|
long |
移交初始化完成
public void handoverInitiationComplete ()
通知命令调度程序,其初始切换交换正在使用的设备和命令 就可以开始安排操作了
关闭切换
public boolean handoverShutdown (int handoverPort)
启动 shutdown()
并切换到同一主机上的另一个 tradefed 进程。
调度器将通知监听已释放设备的端口的远程 tradefed 进程 。
参数 | |
---|---|
handoverPort |
int |
返回 | |
---|---|
boolean |
如果切换启动成功,则为 true ;false
否则
|
通知文件已更改
public void notifyFileChanged (File cmdFile,extraArgs)
参数 | |
---|---|
cmdFile |
File |
extraArgs |
|
removeAllCommands
public void removeAllCommands ()
从调度器中移除所有命令
得分
public void run ()
此线程的主执行块。
setClearcutClient
public void setClearcutClient (ClearcutClient client)
将客户端设置为报告自动化测试框架数据
参数 | |
---|---|
client |
ClearcutClient |
shouldShutdownOnCmdfileError
public boolean shouldShutdownOnCmdfileError ()
如果由于命令错误而需要关闭调度器,则返回 true
返回 | |
---|---|
boolean |
关停
public void shutdown ()
尝试正常关闭命令调度器。
清除等待测试的命令,并请求所有正在进行的调用 自动关停
调用关停后,调度器主循环将等待所有正在进行的调用 完成后再完全退出。
关停硬
public void shutdownHard (boolean killAdb)
尝试强制关闭命令调度程序。
与 shutdown()
类似,但也可以选择性地终止 adb 连接,
试图“启发”更快地完成。
参数 | |
---|---|
killAdb |
boolean |
关停硬
public void shutdownHard ()
尝试强制关闭命令调度程序。与 closeHard(true) 相同。
关闭在空白处
public void shutdownOnEmpty ()
与 shutdown()
类似,但会等待所有命令都执行完毕
然后下车。
请注意,如果任何命令处于循环模式,则调度器将永远不会退出。
stopInvocation
public boolean stopInvocation (ITestInvocation invocation)
停止正在运行的调用。
参数 | |
---|---|
invocation |
ITestInvocation |
返回 | |
---|---|
boolean |
如果调用已停止,则为 true,否则为 false |
stopInvocation
public boolean stopInvocation (int invocationId, String cause)
通过指定其 ID 来停止正在运行的调用。
参数 | |
---|---|
invocationId |
int :调用的跟踪 ID。 |
cause |
String :停止调用的原因。 |
返回 | |
---|---|
boolean |
如果调用已停止,则为 true,否则为 false |
受保护的方法
清理
protected void cleanUp ()
在我们退出之前,关闭日志并进行任何其他必要的清理。
公开,以便单元测试可以模拟。
createConfiguration
protected IConfiguration createConfiguration (String[] args)
参数 | |
---|---|
args |
String |
返回 | |
---|---|
IConfiguration |
抛出 | |
---|---|
ConfigurationException |
createInvocationContext
protected IInvocationContext createInvocationContext ()
返回 | |
---|---|
IInvocationContext |
getConfigFactory
protected IConfigurationFactory getConfigFactory ()
用于获取对 IConfigurationFactory
的引用的工厂方法
返回 | |
---|---|
IConfigurationFactory |
要使用的 IConfigurationFactory
|
getDeviceManager
protected IDeviceManager getDeviceManager ()
用于获取对 IDeviceManager
的引用的工厂方法
返回 | |
---|---|
IDeviceManager |
要使用的 IDeviceManager
|
getHostOptions
protected IHostOptions getHostOptions ()
返回 | |
---|---|
IHostOptions |
getKeyStoreClient
protected IKeyStoreClient getKeyStoreClient ()
使用 IKeyStoreFactory
提取 IKeyStoreClient
在 IGlobalConfiguration
中声明,如果未定义,则返回 null。
返回 | |
---|---|
IKeyStoreClient |
IKeyStoreClient |
初始化日志记录
protected void initLogging ()
初始化 ddmlib 日志。
公开,以便单元测试可以模拟。
isShutdown
protected boolean isShutdown ()
返回 | |
---|---|
boolean |
正在关闭
protected boolean isShuttingDown ()
返回 | |
---|---|
boolean |
processReadyCommands
protected void processReadyCommands (IDeviceManager manager)
参数 | |
---|---|
manager |
IDeviceManager |
waitForAllInvocationThreads
protected void waitForAllInvocationThreads ()
等待所有调用线程完成。