コマンドスケジューラ

public class CommandScheduler
extends Object implements ICommandScheduler

java.lang.オブジェクト
com.android.tradefed.command.CommandScheduler


利用可能なすべてのデバイスで TradeFederation コマンドを実行するためのスケジューラ。

実行時間の合計実行回数に基づいて、実行するコマンドの優先順位付けを試みます。たとえば、頻繁に実行されないコマンドや高速に実行されるコマンドは、長時間実行されるコマンドよりも優先されます。

シャットダウンするまでバックグラウンドで永久に実行されます。

まとめ

パブリックコンストラクター

CommandScheduler ()

CommandSchedulerを作成します。

パブリックメソッド

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

スケジューラにコマンドを追加します。

void addCommandFile (String cmdFilePath, extraArgs) addCommandFile (String cmdFilePath, extraArgs)

指定されたファイルのすべてのコマンドをスケジューラに追加します

void await ()

古い TF からのハンドオーバーが完了するまで待機することも含めて、スケジューラの実行が開始されるまで待機します (該当する場合)。

static TradefedDelegator checkDelegation (String[] args)

コマンド ラインに基づいてデリゲータを作成し、実行を委任する必要があるかどうかを確認します。

static createReleaseMap ( IInvocationContext context, Throwable e)

デバイスを適切に解放できるように、デバイスの状態のマップを作成します。

ISandbox createSandbox ()

呼び出しの実行に使用するISandboxを作成します。

void displayCommandQueue (PrintWriter printWriter)

コマンド実行キューの状態に関する詳細なデバッグ情報を出力します。

void displayCommandsInfo (PrintWriter printWriter, String regex)

現在のコマンドのリストを出力します。

void displayInvocationsInfo (PrintWriter printWriter)

現在の呼び出しのリストを表示します。

void dumpCommandsXml (PrintWriter printWriter, String regex)

現在のすべてのコマンドに指定されているすべてのOption値を使用して、コマンドの展開された XML ファイルをダンプします。

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

割り当て済みのデバイス上でコマンドを直接実行します。

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

既存のIInvocationContextを使用して、デバイスをコマンド キューに追加せずに、デバイスを直接割り当ててコマンドを実行します。

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

コマンドキューにデバイスを追加せずに、デバイスを直接割り当ててコマンドを実行します。

CommandFileWatcher getCommandFileWatcher ()

このスケジューラに適切な CommandFileWatcher を取得します

int getExecutingCommandCount ()

実行状態のコマンドの数を返します。

CommandScheduler.HostState getHostState ()
String getInvocationInfo (int invocationId)

呼び出しIDを指定して呼び出しBUの情報を返します。

CommandRunner.ExitCode getLastInvocationExitCode ()

最後に実行された呼び出しのエラー コードを返します。

Throwable getLastInvocationThrowable ()

最後に実行された呼び出しからのThrowableを返します。

int getReadyCommandCount ()

キュー内の準備完了状態のコマンドの数を返します。

long getShutdownTimeout ()
boolean isDeviceInInvocationThread ( ITestDevice device)

デバイスがアクティブな呼び出しスレッドによって使用されている場合は true を返します。

boolean isShuttingDown ()
void notifyFileChanged (File cmdFile, extraArgs) notifyFileChanged (File cmdFile, extraArgs)
void removeAllCommands ()

スケジューラからすべてのコマンドを削除します

void run ()

このスレッドのメイン実行ブロック。

void setClearcutClient (ClearcutClient client)

ハーネス データをレポートするようにクライアントを設定する

boolean shouldShutdownOnCmdfileError ()

コマンドエラー時にスケジューラをシャットダウンする必要がある場合は true を返します。

void shutdown (boolean notifyStop)

コマンド スケジューラを正常にシャットダウンしてみます。

void shutdownHard (boolean killAdb)

コマンドスケジューラを強制的にシャットダウンしてみます。

void shutdownHard ()

コマンドスケジューラを強制的にシャットダウンしてみます。

void shutdownOnEmpty ()

shutdown()と似ていますが、すべてのコマンドが実行されるまで待機してから終了します。

void start ()

ロギングの設定、 DeviceManagerの初期化などを含むスケジューラを起動します。

boolean stopInvocation ( ITestInvocation invocation)

実行中の呼び出しを停止します。

boolean stopInvocation (int invocationId, String cause)

ID を指定して実行中の呼び出しを停止します。

void stopScheduling ()

新しいテストのスケジュール設定と受け入れは停止しますが、Tradefed は停止しません。

保護されたメソッド

void cleanUp ()

終了する前にログを閉じ、その他の必要なクリーンアップを実行します。

IConfiguration createConfiguration (String[] args)
IInvocationContext createInvocationContext ()
void dryRunCommandReporting ( ICommandScheduler.IScheduledInvocationListener handler, IConfiguration config)

