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) 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 文件,其中包含為所有當前命令指定的所有 |
abstract long | execCommand ( IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args) 直接分配設備並執行命令,而不使用已存在的 |
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 () 為此調度程序獲取適當的 |
abstract int | getExecutingCommandCount () 返回處於執行狀態的命令數。 |
abstract String | getInvocationInfo (int invocationId) 返回有關指定調用 ID 的調用的信息。 |
abstract CommandRunner.ExitCode | getLastInvocationExitCode () 返回最後一次運行的調用的錯誤代碼。 |
abstract Throwable | getLastInvocationThrowable () 從最後一次運行的調用中返回 |
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 () 類似於 |
abstract void | start () |
abstract boolean | stopInvocation (int invocationId, String cause) 通過指定它的 id 來停止正在運行的調用。 |
default boolean | stopInvocation (int invocationId) 通過指定它的 id 來停止正在運行的調用。 |
abstract boolean | stopInvocation ( ITestInvocation invocation) 停止正在運行的調用。 |
公共方法
添加命令
public abstract Pair<Boolean, Integer> addCommand (String[] args)
向調度程序添加命令。
命令本質上是要運行的配置及其相關參數的實例。
如果指定了“--help”參數,配置的幫助文本將輸出到標準輸出。否則,配置將被添加到隊列中以運行。
參數 | |
---|---|
args | String :配置參數。 |
退貨 | |
---|---|
Pair <Boolean, Integer> | 一對值,如果成功添加命令,第一個值為布爾值true 。第二個值是已知的命令跟踪器id(非負值)如果命令添加成功,則為所有設備添加命令時返回0,否則返回-1。 |
投擲 | |
---|---|
ConfigurationException | 如果無法解析命令 |
添加命令文件
public abstract void addCommandFile (String cmdFile,extraArgs)
將給定文件中的所有命令添加到調度程序
參數 | |
---|---|
cmdFile | String : 命令文件的文件系統路徑 |
extraArgs | ERROR(/List) 的ERROR(/String) 參數附加到從文件解析的每個命令。可以為空但不應為空。 |
投擲 | |
---|---|
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 文件,命令應與其匹配的正則表達式。如果為空,則將轉儲所有命令。 |
執行命令
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 |
devices | ERROR(/List ) ERROR(/List ) 使用 |
args | String :命令參數 |
退貨 | |
---|---|
long | 計劃命令的調用 ID。 |
投擲 | |
---|---|
ConfigurationException | 如果命令無效 |
getCommandFileWatcher
public abstract CommandFileWatcher getCommandFileWatcher ()
為此調度程序獲取適當的CommandFileWatcher
退貨 | |
---|---|
CommandFileWatcher |
getExecutingCommandCount
public abstract int getExecutingCommandCount ()
返回處於執行狀態的命令數。
退貨 | |
---|---|
int |
獲取調用信息
public abstract String getInvocationInfo (int invocationId)
返回有關指定調用 ID 的調用的信息。
參數 | |
---|---|
invocationId | int :調用的跟踪 ID。 |
退貨 | |
---|---|
String | 包含有關調用的信息的ERROR(/String) 。 |
getLastInvocationExitCode
public abstract CommandRunner.ExitCode getLastInvocationExitCode ()
返回最後一次運行的調用的錯誤代碼。如果尚未運行任何調用,則返回 0(無錯誤)。
退貨 | |
---|---|
CommandRunner.ExitCode |
getLastInvocationThrowable
public abstract Throwable getLastInvocationThrowable ()
從最後一次運行的調用中返回ERROR(/Throwable)
。如果沒有可用的 throwable,則返回 null。
退貨 | |
---|---|
Throwable |
getReadyCommandCount
public abstract int getReadyCommandCount ()
返回隊列中處於就緒狀態的命令數。
退貨 | |
---|---|
int |
isDeviceInInvocationThread
public abstract boolean isDeviceInInvocationThread (ITestDevice device)
如果設備由活動調用線程使用,則返回 true。
參數 | |
---|---|
device | ITestDevice |
退貨 | |
---|---|
boolean |
加入
public abstract void join (long millis)
在指定的持續時間(以毫秒為單位)後等待調度程序完成或超時。
參數 | |
---|---|
millis | long |
也可以看看:
刪除所有命令
public abstract void removeAllCommands ()
從調度程序中刪除所有命令
設置清除客戶端
public abstract void setClearcutClient (ClearcutClient client)
設置客戶端上報線束數據
參數 | |
---|---|
client | ClearcutClient |
shouldShutdownOnCmdfileError
public abstract boolean shouldShutdownOnCmdfileError ()
如果我們需要在命令錯誤時關閉調度程序,則返回 true
退貨 | |
---|---|
boolean |
關閉
public void shutdown ()
嘗試正常關閉命令調度程序。
清除等待測試的命令,並請求所有正在進行的調用正常關閉。
調用 shutdown 後,調度程序主循環將等待所有正在進行的調用完成,然後才完全退出。
關閉
public abstract void shutdown (boolean notifyStop)
嘗試正常關閉命令調度程序。
參數 | |
---|---|
notifyStop | boolean :如果為真,則通知調用 TF 關閉。 |
硬關機
public abstract void shutdownHard (boolean killAdb)
嘗試強制關閉命令調度程序。
類似於shutdown()
,但也可以選擇終止 adb 連接,以試圖“激發”正在進行的調用以更快地完成。
參數 | |
---|---|
killAdb | boolean |
硬關機
public abstract void shutdownHard ()
嘗試強制關閉命令調度程序。與 shutdownHard(true) 相同。
關機時空
public abstract void shutdownOnEmpty ()
類似於shutdown()
,但會在退出前等待所有命令執行完畢。
停止調用
public abstract boolean stopInvocation (int invocationId, String cause)
通過指定它的 id 來停止正在運行的調用。
參數 | |
---|---|
invocationId | int :調用的跟踪 ID。 |
cause | String :停止調用的原因。 |
退貨 | |
---|---|
boolean | 如果調用已停止,則為 true,否則為 false |
投擲 | |
---|---|
| 如果實現不支持這個 |
停止調用
public boolean stopInvocation (int invocationId)
通過指定它的 id 來停止正在運行的調用。
參數 | |
---|---|
invocationId | int |
退貨 | |
---|---|
boolean | 如果調用已停止,則為 true,否則為 false |
投擲 | |
---|---|
| 如果實現不支持這個 |
停止調用
public abstract boolean stopInvocation (ITestInvocation invocation)
停止正在運行的調用。
參數 | |
---|---|
invocation | ITestInvocation |
退貨 | |
---|---|
boolean | 如果調用已停止,則為 true,否則為 false |
投擲 | |
---|---|
| 如果實現不支持這個 |
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2023-03-30 (世界標準時間)。