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(boolean inheritEnvVars)
|
공개 메서드 | |
---|---|
void
|
allowInterrupt(boolean allow)
현재 스레드에서 실행 인터럽트를 허용하거나 허용하지 않습니다. |
ProcessBuilder
|
createProcessBuilder(Redirect redirect,
|
static
IRunUtil
|
getDefault()
기본 |
void
|
interrupt(Thread thread, String message, ErrorIdentifier errorId)
지정된 스레드에서 진행 중인/예정된 실행 작업을 중단합니다. |
void
|
interrupt(Thread thread, String message)
지정된 스레드에서 진행 중인/예정된 실행 작업을 중단합니다. |
boolean
|
isInterruptAllowed()
RunUtil의 인터럽트 상태를 제공합니다. |
Process
|
runCmdInBackground(Redirect redirect,
|
Process
|
runCmdInBackground(
|
Process
|
runCmdInBackground(
|
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,
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)
환경 변수를 설정 해제하여 시스템 명령어가 이 환경 변수 없이 실행되도록 합니다.
환경 변수는 상위 프로세스에서 상속받을 수 있으므로 |
필드
INHERITIO_PREFIX
public static final String INHERITIO_PREFIX
RUNNABLE_NOTIFIER_NAME
public static final String RUNNABLE_NOTIFIER_NAME
공개 생성자
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 |
: 지정된 시스템 명령어와 선택적으로 exec 인수를 포함하는 ERROR(/List) |
반환 값 | |
---|---|
Process |
실행된 명령어의 Process |
runCmdInBackground
public Process runCmdInBackground (command)
ERROR(/List)
형식의 명령어 인수를 허용하는 대체 runCmdInBackground(String)
메서드입니다.
매개변수 | |
---|---|
command |
: 지정된 시스템 명령어와 선택적으로 exec 인수를 포함하는 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 : 단일 작업 시도에 대해 기다릴 수 있는 최대 시간(밀리초)입니다. |
initialPollInterval |
long : 작업 시도 간에 대기하는 초기 시간입니다. |
maxPollInterval |
long : 작업 시도 간에 대기할 최대 시간입니다. |
maxTime |
long : 작업을 계속 시도하는 데 걸리는 총 대략적인 최대 시간입니다. |
runnable |
IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
반환 값 | |
---|---|
boolean |
maxTime이 만료되기 전에 작업이 성공적으로 완료된 경우 true 입니다. |
runFixedTimedRetry
public boolean runFixedTimedRetry (long opTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
작업이 성공할 때까지 작업을 차단하고 여러 번 실행합니다.
매개변수 | |
---|---|
opTimeout |
long : 단일 작업 시도에 대해 기다릴 수 있는 최대 시간(밀리초)입니다. |
pollInterval |
long : 작업 시도 간에 대기하는 초기 시간입니다. |
maxTime |
long : 작업을 계속 시도하는 데 걸리는 총 대략적인 최대 시간입니다. |
runnable |
IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
반환 값 | |
---|---|
boolean |
maxTime이 만료되기 전에 작업이 성공적으로 완료된 경우 true 입니다. |
runFixedTimedRetryWithOutputMonitor
public boolean runFixedTimedRetryWithOutputMonitor (long opTimeout, long idleOutputTimeout, long pollInterval, long maxTime, IRunUtil.IRunnableResult runnable)
작업이 성공할 때까지 작업을 차단하고 여러 번 실행합니다. 또한 활동에 대한 출력 스트림을 모니터링하여 지정된 시간 동안 스트림 활동이 관찰되지 않으면 중단합니다. idleOutputTimeout이 0으로 설정되면 스트림 모니터링이 실행되지 않습니다.
매개변수 | |
---|---|
opTimeout |
long : 단일 작업 시도에 대해 기다릴 수 있는 최대 시간(밀리초)입니다. |
idleOutputTimeout |
long : 출력 스트림의 출력을 기다리는 최대 시간(밀리초) |
pollInterval |
long : 작업 시도 간에 대기하는 초기 시간입니다. |
maxTime |
long : 작업을 계속 시도하는 데 걸리는 총 대략적인 최대 시간입니다. |
runnable |
IRunUtil.IRunnableResult : 실행할 IRunUtil.IRunnableResult |
반환 값 | |
---|---|
boolean |
maxTime이 만료되기 전에 작업이 성공적으로 완료된 경우 true 입니다. |
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 : std 출력이 리디렉션되는 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이 0으로 설정되면 스트림 모니터링이 발생하지 않습니다.
매개변수 | |
---|---|
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 : std 출력이 리디렉션되는 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 : std 출력이 리디렉션되는 ERROR(/OutputStream) 입니다. null일 수 있습니다. |
stderr |
OutputStream : 오류 출력이 리디렉션되는 ERROR(/OutputStream) 입니다. null일 수 있습니다. |
command |
String : 지정된 시스템 명령어 및 선택적으로 exec 인수 |
반환 값 | |
---|---|
CommandResult |
명령어 실행 결과가 포함된 CommandResult |
runTimedCmdWithOutputMonitor
public CommandResult runTimedCmdWithOutputMonitor (long timeout, long idleOutputTimeout, String... command)
시스템 명령어를 실행하고 지정된 시간보다 오래 걸리는 경우 중단하는 도우미 메서드입니다. 또한 활동에 대한 출력 스트림을 모니터링하여 지정된 시간 동안 스트림 활동이 관찰되지 않으면 중단합니다. idleOutputTimeout이 0으로 설정되면 스트림 모니터링이 발생하지 않습니다.
매개변수 | |
---|---|
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이 0으로 설정되면 스트림 모니터링이 실행되지 않습니다.
매개변수 | |
---|---|
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이 0으로 설정되면 스트림 모니터링이 실행되지 않습니다.
매개변수 | |
---|---|
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 : 변수 이름 |