コマンドスケジューラ

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

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

int getReadyCommandCount ()

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

long getShutdownTimeout ()
boolean isDeviceInInvocationThread ( ITestDevice device)

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

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

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

IConfiguration createConfiguration (String[] args)
IInvocationContext createInvocationContext ()
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 ()
boolean isShuttingDown ()
void processReadyCommands ( IDeviceManager manager)

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

コマンドスケジューラ

public CommandScheduler ()

CommandSchedulerを作成します。

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

公開メソッド

add コマンド

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

スロー
ConfigurationException

待つ

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 の場合、すべてのコマンドがダンプされます。

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

getHostState

public CommandScheduler.HostState getHostState ()

戻り値
CommandScheduler.HostState

getInvocationInfo

public String getInvocationInfo (int invocationId)

呼び出し ID を指定して呼び出し bu に関する情報を返します。

パラメーター
invocationId int : 呼び出しの追跡 ID。

戻り値
String呼び出しに関する情報を含むERROR(/String)

getLastInvocationExitCode

public CommandRunner.ExitCode getLastInvocationExitCode ()

実行された最後の呼び出しのエラー コードを返します。呼び出しがまだ実行されていない場合は、0 (エラーなし) を返します。

戻り値
CommandRunner.ExitCode

getLastInvocationThrowable

public Throwable getLastInvocationThrowable ()

実行された最後の呼び出しからERROR(/Throwable)を返します。スロー可能なものがない場合は、null を返します。

戻り値
Throwable

getReadyCommandCount

public int getReadyCommandCount ()

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

戻り値
int

getShutdownTimeout

public long getShutdownTimeout ()

戻り値
long

isDeviceInInvocationThread

public boolean isDeviceInInvocationThread (ITestDevice device)

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

パラメーター
device ITestDevice

戻り値
boolean

通知ファイルが変更されました

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

シャットダウンハード

public void shutdownHard (boolean killAdb)

コマンド スケジューラの強制シャットダウンを試みます。

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

パラメーター
killAdb boolean

シャットダウンハード

public void shutdownHard ()

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

shutdownOnEmpty

public void shutdownOnEmpty ()

shutdown()と似ていますが、終了する前にすべてのコマンドが実行されるのを待ちます。

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

始める

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

保護されたメソッド

掃除

protected void cleanUp ()

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

公開されているため、単体テストをモックできます。

createConfiguration

protected IConfiguration createConfiguration (String[] args)

パラメーター
args String

戻り値
IConfiguration

スロー
ConfigurationException

createInvocationContext

protected IInvocationContext createInvocationContext ()

戻り値
IInvocationContext

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

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

isShuttingDown

protected boolean isShuttingDown ()

戻り値
boolean

processReadyCommands

protected void processReadyCommands (IDeviceManager manager)

パラメーター
manager IDeviceManager