RunUtil

public class RunUtil
extends Object implements IRunUtil

java.lang.Object
   ↳ com.android.tradefed.util.RunUtil


オペレーションの実行に使用するヘルパー メソッドのコレクション。

概要

フィールド

public static final String INHERITIO_PREFIX

public static final String RUNNABLE_NOTIFIER_NAME

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

RunUtil()

使用する新しい RunUtil オブジェクトを作成します。

RunUtil(boolean inheritEnvVars)

パブリック メソッド

void allowInterrupt(boolean allow)

現在のスレッドで実行中断を許可または禁止します。

ProcessBuilder createProcessBuilder(Redirect redirect, commandList, boolean enableCache)
static IRunUtil getDefault()

デフォルトの RunUtil オブジェクトへの参照を取得します。

void interrupt(Thread thread, String message, ErrorIdentifier errorId)

指定されたスレッドで進行中または今後実行される実行オペレーションを中断します。

void interrupt(Thread thread, String message)

指定されたスレッドで進行中または今後実行される実行オペレーションを中断します。

boolean isInterruptAllowed()

RunUtil の中断ステータスを返します。

Process runCmdInBackground(Redirect redirect, command)

ERROR(/List) 形式のコマンド引数を受け取る別の runCmdInBackground(String) メソッド。

Process runCmdInBackground( command)

ERROR(/List) 形式のコマンド引数を受け取る別の runCmdInBackground(String) メソッド。

Process runCmdInBackground( command, OutputStream output)

ERROR(/OutputStream) を指定してコマンドを実行すると、コマンドの出力がログに記録されます。

Process runCmdInBackground(String... command)

システム コマンドを非同期で実行するヘルパー メソッド。

Process runCmdInBackground(Redirect redirect, String... command)

システム コマンドを非同期で実行するヘルパー メソッド。

