RunUtil
public class RunUtil
extends Object
implements IRunUtil
java.lang.객체 | |
↳ | com.android.tradefed.util.RunUtil |
작업을 실행하기 위한 도우미 메서드 모음입니다.
요약
필드 | |
---|---|
public static final String | INHERITIO_PREFIX |
public static final String | RUNNABLE_NOTIFIER_NAME
|
공개 생성자 | |
---|---|
RunUtil () 사용할 새 |
공개 방법 | |
---|---|
void | allowInterrupt (boolean allow) 현재 스레드에서 실행 인터럽트를 허용/금지합니다. |
static IRunUtil | getDefault () 기본 |
void | interrupt (Thread thread, String message, ErrorIdentifier errorId) 지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. |
void | interrupt (Thread thread, String message) 지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. |
boolean | isInterruptAllowed () RunUtil의 인터럽트 상태를 제공합니다. |
Process | runCmdInBackground (Redirect redirect, command) runCmdInBackground (Redirect redirect, command) |
Process | runCmdInBackground ( command) runCmdInBackground ( command) |
Process | runCmdInBackground ( command, OutputStream output) runCmdInBackground ( command, OutputStream output) |
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) 성공할 때까지 작업을 여러 번 차단하고 실행합니다. |
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 | 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) runTimedCmdWithInput (long timeout, String input, command) stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
CommandResult | runTimedCmdWithInputRedirect (long timeout, File inputRedirect, String... command) 파일에서 Stdin을 리디렉션하고 지정된 시간보다 오래 걸리는 경우 중단해야 하는 시스템 명령을 실행하는 도우미 메서드입니다. |
boolean | runTimedRetry (long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable) 성공할 때까지 작업을 여러 번 차단하고 실행합니다. |
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) 시스템 명령이 이 환경 변수 없이 실행되도록 환경 변수를 설정 해제합니다. 환경 변수는 상위 프로세스에서 상속될 수 있으므로 |
필드
INHERITIO_PREFIX
public static final String INHERITIO_PREFIX
RUNNABLE_NOTIFIER_NAME
public static final String RUNNABLE_NOTIFIER_NAME
공개 생성자
공개 방법
allowInterrupt
public void allowInterrupt (boolean allow)
현재 스레드에서 실행 인터럽트를 허용/금지합니다. 허용되면 다른 스레드에서 현재 스레드의 실행 작업을 interrupt(Thread, String)
메서드를 통해 중단할 수 있습니다.
매개변수 | |
---|---|
allow | boolean : 현재 스레드에서 실행 인터럽트를 허용할지 여부. |
getDefault
public static IRunUtil getDefault ()
기본 RunUtil
개체에 대한 참조를 가져옵니다.
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입니다. |
runCmdIn배경
public Process runCmdInBackground (Redirect redirect,command)
ERROR(/List)
형식의 명령 인수를 허용하는 대체 runCmdInBackground(String)
메서드입니다.
매개변수 | |
---|---|
redirect | Redirect : ProcessBuilder 에 적용할 ERROR(/Redirect) . |
command | ERROR(/List) |
보고 | |
---|---|
Process | 실행된 명령의 Process |
runCmdIn배경
public Process runCmdInBackground (command)
ERROR(/List)
형식의 명령 인수를 허용하는 대체 runCmdInBackground(String)
메서드입니다.
매개변수 | |
---|---|
command | ERROR(/List) |
보고 | |
---|---|
Process | 실행된 명령의 Process |
runCmdIn배경
public Process runCmdInBackground (command, OutputStream output)
ERROR(/OutputStream)
와 함께 명령을 실행하면 명령의 출력이 기록됩니다. Stdout과 stderr은 함께 병합됩니다.
매개변수 | |
---|---|
command | |
output | OutputStream : 출력을 저장할 OutputStream |
보고 | |
---|---|
Process | 명령을 실행하는 Process |
runCmdIn배경
public Process runCmdInBackground (String... command)
시스템 명령을 비동기적으로 실행하는 도우미 메서드입니다.
명령 실행 후 즉시 반환됩니다.
매개변수 | |
---|---|
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
Process | 실행된 명령의 Process |
runCmdIn배경
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 : 단일 작업 시도를 기다리는 최대 시간(ms) |
initialPollInterval | long : 작업 시도 사이의 초기 대기 시간 |
maxPollInterval | long : 작업 시도 사이의 최대 대기 시간 |
maxTime | long : 작업을 계속 시도하는 총 대략적인 최대 시간 |
runnable | IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
보고 | |
---|---|
boolean | maxTime이 만료되기 전에 작업이 성공적으로 완료된 경우 true |
runFixedTimed재시도
public boolean runFixedTimedRetry (long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
성공할 때까지 작업을 여러 번 차단하고 실행합니다.
매개변수 | |
---|---|
opTimeout | long : 단일 작업 시도를 기다리는 최대 시간(ms) |
pollInterval | long : 작업 시도 사이의 초기 대기 시간 |
maxTime | long : 작업을 계속 시도하는 총 대략적인 최대 시간 |
runnable | IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
보고 | |
---|---|
boolean | maxTime이 만료되기 전에 작업이 성공적으로 완료된 경우 true |
런타임
public CommandStatus runTimed (long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
작업을 차단하고 실행하며 지정된 시간보다 오래 걸리면 중단됩니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
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 : 타임아웃 최대 대기 시간(ms). 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 : 최대 대기 시간(ms). 0은 제한 시간이 없음을 의미합니다. |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmd재시도
public CommandResult runTimedCmdRetry (long timeout, long retryInterval, int attempts, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 각 시도에 대해 대기하는 최대 시간(ms) |
retryInterval | long : 명령 재시도 사이에 대기하는 시간 |
attempts | int : 최대 시도 횟수 |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmd조용히
public CommandResult runTimedCmdSilently (long timeout, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. runTimedCmd(long, String)
와 유사하지만 예외에 대한 오류를 기록하지 않습니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdSilentlyRetry
public CommandResult runTimedCmdSilentlyRetry (long timeout, long retryInterval, int attempts, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. runTimedCmdRetry(long, long, int, String[])
와 유사하지만 예외에 대한 오류를 기록하지 않습니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
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 : 타임아웃 최대 대기 시간(ms). 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 : 최대 대기 시간(ms) |
input | String : 프로세스에 전달할 stdin 입력 |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdWithInput
public CommandResult runTimedCmdWithInput (long timeout, String input,command)
stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
input | String : 프로세스에 전달할 stdin 입력 |
command | ERROR(/List) 시스템 명령과 선택적으로 exec에 대한 인수를 포함 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdWithInputRedirect
public CommandResult runTimedCmdWithInputRedirect (long timeout, File inputRedirect, String... command)
파일에서 Stdin을 리디렉션하고 지정된 시간보다 오래 걸리는 경우 중단해야 하는 시스템 명령을 실행하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
inputRedirect | File : ProcessBuilder.redirectInput() 사용하여 표준 입력으로 리디렉션할 ERROR(/File) . null이면 stdin이 리디렉션되지 않습니다. |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedRetry
public boolean runTimedRetry (long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable)
성공할 때까지 작업을 여러 번 차단하고 실행합니다.
매개변수 | |
---|---|
opTimeout | long : 한 번의 작업 시도 동안 대기하는 최대 시간(ms) |
pollInterval | long : 명령 재시도 사이에 대기하는 시간 |
attempts | int : 최대 시도 횟수 |
runnable | IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
보고 | |
---|---|
boolean | 시도에 도달하기 전에 작업이 성공적으로 완료되면 true 입니다. |
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)
시스템 명령을 실행할 때 표준 출력 스트림으로 리디렉션하도록 표준 오류 스트림을 설정합니다. 초기 값은 거짓입니다.
매개변수 | |
---|---|
redirect | boolean : 리디렉션 여부에 대한 새 값 |
setWorkingDir
public void setWorkingDir (File dir)
시스템 명령에 대한 작업 디렉토리를 설정합니다.
매개변수 | |
---|---|
dir | File : 작업 디렉토리 |
잠
public void sleep (long time)
예외를 무시하고 지정된 시간 동안 절전 모드로 전환하는 도우미 메서드입니다.
매개변수 | |
---|---|
time | long : ms 잠자기. 0보다 작거나 같은 값은 무시됩니다. |
unsetEnvVariable
public void unsetEnvVariable (String key)
시스템 명령이 이 환경 변수 없이 실행되도록 환경 변수를 설정 해제합니다. 환경 변수는 상위 프로세스에서 상속될 수 있으므로 ProcessBuilder.environment()
에서 환경 변수를 삭제해야 합니다.
매개변수 | |
---|---|
key | String : 변수 이름 |
또한보십시오: