CommandScheduler

public class CommandScheduler
extends Object implements ICommandScheduler

java.lang.Object
   ↳ com.android.tradefed.command.CommandScheduler


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

実行時間の合計実行回数に基づいて、実行するコマンドの優先順位を付けようとします。たとえば、実行頻度が低いコマンドや実行時間の短いコマンドは、実行時間の長いコマンドよりも優先されます。

シャットダウンするまでバックグラウンドで実行し続けます。

概要

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

CommandScheduler()

CommandScheduler を作成します。

パブリック メソッド

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

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

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

すでに割り当てられているデバイスでコマンドを直接実行します。

long 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 を指定して、呼び出しに関する情報を返します。

CommandRunner.ExitCode getLastInvocationExitCode()

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

Throwable getLastInvocationThrowable()

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

int getReadyCommandCount()

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

long getShutdownTimeout()
boolean isDeviceInInvocationThread(ITestDevice device)

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

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

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

void run()

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

void setClearcutClient(ClearcutClient client)

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

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

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

CommandScheduler

public CommandScheduler ()

CommandScheduler を作成します。

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

パブリック メソッド

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 static  createReleaseMap (IInvocationContext context, 
                Throwable e)

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

パラメータ
context IInvocationContext

e Throwable

戻り値

createSandbox

public ISandbox createSandbox ()

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

戻り値
ISandbox

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

getHostState

public CommandScheduler.HostState getHostState ()

戻り値
CommandScheduler.HostState

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

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

setMaxPollTime

public void setMaxPollTime (long polling)

パラメータ
polling long

setPrintSchedulingWarning

public void setPrintSchedulingWarning (boolean print)

パラメータ
print boolean

shouldShutdownOnCmdfileError

public boolean shouldShutdownOnCmdfileError ()

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

戻り値
boolean

shutdown

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() と似ていますが、終了する前にすべてのコマンドが実行されるのを待ちます。

コマンドがループモードの場合、スケジューラは終了しません。

start

public void start ()

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

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

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 ログを初期化します。

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

isShutdown

protected boolean isShutdown ()

戻り値
boolean

processReadyCommands

protected void processReadyCommands (IDeviceManager manager)

パラメータ
manager IDeviceManager