IRunUtil
public interface IRunUtil
com.android.tradefed.util.IRunUtil |
시간 제한 작업 및 시스템 명령을 실행하기 위한 인터페이스.
요약
중첩 클래스 | |
---|---|
interface | IRunUtil.IRunnableResult 부울 상태를 반환하는 작업을 비동기적으로 실행하기 위한 인터페이스입니다. |
공개 방법 | |
---|---|
abstract void | allowInterrupt (boolean allow) 현재 스레드에서 실행 인터럽트를 허용/금지합니다. |
abstract void | interrupt (Thread thread, String message, ErrorIdentifier errorId) 지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. |
abstract void | interrupt (Thread thread, String message) 지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. |
abstract boolean | isInterruptAllowed () RunUtil의 인터럽트 상태를 제공합니다. |
abstract Process | runCmdInBackground (Redirect redirect, command) runCmdInBackground (Redirect redirect, command) |
abstract Process | runCmdInBackground ( command) runCmdInBackground ( command) |
abstract Process | runCmdInBackground ( command, OutputStream output) runCmdInBackground ( command, OutputStream output) |
abstract Process | runCmdInBackground (String... command) 시스템 명령을 비동기적으로 실행하는 도우미 메서드입니다. |
abstract Process | runCmdInBackground (Redirect redirect, String... command) 시스템 명령을 비동기적으로 실행하는 도우미 메서드입니다. |
abstract boolean | runEscalatingTimedRetry (long opTimeout, long initialPollInterval, long maxPollInterval, long maxTime, IRunUtil.IRunnableResult runnable) 성공할 때까지 작업을 여러 번 차단하고 실행합니다. |
abstract boolean | runFixedTimedRetry (long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable) 성공할 때까지 작업을 여러 번 차단하고 실행합니다. |
abstract CommandStatus | runTimed (long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors) 작업을 차단하고 실행하며 지정된 시간보다 오래 걸리면 중단됩니다. |
abstract CommandResult | runTimedCmd (long timeout, OutputStream stdout, OutputStream stderr, String... command) 시스템 명령을 실행하고, 지정된 시간보다 오래 걸리면 중단하고, 지정된 경우 출력을 파일로 리디렉션하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmd (long timeout, String... command) 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdRetry (long timeout, long retryInterval, int attempts, String... command) 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdSilently (long timeout, String... command) 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdSilentlyRetry (long timeout, long retryInterval, int attempts, String... command) 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdWithInput (long timeout, String input, File stdoutFile, File stderrFile, String... command) 시스템 명령을 실행하고, 지정된 시간보다 오래 걸리면 중단하고, 지정된 경우 출력을 파일로 리디렉션하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdWithInput (long timeout, String input, String... command) stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdWithInput (long timeout, String input, command) runTimedCmdWithInput (long timeout, String input, command) stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. |
abstract CommandResult | runTimedCmdWithInputRedirect (long timeout, File inputRedirect, String... command) 파일에서 Stdin을 리디렉션하고 지정된 시간보다 오래 걸리는 경우 중단해야 하는 시스템 명령을 실행하는 도우미 메서드입니다. |
abstract boolean | runTimedRetry (long opTimeout, long pollInterval, int attempts, IRunUtil.IRunnableResult runnable) 성공할 때까지 작업을 여러 번 차단하고 실행합니다. |
abstract void | setEnvVariable (String key, String value) 시스템 명령을 실행할 때 사용할 환경 변수를 설정합니다. |
abstract void | setEnvVariablePriority ( IRunUtil.EnvPriority priority) 프로세스를 생성할 때 환경 변수를 설정하는 것보다 설정 해제하는 것이 우선 순위인지 여부를 결정합니다. |
abstract void | setInterruptibleInFuture (Thread thread, long timeMs) 약간의 대기 시간 후 중단 가능으로 설정하십시오. |
abstract void | setLinuxInterruptProcess (boolean interrupt) 시간 초과에 도달하면 #runTimed 메서드를 통해 실행 중인 프로세스에서 Linux 'kill' 중단을 사용하도록 허용합니다. |
abstract void | setRedirectStderrToStdout (boolean redirect) 시스템 명령을 실행할 때 표준 출력 스트림으로 리디렉션하도록 표준 오류 스트림을 설정합니다. |
abstract void | setWorkingDir (File dir) 시스템 명령에 대한 작업 디렉토리를 설정합니다. |
abstract void | sleep (long time) 예외를 무시하고 지정된 시간 동안 절전 모드로 전환하는 도우미 메서드입니다. |
abstract void | unsetEnvVariable (String key) 시스템 명령이 이 환경 변수 없이 실행되도록 환경 변수를 설정 해제합니다. |
공개 방법
allowInterrupt
public abstract void allowInterrupt (boolean allow)
현재 스레드에서 실행 인터럽트를 허용/금지합니다. 허용되면 다른 스레드에서 현재 스레드의 실행 작업을 interrupt(Thread, String)
메서드를 통해 중단할 수 있습니다.
매개변수 | |
---|---|
allow | boolean : 현재 스레드에서 실행 인터럽트를 허용할지 여부. |
방해하다
public abstract void interrupt (Thread thread, String message, ErrorIdentifier errorId)
지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. 지정된 스레드의 실행 작업은 RunInterruptedException
발생시킵니다.
매개변수 | |
---|---|
message | String : RunInterruptedException 에 대한 메시지입니다. |
errorId | ErrorIdentifier : 알려진 경우 중단의 원인을 나타냅니다. |
방해하다
public abstract void interrupt (Thread thread, String message)
지정된 스레드에서 진행 중인/다가오는 실행 작업을 중단합니다. 지정된 스레드의 실행 작업은 RunInterruptedException
발생시킵니다.
매개변수 | |
---|---|
message | String : RunInterruptedException 에 대한 메시지입니다. |
isInterruptAllowed
public abstract boolean isInterruptAllowed ()
RunUtil의 인터럽트 상태를 제공합니다.
보고 | |
---|---|
boolean | 실행을 중단할 수 있으면 true이고, 그렇지 않으면 false입니다. |
runCmdIn배경
public abstract Process runCmdInBackground (Redirect redirect,command)
ERROR(/List)
형식의 명령 인수를 허용하는 대체 runCmdInBackground(String)
메서드입니다.
매개변수 | |
---|---|
redirect | Redirect : ERROR( ERROR(/ProcessBuilder) ERROR(/Redirect) 입니다. |
command | ERROR(/List) |
보고 | |
---|---|
Process | 실행된 명령의 ERROR(/Process) |
던지기 | |
---|---|
| 명령 실행에 실패한 경우 |
runCmdIn배경
public abstract Process runCmdInBackground (command)
ERROR(/List)
형식의 명령 인수를 허용하는 대체 runCmdInBackground(String)
메서드입니다.
매개변수 | |
---|---|
command | ERROR(/List) |
보고 | |
---|---|
Process | 실행된 명령의 ERROR(/Process) |
던지기 | |
---|---|
| 명령 실행에 실패한 경우 |
runCmdIn배경
public abstract Process runCmdInBackground (command, OutputStream output)
ERROR(/OutputStream)
와 함께 명령을 실행하면 명령의 출력이 기록됩니다. Stdout과 stderr은 함께 병합됩니다.
매개변수 | |
---|---|
command | |
output | OutputStream : 출력을 저장할 OutputStream |
보고 | |
---|---|
Process | 명령을 실행하는 ERROR(/Process) |
던지기 | |
---|---|
| IO예외 |
runCmdIn배경
public abstract Process runCmdInBackground (String... command)
시스템 명령을 비동기적으로 실행하는 도우미 메서드입니다.
명령 실행 후 즉시 반환됩니다.
매개변수 | |
---|---|
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
Process | 실행된 명령의 ERROR(/Process) |
던지기 | |
---|---|
| 명령 실행에 실패한 경우 |
runCmdIn배경
public abstract Process runCmdInBackground (Redirect redirect, String... command)
시스템 명령을 비동기적으로 실행하는 도우미 메서드입니다.
명령 실행 후 즉시 반환됩니다.
매개변수 | |
---|---|
redirect | Redirect : ERROR( ERROR(/ProcessBuilder) ERROR(/Redirect) 입니다. |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
Process | 실행된 명령의 ERROR(/Process) |
던지기 | |
---|---|
| 명령 실행에 실패한 경우 |
runEscalatingTimedRetry
public abstract 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 abstract 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 abstract CommandStatus runTimed (long timeout, IRunUtil.IRunnableResult runnable, boolean logErrors)
작업을 차단하고 실행하며 지정된 시간보다 오래 걸리면 중단됩니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
runnable | IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
logErrors | boolean : 예외 발생 시 오류를 기록할지 여부. |
보고 | |
---|---|
CommandStatus | 작업의 CommandStatus 결과입니다. |
runTimedCmd
public abstract 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 abstract CommandResult runTimedCmd (long timeout, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms). 0은 제한 시간이 없음을 의미합니다. |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmd재시도
public abstract CommandResult runTimedCmdRetry (long timeout, long retryInterval, int attempts, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 각 시도에 대해 대기하는 최대 시간(ms) |
retryInterval | long : 명령 재시도 사이에 대기하는 시간 |
attempts | int : 최대 시도 횟수 |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmd조용히
public abstract CommandResult runTimedCmdSilently (long timeout, String... command)
시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다. runTimedCmd(long, String)
와 유사하지만 예외에 대한 오류를 기록하지 않습니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdSilentlyRetry
public abstract 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 abstract 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 abstract CommandResult runTimedCmdWithInput (long timeout, String input, String... command)
stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
input | String : 프로세스에 전달할 stdin 입력 |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdWithInput
public abstract CommandResult runTimedCmdWithInput (long timeout, String input,command)
stdin 입력이 필요한 시스템 명령을 실행하고 지정된 시간보다 오래 걸리면 중단하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
input | String : 프로세스에 전달할 stdin 입력 |
command | ERROR(/List) 시스템 명령과 선택적으로 exec에 대한 인수를 포함 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedCmdWithInputRedirect
public abstract CommandResult runTimedCmdWithInputRedirect (long timeout, File inputRedirect, String... command)
파일에서 Stdin을 리디렉션하고 지정된 시간보다 오래 걸리는 경우 중단해야 하는 시스템 명령을 실행하는 도우미 메서드입니다.
매개변수 | |
---|---|
timeout | long : 최대 대기 시간(ms) |
inputRedirect | File : ERROR ERROR(/ProcessBuilder#redirectInput()) 사용하여 표준 입력으로 리디렉션할 ERROR(/File) )입니다. null이면 stdin이 리디렉션되지 않습니다. |
command | String : 지정된 시스템 명령 및 선택적으로 exec에 대한 인수 |
보고 | |
---|---|
CommandResult | 명령 실행 결과를 포함하는 CommandResult |
runTimedRetry
public abstract 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 abstract void setEnvVariable (String key, String value)
시스템 명령을 실행할 때 사용할 환경 변수를 설정합니다.
매개변수 | |
---|---|
key | String : 변수 이름 |
value | String : 변수 값 |
setEnvVariablePriority
public abstract void setEnvVariablePriority (IRunUtil.EnvPriority priority)
프로세스를 생성할 때 환경 변수를 설정하는 것보다 설정 해제하는 것이 우선 순위인지 여부를 결정합니다. 기본적으로 설정 해제가 더 높은 우선 순위입니다. 즉, 동일한 이름의 변수를 설정하려고 시도하면 변수가 설정 해제되기 때문에 발생하지 않습니다. 기본 IRunUtil
인스턴스에서는 사용할 수 없습니다.
매개변수 | |
---|---|
priority | IRunUtil.EnvPriority |
setInterruptibleInFuture
public abstract void setInterruptibleInFuture (Thread thread, long timeMs)
약간의 대기 시간 후 중단 가능으로 설정하십시오. ERROR(/CommandScheduler#shutdownHard())
강제로 결국 종료합니다.
매개변수 | |
---|---|
thread | Thread : 인터럽트가 가능한 스레드. |
timeMs | long : 인터럽트를 설정하기 전에 기다리는 시간. |
setLinuxInterruptProcess
public abstract void setLinuxInterruptProcess (boolean interrupt)
시간 초과에 도달하면 #runTimed 메서드를 통해 실행 중인 프로세스에서 Linux 'kill' 중단을 사용하도록 허용합니다. 기본 IRunUtil
인스턴스에서는 사용할 수 없습니다.
매개변수 | |
---|---|
interrupt | boolean |
setRedirectStderrToStdout
public abstract void setRedirectStderrToStdout (boolean redirect)
시스템 명령을 실행할 때 표준 출력 스트림으로 리디렉션하도록 표준 오류 스트림을 설정합니다. 초기 값은 거짓입니다.
매개변수 | |
---|---|
redirect | boolean : 리디렉션 여부에 대한 새 값 |
setWorkingDir
public abstract void setWorkingDir (File dir)
시스템 명령에 대한 작업 디렉토리를 설정합니다.
매개변수 | |
---|---|
dir | File : 작업 디렉토리 |
잠
public abstract void sleep (long time)
예외를 무시하고 지정된 시간 동안 절전 모드로 전환하는 도우미 메서드입니다.
매개변수 | |
---|---|
time | long : ms 잠자기. 0보다 작거나 같은 값은 무시됩니다. |
unsetEnvVariable
public abstract void unsetEnvVariable (String key)
시스템 명령이 이 환경 변수 없이 실행되도록 환경 변수를 설정 해제합니다.
매개변수 | |
---|---|
key | String : 변수 이름 |
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2023-03-30(UTC)