boolean runEscalatingTimedRetry(long opTimeout, long initialPollInterval, long maxPollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

boolean runFixedTimedRetry(long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

boolean runFixedTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

CommandStatus runTimed(long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)

オペレーションをブロックして実行し、指定された時間を超えると中止します。

CommandResult runTimedCmd(long timeout, OutputStream stdout, OutputStream stderr, String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。

CommandResult runTimedCmd(long timeout, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

CommandResult runTimedCmdRetry(long timeout, long retryInterval, int attempts, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

CommandResult runTimedCmdRetryWithOutputMonitor(long timeout, long idleOutputTimeout, long retryInterval, int attempts, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

CommandResult runTimedCmdSilently(long timeout, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

CommandResult runTimedCmdSilentlyRetry(long timeout, long retryInterval, int attempts, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

CommandResult runTimedCmdWithInput(long timeout, String input, File stdoutFile, File stderrFile, String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。

CommandResult runTimedCmdWithInput(long timeout, String input, String... command)

stdin 入力を必要とするシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

CommandResult runTimedCmdWithInput(long timeout, String input, command)

stdin 入力を必要とするシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

CommandResult runTimedCmdWithInputRedirect(long timeout, File inputRedirect, String... command)

ファイルから Stdin をリダイレクトする必要があるシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

CommandResult runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, OutputStream stdout, OutputStream stderr, String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。

CommandResult runTimedCmdWithOutputMonitor(long timeout, long idleOutputTimeout, String... command)

システム コマンドを実行し、指定した時間より長くかかる場合は中止するヘルパー メソッド。

boolean runTimedRetry(long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

boolean runTimedRetryWithOutputMonitor(long opTimeout, long idleOutputTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

CommandStatus runTimedWithOutputMonitor(long timeout, long idleOutputTimeout, IRunUtil.IRunnableResult runnable, boolean logErrors)

オペレーションをブロックして実行し、指定された時間を超えると中止します。

void setEnvVariable(String name, String value)

システム コマンドの実行時に使用される環境変数を設定します。

void setEnvVariablePriority(IRunUtil.EnvPriority priority)

プロセスの作成時に、環境変数の設定解除が設定よりも優先されるかどうかを決定します。

void setInterruptibleInFuture(Thread thread, long timeMs)

一定の待機時間後に中断可能として設定します。

void setLinuxInterruptProcess(boolean interrupt)

タイムアウトに達したときに、#runTimed メソッドで実行されているプロセスで Linux の「kill」中断を使用できるようにしました。

void setRedirectStderrToStdout(boolean redirect)

システム コマンドを実行するときに、標準出力ストリームにリダイレクトするように標準エラー ストリームを設定します。

void setWorkingDir(File dir)

システム コマンドの作業ディレクトリを設定します。

void sleep(long time)

例外を無視して指定された時間だけスリープするヘルパー メソッド。

void unsetEnvVariable(String key)

環境変数の設定を解除し、システム コマンドがこの環境変数なしで実行されるようにします。環境変数は親プロセスから継承される可能性があるため、ProcessBuilder.environment() から環境変数を削除する必要があります。

フィールド

INHERITIO_PREFIX

public static final String INHERITIO_PREFIX

RUNNABLE_NOTIFIER_NAME

public static final String RUNNABLE_NOTIFIER_NAME

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

RunUtil

public RunUtil ()

使用する新しい RunUtil オブジェクトを作成します。

RunUtil

public RunUtil (boolean inheritEnvVars)

パラメータ
inheritEnvVars boolean

パブリック メソッド

allowInterrupt

public void allowInterrupt (boolean allow)

現在のスレッドで実行中断を許可または禁止します。許可されている場合、現在のスレッドの実行オペレーションは、interrupt(Thread, String) メソッドを介して他のスレッドから中断できます。

パラメータ
allow boolean: 現在のスレッドで実行中断を許可するかどうか。

createProcessBuilder

public ProcessBuilder createProcessBuilder (Redirect redirect, 
                 commandList, 
                boolean enableCache)

パラメータ
redirect Redirect

commandList

enableCache boolean

戻り値
ProcessBuilder

getDefault

public static IRunUtil getDefault ()

デフォルトの RunUtil オブジェクトへの参照を取得します。

これは、カスタマイズなしで IRunUtil を使用する呼び出し元に便利です。カスタムの IRunUtil インスタンスが必要な呼び出し元(setEnvVariable(String, String) または setWorkingDir(File) のいずれかを呼び出す必要がある呼び出し元)は、独自のコピーを作成することをおすすめします。

戻り値
IRunUtil

割り込み

public void interrupt (Thread thread, 
                String message, 
                ErrorIdentifier errorId)

指定されたスレッドで進行中または今後実行される実行オペレーションを中断します。指定されたスレッドで実行オペレーションを実行すると、RunInterruptedException がスローされます。

パラメータ
message String: RunInterruptedException のメッセージ。

errorId ErrorIdentifier: 中断の原因(既知の場合)。

割り込み

public void interrupt (Thread thread, 
                String message)

指定されたスレッドで進行中または今後実行される実行オペレーションを中断します。指定されたスレッドで実行オペレーションを実行すると、RunInterruptedException がスローされます。

パラメータ
message String: RunInterruptedException のメッセージ。

isInterruptAllowed

public boolean isInterruptAllowed ()

RunUtil の中断ステータスを返します。

戻り値
boolean 実行を中断できる場合は true、それ以外の場合は false。

runCmdInBackground

public Process runCmdInBackground (Redirect redirect, 
                 command)

ERROR(/List) 形式のコマンド引数を受け取る代替の runCmdInBackground(String) メソッド。

パラメータ
redirect Redirect: ProcessBuilder に適用する ERROR(/Redirect)

command : 指定されたシステム コマンドと、必要に応じて実行する引数を含む ERROR(/List)

戻り値
Process 実行されたコマンドの Process

runCmdInBackground

public Process runCmdInBackground ( command)

ERROR(/List) 形式のコマンド引数を受け取る代替の runCmdInBackground(String) メソッド。

パラメータ
command : 指定されたシステム コマンドと、必要に応じて実行する引数を含む ERROR(/List)

戻り値
Process 実行されたコマンドの Process

runCmdInBackground

public Process runCmdInBackground ( command, 
                OutputStream output)

ERROR(/OutputStream) を指定してコマンドを実行すると、コマンドの出力がログに記録されます。stdout と stderr が統合されます。

パラメータ
command : 実行するコマンド

output OutputStream: 出力を保存する OutputStream

戻り値
Process コマンドを実行している Process

runCmdInBackground

public Process runCmdInBackground (String... command)

システム コマンドを非同期で実行するヘルパー メソッド。

コマンドの起動直後に返されます。

パラメータ
command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
Process 実行されたコマンドの Process

runCmdInBackground

public Process runCmdInBackground (Redirect redirect, 
                String... command)

システム コマンドを非同期で実行するヘルパー メソッド。

コマンドの起動直後に返されます。

パラメータ
redirect Redirect: ProcessBuilder に適用する ERROR(/Redirect)

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
Process 実行されたコマンドの Process

runEscalatingTimedRetry

public boolean runEscalatingTimedRetry (long opTimeout, 
                long initialPollInterval, 
                long maxPollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

オペレーションの試行間の待機時間を指数関数的に増やします。これは、サーバーのポーリングなどのオペレーションを実行するときに使用し、サーバーが一時的に停止した場合に復旧する時間を確保することを目的としています。

パラメータ
opTimeout long: 1 回のオペレーションの試行で待機する最大時間(ミリ秒)

initialPollInterval long: オペレーションの試行の間に待機する初期時間

maxPollInterval long: オペレーションの試行の間に待機する最大時間

maxTime long: オペレーションの再試行を続ける合計推定最大時間

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

戻り値
boolean true(maxTime が期限切れになる前にオペレーションが正常に完了した場合)

runFixedTimedRetry

public boolean runFixedTimedRetry (long opTimeout, 
                long pollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

パラメータ
opTimeout long: 1 回のオペレーションの試行で待機する最大時間(ミリ秒)

pollInterval long: オペレーションの試行の間に待機する初期時間

maxTime long: オペレーションの再試行を続ける合計推定最大時間

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

戻り値
boolean true(maxTime が期限切れになる前にオペレーションが正常に完了した場合)

runFixedTimedRetryWithOutputMonitor

public boolean runFixedTimedRetryWithOutputMonitor (long opTimeout, 
                long idleOutputTimeout, 
                long pollInterval, 
                long maxTime, 
                IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。また、出力ストリームのアクティビティをモニタリングし、指定した時間ストリーム アクティビティが検出されなかった場合は中止します。idleOutputTimeout がゼロに設定されている場合、ストリーム モニタリングは行われません。

パラメータ
opTimeout long: 1 回のオペレーションの試行で待機する最大時間(ミリ秒)

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

pollInterval long: オペレーションの試行の間に待機する初期時間

maxTime long: オペレーションの再試行を続ける合計推定最大時間

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

戻り値
boolean true(maxTime が期限切れになる前にオペレーションが正常に完了した場合)

runTimed

public CommandStatus runTimed (long timeout, 
                IRunUtil.IRunnableResult runnable, 
                boolean logErrors)

オペレーションをブロックして実行し、指定された時間を超えると中止します。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

logErrors boolean: 例外でエラーをログに記録するかどうか。

戻り値
CommandStatus オペレーションの CommandStatus 結果。

runTimedCmd

public CommandResult runTimedCmd (long timeout, 
                OutputStream stdout, 
                OutputStream stderr, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。このように ERROR(/OutputStream) を指定すると、関数の終了時に開いたままになります。

パラメータ
timeout long: 待機するタイムアウトの最大時間(ミリ秒単位)。0 はタイムアウトなしを意味します。

stdout OutputStream: 標準出力がリダイレクトされる ERROR(/OutputStream)。null の場合もあります。

stderr OutputStream: エラー出力がリダイレクトされる ERROR(/OutputStream)。null の場合もあります。

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmd

public CommandResult runTimedCmd (long timeout, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

パラメータ
timeout long: 待機する最大時間(ミリ秒単位)。0 はタイムアウトなしを意味します。

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdRetry

public CommandResult runTimedCmdRetry (long timeout, 
                long retryInterval, 
                int attempts, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

パラメータ
timeout long: 各試行で待機する最大時間(ミリ秒)

retryInterval long: コマンドの再試行の間に待機する時間

attempts int: 試行する最大回数

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdRetryWithOutputMonitor

public CommandResult runTimedCmdRetryWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                long retryInterval, 
                int attempts, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。また、出力ストリームのアクティビティをモニタリングし、指定した時間内にストリーム アクティビティが検出されなかった場合は中止します。idleOutputTimeout がゼロに設定されている場合、ストリーム モニタリングは行われません。

パラメータ
timeout long: 各試行で待機する最大時間(ミリ秒)

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

retryInterval long: コマンドの再試行の間に待機する時間

attempts int: 試行する最大回数

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdSilently

public CommandResult runTimedCmdSilently (long timeout, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。runTimedCmd(long, String) に似ていますが、例外でエラーをログに記録しません。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdSilentlyRetry

public CommandResult runTimedCmdSilentlyRetry (long timeout, 
                long retryInterval, 
                int attempts, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。runTimedCmdRetry(long, long, int, String[]) に似ていますが、例外でエラーをログに記録しません。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

retryInterval long: コマンドの再試行の間に待機する時間

attempts int: 試行する最大回数

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithInput

public CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                File stdoutFile, 
                File stderrFile, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。

パラメータ
timeout long: 待機するタイムアウトの最大時間(ミリ秒単位)。0 はタイムアウトなしを意味します。

input String: プロセスに渡す stdin 入力

stdoutFile File: 標準出力がリダイレクトされる ERROR(/File)。null の場合もあります。

stderrFile File: エラー出力がリダイレクトされる ERROR(/File)。null の場合もあります。

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithInput

public CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                String... command)

stdin 入力を必要とするシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

input String: プロセスに渡す stdin 入力

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithInput

public CommandResult runTimedCmdWithInput (long timeout, 
                String input, 
                 command)

stdin 入力を必要とするシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

input String: プロセスに渡す stdin 入力

command : システム コマンドと、必要に応じて実行する引数を含む ERROR(/List)

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithInputRedirect

public CommandResult runTimedCmdWithInputRedirect (long timeout, 
                File inputRedirect, 
                String... command)

ファイルから Stdin をリダイレクトする必要があるシステム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

inputRedirect File: ProcessBuilder.redirectInput() を使用して標準入力としてリダイレクトする ERROR(/File)。null の場合、stdin はリダイレクトされません。

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithOutputMonitor

public CommandResult runTimedCmdWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                OutputStream stdout, 
                OutputStream stderr, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止し、指定されている場合は出力をファイルにリダイレクトするヘルパー メソッド。このように ERROR(/OutputStream) を指定すると、関数の終了時に開いたままになります。

パラメータ
timeout long: 待機するタイムアウトの最大時間(ミリ秒単位)。0 はタイムアウトなしを意味します。

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

stdout OutputStream: 標準出力がリダイレクトされる ERROR(/OutputStream)。null の場合もあります。

stderr OutputStream: エラー出力がリダイレクトされる ERROR(/OutputStream)。null の場合もあります。

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedCmdWithOutputMonitor

public CommandResult runTimedCmdWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                String... command)

システム コマンドを実行し、指定された時間を超えると中止するヘルパー メソッド。また、出力ストリームのアクティビティをモニタリングし、指定した時間内にストリーム アクティビティが検出されなかった場合は中止します。idleOutputTimeout がゼロに設定されている場合、ストリーム モニタリングは行われません。

パラメータ
timeout long: 待機する最大時間(ミリ秒単位)。0 はタイムアウトなしを意味します。

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

command String: 指定されたシステム コマンドと、必要に応じて exec の引数

戻り値
CommandResult コマンドの実行結果を含む CommandResult

runTimedRetry

public boolean runTimedRetry (long opTimeout, 
                long pollInterval, 
                int attempts, 
                IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。

パラメータ
opTimeout long: 1 回のオペレーションの試行で待機する最大時間(ミリ秒単位)

pollInterval long: コマンドの再試行の間に待機する時間

attempts int: 試行する最大回数

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

戻り値
boolean 試行に達する前にオペレーションが正常に完了した場合は true

runTimedRetryWithOutputMonitor

public boolean runTimedRetryWithOutputMonitor (long opTimeout, 
                long idleOutputTimeout, 
                long pollInterval, 
                int attempts, 
                IRunUtil.IRunnableResult runnable)

オペレーションが成功するまで、オペレーションをブロックして複数回実行します。また、出力ストリームのアクティビティをモニタリングし、指定した時間ストリーム アクティビティが検出されなかった場合は中止します。idleOutputTimeout がゼロに設定されている場合、ストリーム モニタリングは行われません。

パラメータ
opTimeout long: 1 回のオペレーションの試行で待機する最大時間(ミリ秒単位)

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

pollInterval long: コマンドの再試行の間に待機する時間

attempts int: 試行する最大回数

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

戻り値
boolean 試行に達する前にオペレーションが正常に完了した場合は true

runTimedWithOutputMonitor

public CommandStatus runTimedWithOutputMonitor (long timeout, 
                long idleOutputTimeout, 
                IRunUtil.IRunnableResult runnable, 
                boolean logErrors)

オペレーションをブロックして実行し、指定された時間を超えると中止します。また、出力ストリームのアクティビティをモニタリングし、指定された時間にストリーム アクティビティが検出されなかった場合は中止します。idleOutputTimeout がゼロに設定されている場合、ストリーム モニタリングは行われません。

パラメータ
timeout long: 待機する最大時間(ミリ秒)

idleOutputTimeout long: 出力ストリームの出力を待機する最大時間(ミリ秒)

runnable IRunUtil.IRunnableResult: 実行する IRunUtil.IRunnableResult

logErrors boolean: 例外でエラーをログに記録するかどうか。

戻り値
CommandStatus オペレーションの CommandStatus 結果。

setEnvVariable

public void setEnvVariable (String name, 
                String value)

システム コマンドの実行時に使用される環境変数を設定します。

パラメータ
name String: 変数名

value String: 変数の値

setEnvVariablePriority

public void setEnvVariablePriority (IRunUtil.EnvPriority priority)

プロセスの作成時に、環境変数の設定解除が設定よりも優先されるかどうかを決定します。デフォルトでは、無効化の優先度が高くなります。つまり、同じ名前の変数の設定を試みても、変数が無効になっているため設定されません。デフォルトの IRunUtil インスタンスでは使用できません。

パラメータ
priority IRunUtil.EnvPriority

setInterruptibleInFuture

public void setInterruptibleInFuture (Thread thread, 
                long timeMs)

一定の待機時間後に中断可能として設定します。ERROR(/CommandScheduler#shutdownHard()) は、最終的に強制終了することを意味します。

パラメータ
thread Thread: 中断可能になるスレッド。

timeMs long: 中断可能を設定してから待機する時間。

setLinuxInterruptProcess

public void setLinuxInterruptProcess (boolean interrupt)

タイムアウトに達したときに、#runTimed メソッドで実行されているプロセスで Linux の「kill」中断を使用できるようにしました。 デフォルトの IRunUtil インスタンスでは使用できません。

パラメータ
interrupt boolean

setRedirectStderrToStdout

public void setRedirectStderrToStdout (boolean redirect)

システム コマンドを実行するときに、標準出力ストリームにリダイレクトするように標準エラー ストリームを設定します。初期値は false です。

パラメータ
redirect boolean: リダイレクトするかどうかの新しい値

setWorkingDir

public void setWorkingDir (File dir)

システム コマンドの作業ディレクトリを設定します。

パラメータ
dir File: 作業ディレクトリ

sleep

public void sleep (long time)

例外を無視して指定された時間だけスリープするヘルパー メソッド。

パラメータ
time long: スリープ時間(ミリ秒)。0 以下の値は無視されます。

unsetEnvVariable

public void unsetEnvVariable (String key)

環境変数の設定を解除し、システム コマンドがこの環境変数なしで実行されるようにします。環境変数は親プロセスから継承される可能性があるため、ProcessBuilder.environment() から環境変数を削除する必要があります。

パラメータ
key String: 変数名