CommandScheduler

public class CommandScheduler
extends Object implements ICommandScheduler

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


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

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

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

概要

ネストされたクラス

enum CommandScheduler.HostState

ホストのさまざまなステータスの列挙型

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

CommandScheduler()

CommandScheduler を作成します。

パブリック メソッド

boolean addCommand(String[] args)

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

void addCommandFile(String cmdFilePath, extraArgs)

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

void await()

スケジューラが実行を開始するまで待機します。これには、古い TF からの引き継ぎが完了するまで待機することも含まれます(該当する場合)。

static TradefedDelegator checkDelegation(String[] args)

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

void completeHandover()

開始された引き継ぎシーケンスが完全に完了し、デフォルト ポートでリモート マネージャーを再初期化する必要があることを指示します。

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 ファイルをダンプします。

void execCommand(ICommandScheduler.IScheduledInvocationListener listener, ITestDevice device, String[] args)

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

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

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

void 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()

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

int getReadyCommandCount()

キュー内の準備完了状態の Command の数を返します。

long getShutdownTimeout()
void handoverInitiationComplete()

使用中のデバイスとコマンドの最初の引き継ぎ交換が完了し、オペレーションのスケジュールを開始できることをコマンド スケジューラに通知します。

boolean handoverShutdown(int handoverPort)

shutdown() を開始し、同じホスト上の別の TradeFed プロセスに引き渡します。

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

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

void run()

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

void setClearcutClient(ClearcutClient client)

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

boolean shouldShutdownOnCmdfileError()

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

void shutdown()

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

void shutdownHard(boolean killAdb)

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

void shutdownHard()

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

void shutdownOnEmpty()

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

void start()

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

boolean stopInvocation(ITestInvocation invocation)

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

boolean stopInvocation(int invocationId, String cause)

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

保護されたメソッド

void cleanUp()

ログを閉じて、終了前に必要なクリーンアップを行います。

IConfiguration createConfiguration(String[] args)
IInvocationContext createInvocationContext()
IConfigurationFactory getConfigFactory()

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

IDeviceManager getDeviceManager()

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

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

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

void initLogging()

ddmlib ログを初期化します。

boolean isShutdown()
boolean isShuttingDown()
void processReadyCommands(IDeviceManager manager)
void waitForAllInvocationThreads()

すべての呼び出しスレッドが完了するまで待ちます。

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

CommandScheduler

public CommandScheduler ()

CommandScheduler を作成します。

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

パブリック メソッド

addCommand

public boolean addCommand (String[] args)

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

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

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

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

戻り値
boolean true(コマンドが正常に追加された場合)

例外
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

例外
ConfigurationException

completeHandover

public void completeHandover ()

開始された引き継ぎシーケンスが完全に完了し、デフォルト ポートでリモート マネージャーを再初期化する必要があることを指示します。

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 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

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 ()

キュー内の準備完了状態の Command の数を返します。

戻り値
int

getShutdownTimeout

public long getShutdownTimeout ()

戻り値
long

handoverInitiationComplete

public void handoverInitiationComplete ()

使用中のデバイスとコマンドの最初の引き継ぎ交換が完了し、オペレーションのスケジュールを開始できることをコマンド スケジューラに通知します。

handoverShutdown

public boolean handoverShutdown (int handoverPort)

shutdown() を開始し、同じホスト上の別の TradeFed プロセスに引き渡します。

スケジューラは、解放されたデバイスが利用可能になると、そのポートでリッスンしているリモート tradefed プロセスに通知します。

パラメータ
handoverPort int

戻り値
boolean ハンドオーバーの開始が成功した場合は true、それ以外の場合は false

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 ()

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

テストを待機しているコマンドをクリアし、進行中のすべての呼び出しを正常にシャットダウンするようリクエストします。

シャットダウンが呼び出されると、スケジューラ メインループは、進行中のすべての呼び出しが完了するまで待ってから完全に終了します。

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

保護されたメソッド

cleanUp

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

getFeatureServer

protected TradefedFeatureServer getFeatureServer ()

戻り値
TradefedFeatureServer

getHostOptions

protected IHostOptions getHostOptions ()

戻り値
IHostOptions

getKeyStoreClient

protected IKeyStoreClient getKeyStoreClient ()

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

戻り値
IKeyStoreClient IKeyStoreClient

initLogging

protected void initLogging ()

ddmlib ログを初期化します。

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

isShutdown

protected boolean isShutdown ()

戻り値
boolean

isShuttingDown

protected boolean isShuttingDown ()

戻り値
boolean

processReadyCommands

protected void processReadyCommands (IDeviceManager manager)

パラメータ
manager IDeviceManager

waitForAllInvocationThreads

protected void waitForAllInvocationThreads ()

すべての呼び出しスレッドが完了するまで待ちます。