指定されたコマンドが予行演習であるかどうかを判断します。

long execCommand ( IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, reservedDevices, String[] args) execCommand ( IInvocationContext context, ICommandScheduler.IScheduledInvocationListener listener, reservedDevices, String[] args)
IConfigurationFactory getConfigFactory ()

IConfigurationFactoryへの参照を取得するためのファクトリ メソッド

DeviceManagementGrpcServer getDeviceManagementServer ()
IDeviceManager getDeviceManager ()

IDeviceManagerへの参照を取得するためのファクトリ メソッド

TradefedFeatureServer getFeatureServer ()
IHostOptions getHostOptions ()
IKeyStoreClient getKeyStoreClient ()

IGlobalConfigurationで宣言されたIKeyStoreFactoryを使用してIKeyStoreClientを取得します。何も定義されていない場合は null を取得します。

TestInvocationManagementServer getTestInvocationManagementServer ()
void initLogging ()

ddmlib ログを初期化します。

boolean isShutdown ()
void processReadyCommands ( IDeviceManager manager)

パブリックコンストラクター

コマンドスケジューラ

public CommandScheduler ()

CommandSchedulerを作成します。

注: start は使用前に呼び出す必要があります。

パブリックメソッド

addコマンド

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

スケジューラにコマンドを追加します。

コマンドは基本的に、実行する構成とそれに関連する引数のインスタンスです。

「--help」引数を指定すると、設定のヘルプ テキストが標準出力に出力されます。それ以外の場合、構成は実行するキューに追加されます。

パラメーター
args String : 構成引数。

戻り値
Pair <Boolean, Integer>値のペア。コマンドが正常に追加された場合、最初の値はブール値trueです。 2 番目の値は既知のコマンド トラッカー ID (負ではない値) です。コマンドが正常に追加された場合は、コマンドがすべてのデバイスに追加された場合は 0 を返し、それ以外の場合は -1 を返します。

投げる
ConfigurationException

addコマンドファイル

public void addCommandFile (String cmdFilePath, 
                 extraArgs)

指定されたファイルのすべてのコマンドをスケジューラに追加します

パラメーター
cmdFilePath String : コマンドファイルのファイルシステムパス

extraArgs : ファイルから解析された各コマンドに追加するString引数のERROR(/List) 。空にすることもできますが、null にすることはできません。

投げる
ConfigurationException

待つ

public void await ()

古い TF からのハンドオーバーが完了するまで待機することも含めて、スケジューラの実行が開始されるまで待機します (該当する場合)。

check委任

public static TradefedDelegator checkDelegation (String[] args)

コマンド ラインに基づいてデリゲータを作成し、実行を委任する必要があるかどうかを確認します。

パラメーター
args String

戻り値
TradefedDelegator

投げる
com.android.tradefed.config.ConfigurationException
ConfigurationException

リリースマップの作成

public static  createReleaseMap (IInvocationContext context, 
                Throwable e)

デバイスを適切に解放できるように、デバイスの状態のマップを作成します。

パラメーター
context IInvocationContext

e Throwable

戻り値

サンドボックスの作成

public ISandbox createSandbox ()

呼び出しの実行に使用するISandboxを作成します。

戻り値
ISandbox

表示コマンドキュー

public void displayCommandQueue (PrintWriter printWriter)

コマンド実行キューの状態に関する詳細なデバッグ情報を出力します。

表示コマンド情報

public void displayCommandsInfo (PrintWriter printWriter, 
                String regex)

現在のコマンドのリストを出力します。

パラメーター
printWriter PrintWriter : 出力先のERROR(/PrintWriter)

regex String : 出力するためにコマンドを照合する必要がある正規表現。 null の場合、すべてのコマンドが出力されます。

表示呼び出し情報

public void displayInvocationsInfo (PrintWriter printWriter)

現在の呼び出しのリストを表示します。

パラメーター
printWriter PrintWriter : 出力先のERROR(/PrintWriter)

dumpCommandXml

public void dumpCommandsXml (PrintWriter printWriter, 
                String regex)

現在のすべてのコマンドに指定されているすべてのOption値を使用して、コマンドの展開された XML ファイルをダンプします。

パラメーター
printWriter PrintWriter : ステータスを出力するERROR(/PrintWriter)

regex String : XML ファイルをダンプするためにコマンドを照合する必要がある正規表現。 null の場合、すべてのコマンドがダンプされます。

execコマンド

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

割り当て済みのデバイス上でコマンドを直接実行します。

パラメーター
listener ICommandScheduler.IScheduledInvocationListener : 通知されるICommandScheduler.IScheduledInvocationListener

