CommandScheduler
public
class
CommandScheduler
extends Object
implements
ICommandScheduler
| java.lang.Object | |
| ↳ | com.android.tradefed.command.CommandScheduler |
使用可能なすべてのデバイスで TradeFederation コマンドを実行するスケジューラ。
実行時間の合計実行回数に基づいて、実行するコマンドの優先順位付けを試みます。たとえば、実行頻度が低いコマンドや実行時間が短いコマンドは、実行時間が長いコマンドよりも優先されます。
シャットダウンされるまでバックグラウンドで永続的に実行されます。
概要
パブリック コンストラクタ | |
|---|---|
CommandScheduler()
|
|
パブリック メソッド | |
|---|---|
Pair<Boolean, Integer>
|
addCommand(String[] args)
スケジューラにコマンドを追加します。 |
void
|
addCommandFile(String cmdFilePath,
指定されたファイルのすべてのコマンドをスケジューラに追加します。 |
void
|
await()
スケジューラが実行を開始するまで待機します。これには、該当する場合は古い TF からの引き継ぎが完了するまで待機することも含まれます。 |
static
TradefedDelegator
|
checkDelegation(String[] args)
コマンドラインに基づいて委任者を作成し、実行を委任する必要があるかどうかを確認します。 |
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)
現在のすべてのコマンドに指定されているすべての |
long
|
execCommand(ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)
すでに割り振られているデバイスでコマンドを直接実行します。 |
long
|
execCommand(ICommandScheduler.IScheduledInvocationListener listener,
すでに割り振られているデバイスでコマンドを直接実行します。 |
long
|
execCommand(IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, String[] args)
既存の |
long
|
execCommand(ICommandScheduler.IScheduledInvocationListener listener, String[] args)
デバイスを直接割り振り、コマンドキューに追加せずにコマンドを実行します。 |
CommandFileWatcher
|
getCommandFileWatcher()
このスケジューラに適した CommandFileWatcher を取得します。 |
int
|
getExecutingCommandCount()
実行状態の Command の数を返します。 |
CommandScheduler.HostState
|
getHostState()
|
String
|
getInvocationInfo(int invocationId)
呼び出し ID を指定して、呼び出しに関する情報を返します。 |
CommandRunner.ExitCode
|
getLastInvocationExitCode()
最後に実行された呼び出しのエラーコードを返します。 |
Throwable
|
getLastInvocationThrowable()
最後に実行された呼び出しの |
int
|
getReadyCommandCount()
キュー内の準備完了状態の Command の数を返します。 |
long
|
getShutdownTimeout()
|
boolean
|
isDeviceInInvocationThread(ITestDevice device)
デバイスがアクティブな呼び出しスレッドで使用されている場合は true を返します。 |
boolean
|
isShuttingDown()
|
void
|
notifyFileChanged(File cmdFile,
|
void
|
removeAllCommands()
スケジューラからすべてのコマンドを削除します。 |
void
|
run()
このスレッドのメイン実行ブロック。 |
void
|
setClearcutClient(ClearcutClient client)
ハーネスデータを報告するようにクライアントを設定する |
boolean
|
shouldShutdownOnCmdfileError()
コマンドエラーでスケジューラをシャットダウンする必要がある場合は true を返します。 |
void
|
shutdown(boolean notifyStop)
コマンド スケジューラを正常にシャットダウンしようとします。 |
void
|
shutdownHard(boolean killAdb)
コマンド スケジューラを強制的にシャットダウンしようとします。 |
void
|
shutdownHard()
コマンド スケジューラを強制的にシャットダウンしようとします。 |
void
|
shutdownOnEmpty()
|
void
|
start()
ロギングの設定、 |
boolean
|
stopInvocation(ITestInvocation invocation)
実行中の呼び出しを停止します。 |
boolean
|
stopInvocation(int invocationId, String cause)
実行中の呼び出しの ID を指定して停止します。 |
void
|
stopScheduling()
新しいテストのスケジュール設定と受信を停止しますが、Tradefed は停止しません。 |
パブリック コンストラクタ
パブリック メソッド
addCommand
public Pair<Boolean, Integer> addCommand (String[] args)
スケジューラにコマンドを追加します。
コマンドは基本的に、実行する構成とそれに関連付けられた引数のインスタンスです。
「--help」引数を指定すると、構成のヘルプテキストが stdout に出力されます。それ以外の場合は、構成ファイルがキューに追加され、実行されます。
| パラメータ | |
|---|---|
args |
String: 構成引数。 |
| 戻り値 | |
|---|---|
Pair<Boolean, Integer> |
値のペア。コマンドが正常に追加された場合、最初の値はブール値 true です。2 番目の値は、コマンドが正常に追加された場合は既知のコマンド トラッカー ID(正の値)、すべてのデバイスにコマンドが追加された場合は 0、それ以外の場合は -1 です。 |
| 例外 | |
|---|---|
ConfigurationException |
|
addCommandFile
public void addCommandFile (String cmdFilePath,
extraArgs) 指定されたファイルのすべてのコマンドをスケジューラに追加します。
| パラメータ | |
|---|---|
cmdFilePath |
String: コマンド ファイルのファイル システム パス |
extraArgs |
: ファイルから解析された各コマンドに追加する String 引数の ERROR(/List)。空にすることもできますが、null にすることはできません。 |
| 例外 | |
|---|---|
ConfigurationException |
|
await
public void await ()
スケジューラが実行を開始するまで待機します。これには、古い TF からの引き継ぎが完了するまで待機することも含まれます(該当する場合)。
checkDelegation
public static TradefedDelegator checkDelegation (String[] args)
コマンドラインに基づいて委任者を作成し、実行を委任する必要があるかどうかを確認します。
| パラメータ | |
|---|---|
args |
String |
| 戻り値 | |
|---|---|
TradefedDelegator |
|
| 例外 | |
|---|---|
|
com.android.tradefed.config.ConfigurationException |
ConfigurationException |
|
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)現在のすべてのコマンドに指定されているすべての Option 値を含む、コマンドの展開 XML ファイルをダンプします。
| パラメータ | |
|---|---|
printWriter |
PrintWriter: ステータスを出力する ERROR(/PrintWriter)。 |
regex |
String: XML ファイルをダンプするためにコマンドを照合する正規表現。null の場合、すべてのコマンドがダンプされます。 |
execCommand
public long execCommand (ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)
すでに割り当てられているデバイスでコマンドを直接実行します。
| パラメータ | |
|---|---|
listener |
ICommandScheduler.IScheduledInvocationListener: 通知する ICommandScheduler.IScheduledInvocationListener |
device |
ITestDevice: 使用する ITestDevice |
args |
String: コマンドの引数 |
| 戻り値 | |
|---|---|
long |
スケジュール設定されたコマンドの呼び出し ID。 |
| 例外 | |
|---|---|
ConfigurationException |
|
execCommand
public long execCommand (ICommandScheduler.IScheduledInvocationListener listener,reservedDevices, String[] args)
すでに割り振られているデバイスでコマンドを直接実行します。
| パラメータ | |
|---|---|
listener |
ICommandScheduler.IScheduledInvocationListener: 通知する ICommandScheduler.IScheduledInvocationListener |
reservedDevices |
: 使用する ERROR(/List |
args |
String: コマンドの引数 |
| 戻り値 | |
|---|---|
long |
スケジュール設定されたコマンドの呼び出し ID。 |
| 例外 | |
|---|---|
ConfigurationException |
|
execCommand
public 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 long execCommand (ICommandScheduler.IScheduledInvocationListener listener, String[] args)
デバイスを直接割り振り、コマンドキューに追加せずにコマンドを実行します。
| パラメータ | |
|---|---|
listener |
ICommandScheduler.IScheduledInvocationListener: 通知する ICommandScheduler.IScheduledInvocationListener |
args |
String: コマンドの引数 |
| 戻り値 | |
|---|---|
long |
スケジュール設定されたコマンドの呼び出し ID。 |
| 例外 | |
|---|---|
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 ()
キュー内の準備完了状態の Command の数を返します。
| 戻り値 | |
|---|---|
int |
|
getShutdownTimeout
public long getShutdownTimeout ()
| 戻り値 | |
|---|---|
long |
|
isDeviceInInvocationThread
public boolean isDeviceInInvocationThread (ITestDevice device)
デバイスがアクティブな呼び出しスレッドで使用されている場合は true を返します。
| パラメータ | |
|---|---|
device |
ITestDevice |
| 戻り値 | |
|---|---|
boolean |
|
isShuttingDown
public boolean isShuttingDown ()
| 戻り値 | |
|---|---|
boolean |
|
notifyFileChanged
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 (boolean notifyStop)
コマンド スケジューラを正常にシャットダウンしようとします。
| パラメータ | |
|---|---|
notifyStop |
boolean: true の場合、TF シャットダウンの呼び出しを通知します。 |
shutdownHard
public void shutdownHard (boolean killAdb)
コマンド スケジューラを強制的にシャットダウンしようとします。
shutdown() に似ていますが、進行中の呼び出しをより速く完了させるために、必要に応じて adb 接続も強制終了します。
| パラメータ | |
|---|---|
killAdb |
boolean |
shutdownHard
public void shutdownHard ()
コマンド スケジューラを強制的にシャットダウンしようとします。shutdownHard(true) と同じです。
shutdownOnEmpty
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 |
stopScheduling
public void stopScheduling ()
新しいテストのスケジュール設定と受信は停止されますが、Tradefed は停止されません。これは、まず実行中のすべてのテストをドレインしてから、Tradefed プロセスを終了する 2 段階のシャットダウンを可能にすることを目的としています。
保護されたメソッド
cleanUp
protected void cleanUp ()
終了前にログを閉じて、必要なクリーンアップを行います。
単体テストでモックできるように公開されています。
createConfiguration
protected IConfiguration createConfiguration (String[] args)
| パラメータ | |
|---|---|
args |
String |
| 戻り値 | |
|---|---|
IConfiguration |
|
| 例外 | |
|---|---|
ConfigurationException |
|
createInvocationContext
protected IInvocationContext createInvocationContext ()
| 戻り値 | |
|---|---|
IInvocationContext |
|
dryRunCommandReporting
protected void dryRunCommandReporting (ICommandScheduler.IScheduledInvocationListener handler, IConfiguration config)
指定されたコマンドがドライランかどうかを判断します。コマンドがドライランの場合は、検証します。構成に問題がある場合は、ConfigurationException がスローされます。
| パラメータ | |
|---|---|
handler |
ICommandScheduler.IScheduledInvocationListener: ドライラン検証のイベントを報告する ERROR(/InvocationEventHandler)。 |
config |
IConfiguration |
| 戻り値 | |
|---|---|
void |
コマンドがドライランの場合は true、それ以外の場合は false。 |
| 例外 | |
|---|---|
|
com.android.tradefed.config.ConfigurationException |
ConfigurationException |
|
execCommand
protected long execCommand (IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener,reservedDevices, String[] args)
| パラメータ | |
|---|---|
context |
IInvocationContext |
listener |
ICommandScheduler.IScheduledInvocationListener |
reservedDevices |
|
args |
String |
| 戻り値 | |
|---|---|
long |
|
| 例外 | |
|---|---|
ConfigurationException |
|
getConfigFactory
protected IConfigurationFactory getConfigFactory ()
IConfigurationFactory への参照を取得するファクトリ メソッド
| 戻り値 | |
|---|---|
IConfigurationFactory |
使用する IConfigurationFactory |
getDeviceManagementServer
protected DeviceManagementGrpcServer getDeviceManagementServer ()
| 戻り値 | |
|---|---|
DeviceManagementGrpcServer |
|
getDeviceManager
protected IDeviceManager getDeviceManager ()
IDeviceManager への参照を取得するファクトリ メソッド
| 戻り値 | |
|---|---|
IDeviceManager |
使用する IDeviceManager |
getKeyStoreClient
protected IKeyStoreClient getKeyStoreClient ()
IGlobalConfiguration で宣言された IKeyStoreFactory を使用して IKeyStoreClient を取得します。定義されていない場合は null を返します。
| 戻り値 | |
|---|---|
IKeyStoreClient |
IKeyStoreClient |
getTestInvocationManagementServer
protected TestInvocationManagementServer getTestInvocationManagementServer ()
| 戻り値 | |
|---|---|
TestInvocationManagementServer |
|
initLogging
protected void initLogging ()
ddmlib ログを初期化します。
単体テストでモックできるように公開されています。
isShutdown
protected boolean isShutdown ()
| 戻り値 | |
|---|---|
boolean |
|
processReadyCommands
protected void processReadyCommands (IDeviceManager manager)
| パラメータ | |
|---|---|
manager |
IDeviceManager |