reservedDevices : ERROR(/List ) ERROR(/List )使用する

args String : コマンド引数

戻り値
longスケジュールされたコマンドの呼び出し ID。

投げる
ConfigurationException

execコマンド

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

既存のIInvocationContextを使用して、デバイスをコマンド キューに追加せずに、デバイスを直接割り当ててコマンドを実行します。

パラメーター
context IInvocationContext : 既存のIInvocationContext

listener ICommandScheduler.IScheduledInvocationListener : 通知されるICommandScheduler.IScheduledInvocationListener

args String : コマンド引数

戻り値
long

投げる
ConfigurationException
NoDeviceException

execコマンド

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

ホスト状態の取得

public CommandScheduler.HostState getHostState ()

戻り値
CommandScheduler.HostState

getInvocationInfo

public String getInvocationInfo (int invocationId)

呼び出しIDを指定して呼び出しBUの情報を返します。

パラメーター
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

isDeviceInInvocationThread

public boolean isDeviceInInvocationThread (ITestDevice device)

デバイスがアクティブな呼び出しスレッドによって使用されている場合は true を返します。

パラメーター
device ITestDevice

戻り値
boolean

シャットダウン中です

public boolean isShuttingDown ()

戻り値
boolean

通知ファイル変更

public void notifyFileChanged (File cmdFile, 
                 extraArgs)

パラメーター
cmdFile File

extraArgs

すべてのコマンドを削除

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 シャットダウンの呼び出しを通知します。

シャットダウンハード

public void shutdownHard (boolean killAdb)

コマンドスケジューラを強制的にシャットダウンしてみます。

shutdown()と似ていますが、進行中の呼び出しをより速く完了させるために、オプションで adb 接続を強制終了します。

パラメーター
killAdb boolean

シャットダウンハード

public void shutdownHard ()

コマンドスケジューラを強制的にシャットダウンしてみます。 shutdownHard(true) と同じです。

shutdownOnEmpty

public void shutdownOnEmpty ()

shutdown()と似ていますが、すべてのコマンドが実行されるまで待機してから終了します。

コマンドがループ モードにある場合、スケジューラは決して終了しないことに注意してください。

始める

public void start ()

ロギングの設定、 DeviceManagerの初期化などを含むスケジューラを起動します。

stop呼び出し

public boolean stopInvocation (ITestInvocation invocation)

実行中の呼び出しを停止します。

パラメーター
invocation ITestInvocation

戻り値
boolean呼び出しが停止された場合は true、それ以外の場合は false

stop呼び出し

public boolean stopInvocation (int invocationId, 
                String cause)

ID を指定して実行中の呼び出しを停止します。

パラメーター
invocationId int : 呼び出しのトラッキング ID。

cause String : 呼び出しを停止する原因。

戻り値
boolean呼び出しが停止された場合は true、それ以外の場合は false

停止スケジュール

public void stopScheduling ()

新しいテストのスケジュール設定と受け入れは停止しますが、Tradefed は停止しません。これは、最初に実行中のすべてのテストをドレインし、次に Tradefed プロセスを終了する 2 段階のシャットダウンを有効にすることを目的としています。

保護されたメソッド

掃除

protected void cleanUp ()

終了する前にログを閉じ、その他の必要なクリーンアップを実行します。

単体テストがモックできるように公開されています。

構成の作成

protected IConfiguration createConfiguration (String[] args)

パラメーター
args String

戻り値
IConfiguration

投げる
ConfigurationException

createInvocationContext

protected IInvocationContext createInvocationContext ()

戻り値
IInvocationContext

dryRunコマンドレポート

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

execコマンド

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

getデバイスマネージャー

protected IDeviceManager getDeviceManager ()

IDeviceManagerへの参照を取得するためのファクトリ メソッド

戻り値
IDeviceManager使用するIDeviceManager

getFeatureServer

protected TradefedFeatureServer getFeatureServer ()

戻り値
TradefedFeatureServer

getHostOptions

protected IHostOptions getHostOptions ()

戻り値
IHostOptions

getKeyStoreClient

protected IKeyStoreClient getKeyStoreClient ()

IGlobalConfigurationで宣言されたIKeyStoreFactoryを使用してIKeyStoreClientを取得します。何も定義されていない場合は null を取得します。

戻り値
IKeyStoreClient IKeyStoreClient

getTestInvocationManagementServer

protected TestInvocationManagementServer getTestInvocationManagementServer ()

戻り値
TestInvocationManagementServer

initLogging

protected void initLogging ()

ddmlib ログを初期化します。

単体テストがモックできるように公開されています。

シャットダウンです

protected boolean isShutdown ()

戻り値
boolean

processReadyコマンド

protected void processReadyCommands (IDeviceManager manager)

パラメーター
manager IDeviceManager